/* Modal Styles - EXACT copy of shortcut-search */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    background: rgba(0, 0, 0, 0.3);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    padding: 1.5rem 2rem;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-primary);
    background: var(--background-modal);
    transform: scale(0.98) translateY(8px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal.whats-new-modal {
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.whats-new-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.wn-skeleton-stack {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0.5rem;
}

.wn-skeleton-line {
    height: 0.72rem;
    border-radius: 0.25rem;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--border-primary) 55%, transparent) 0%,
        color-mix(in srgb, var(--border-primary) 25%, transparent) 50%,
        color-mix(in srgb, var(--border-primary) 55%, transparent) 100%
    );
    background-size: 200% 100%;
    animation: wnSkeletonShimmer 1.2s ease-in-out infinite;
}

.wn-skeleton-line--short {
    width: 62%;
}

.wn-lazy-sentinel {
    height: 1px;
    width: 100%;
    pointer-events: none;
}

.wn-load-more-hint {
    margin: 1rem 0 0.5rem;
    font-size: calc(var(--font-size-controls) * 0.9);
    color: var(--text-secondary);
    text-align: center;
}

.wn-empty {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    line-height: 1.55;
}

.wn-release-loading {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

@keyframes wnSkeletonShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

body.no-animations .wn-skeleton-line {
    animation: none;
}

/* ── What's New intro block ─────────────────────────────────────── */
.wn-intro {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-primary);
    background: color-mix(in srgb, var(--background-primary) 30%, transparent);
    flex-wrap: wrap;
}

.wn-intro-text {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--font-size-controls);
    color: var(--text-secondary);
    line-height: 1.55;
}

.wn-kofi-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: color-mix(in srgb, var(--accent-primary) 13%, transparent);
    color: var(--accent-primary);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 32%, transparent);
    border-radius: 0.4rem;
    text-decoration: none;
    font-size: var(--font-size-controls);
    font-family: var(--font-family-main);
    font-weight: var(--font-weight-normal);
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.wn-kofi-btn:hover {
    background: color-mix(in srgb, var(--accent-primary) 22%, transparent);
    border-color: color-mix(in srgb, var(--accent-primary) 55%, transparent);
    transform: translateY(-1px);
}

.wn-kofi-btn:active {
    transform: translateY(0);
}

.wn-kofi-icon {
    flex-shrink: 0;
}

/* ── What's New release blocks ─────────────────────────────────── */
.wn-release {
    margin-bottom: 1.75rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--accent-primary);
}
.wn-release:last-child { margin-bottom: 0; }

.wn-release-header {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}
.wn-release-tag {
    font-size: var(--font-size-controls);
    font-weight: var(--font-weight-semibold);
    color: var(--accent-primary);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 38%, transparent);
    background: color-mix(in srgb, var(--accent-primary) 9%, transparent);
    padding: 0.1rem 0.42rem;
}
.wn-release-date {
    font-size: var(--font-size-controls);
    color: var(--text-tertiary);
}

.wn-section { margin-bottom: 0.9rem; }
.wn-section:last-child { margin-bottom: 0; }

.wn-section-title {
    font-size: var(--font-size-category);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 0.45rem;
    letter-spacing: 0.01em;
}

.wn-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.45rem;
}
.wn-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.55;
}
.wn-item-text {
    flex: 1;
    font-size: var(--font-size-text);
    color: var(--text-secondary);
}
.wn-item-text strong { color: var(--text-primary); }
.wn-item-text code {
    font-family: var(--font-family-main);
    font-size: 0.88em;
    background: var(--background-secondary);
    border: 1px solid var(--border-primary);
    padding: 0.05rem 0.28rem;
    color: var(--text-primary);
}
.wn-badge {
    flex-shrink: 0;
    font-size: 0.68em;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.12rem 0.38rem;
    border: 1px solid;
    margin-top: 0.18rem;
    white-space: nowrap;
}
.wn-badge-new {
    color: var(--accent-success);
    border-color: color-mix(in srgb, var(--accent-success) 40%, transparent);
    background: color-mix(in srgb, var(--accent-success) 9%, transparent);
}
.wn-badge-fix {
    color: var(--text-tertiary);
    border-color: var(--border-primary);
    background: var(--background-secondary);
}

.modal.keyboard-cheat-sheet-modal {
    max-width: 480px;
    width: min(96vw, 480px);
    margin: auto;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.2rem;
}

.modal.keyboard-cheat-sheet-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
}

/* Fix hidden attribute override */
.modal-overlay[hidden] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.modal-header {
    display: flex;
    align-items: center;
    font-size: var(--font-size-bookmark);
    font-weight: var(--font-weight-semibold);
    justify-content: flex-start;
}

.modal-title {
    margin-right: 0.5rem;
    color: var(--text-primary);
}

.modal-body {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

/* New bookmark modal textarea */
.new-bookmark-textarea {
    width: 100%;
    min-height: 4rem;
    padding: 0.5rem;
    font-size: 0.95rem;
    resize: vertical;
    margin-top: 0.35rem;
}

.modal-text {
    min-width: 2ch;
    color: var(--text-primary);
    display: block;
}

.danger {
    color: var(--accent-error);
    font-weight: var(--font-weight-bold);
}

.modal-actions {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.modal-button {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-primary);
    background: transparent;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    font-family: var(--font-family-main);
    
    /* Remove tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.modal-button:hover,
.modal-button.selected {
    color: var(--text-primary);
    transform: translateX(4px);
}

.modal-button-prefix {
    font-weight: var(--font-weight-bold);
    margin-right: 1rem;
    min-width: 3ch;
    font-size: var(--font-size-controls);
    color: var(--accent-success);
}

.modal-button-name {
    font-size: var(--font-size-text);
    font-weight: var(--font-weight-semibold);
}

/* Danger button styles (red) */
.modal-button.danger {
    font-weight: var(--font-weight-bold);
    border: 1px solid var(--accent-error);
    color: var(--accent-error);
}

.modal-button.danger:hover,
.modal-button.danger.selected {
    background-color: var(--accent-error);
    color: var(--background-primary);
    transform: translateX(4px);
}

body.no-animations .modal-overlay,
body.no-animations .modal,
body.no-animations .modal-button {
    transition: none !important;
}

body.no-animations .modal {
    transform: none !important;
    opacity: 1 !important;
}

body.no-animations .modal-button:hover,
body.no-animations .modal-button.selected,
body.no-animations .modal-button.danger:hover,
body.no-animations .modal-button.danger.selected {
    transform: none !important;
}

.modal-button.danger .modal-button-prefix {
    color: var(--accent-error);
}

/* ESC to close hint */
.modal-esc-hint {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.68rem;
    color: var(--text-tertiary);
    opacity: 0.6;
    user-select: none;
    pointer-events: none;
}

.modal-esc-hint kbd {
    font-family: var(--font-family-main);
    font-size: 0.65rem;
    font-weight: var(--font-weight-semibold);
    padding: 0.1rem 0.32rem;
    border: 1px solid var(--border-primary);
    background: var(--background-secondary);
    color: var(--text-tertiary);
    border-radius: 3px;
    letter-spacing: 0.04em;
    line-height: 1;
    vertical-align: baseline;
}

.modal-esc-hint:empty {
    display: none;
}

@media (pointer: coarse) {
    .modal-esc-hint { display: none; }
}

/* Modal select styling */
.modal-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-primary);
    background: var(--background-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-controls);
    margin-top: 0.5rem;
}

/* Modal page list styling */
.modal-page-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.modal-page-btn {
    padding: 0.5rem;
    border: 1px solid var(--border-primary);
    background: var(--background-primary);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: var(--font-size-controls);
    transition: background-color 0.3s ease;
}

.modal-page-btn:hover:not(.current) {
    background-color: var(--background-secondary);
}

.modal-page-btn.current {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Keyboard cheat sheet: accordion style ───────────────────────────────── */

.keyboard-cheat-sheet {
    width: 100%;
}

.cheat-sheet-filter {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    outline: none;
    padding: 0.35rem 0.65rem;
    transition: border-color 0.12s;
}
.cheat-sheet-filter:focus {
    border-color: var(--accent-primary);
}
.cheat-sheet-filter::placeholder {
    color: var(--text-tertiary);
    opacity: 0.65;
}

.cheat-sheet-group {
    border-bottom: 1px solid var(--border-primary);
}

.cheat-sheet-group:last-child {
    border-bottom: none;
}

.cheat-sheet-group-title {
    list-style: none;
    cursor: pointer;
    padding: 0.5rem 0;
    font-size: 0.7rem;
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.cheat-sheet-group-title::-webkit-details-marker {
    display: none;
}

.cheat-sheet-group-title::before {
    content: '▶';
    font-size: 0.5rem;
    color: var(--text-tertiary);
    transition: transform 0.15s ease;
    display: inline-block;
}

.cheat-sheet-group[open] .cheat-sheet-group-title::before {
    transform: rotate(90deg);
}

.cheat-sheet-group-title:hover {
    color: var(--text-secondary);
}

.keyboard-cheat-sheet-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-bottom: 0.5rem;
}

.keyboard-cheat-sheet-table td {
    padding: 0.22rem 0;
    border-bottom: 1px solid var(--border-primary);
    vertical-align: top;
    line-height: 1.35;
}

.keyboard-cheat-sheet-table tr:last-child td {
    border-bottom: none;
}

.keyboard-cheat-sheet-keys {
    font-family: "Source Code Pro", monospace;
    font-size: 0.8rem;
    font-weight: var(--font-weight-bold);
    color: var(--accent-primary);
    white-space: normal;
    word-break: break-word;
    padding-right: 1rem;
    width: 40%;
}

.keyboard-cheat-sheet-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-width: 0;
    overflow-wrap: anywhere;
    width: 60%;
}

@media (prefers-reduced-motion: reduce) {
    /* Modal open/close → keep opacity fade, remove scale + translate */
    .modal { transform: none !important; transition: opacity 0.15s ease !important; }
    .modal-overlay.show .modal { transform: none !important; }
    .modal-button,
    .modal-button:hover,
    .modal-button.selected,
    .modal-button.danger:hover,
    .modal-button.danger.selected { transition: none !important; transform: none !important; }
}
