@font-face {
    font-family: 'Mesgentia';
    src: url('/assets/fonts/Mesgentia.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    ascent-override: 100%;
    descent-override: 20%;
    line-gap-override: 0%;
}

@font-face {
    font-family: 'Mineko';
    src: url('/assets/fonts/Mineko.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    ascent-override: 97.5%;
    descent-override: 22.5%;
    line-gap-override: 0%;
}

@font-face {
    font-family: 'Minecraft';
    src: url('/assets/fonts/MinecraftRegular-Bmg3.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Minecraft';
    src: url('/assets/fonts/MinecraftBold-nMK1.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Minecraft';
    src: url('/assets/fonts/MinecraftItalic-R8Mo.otf') format('opentype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Minecraft';
    src: url('/assets/fonts/MinecraftBoldItalic-1y1e.otf') format('opentype');
    font-weight: bold;
    font-style: italic;
}

@font-face {
    font-family: 'Imprima';
    src: url('/assets/fonts/Imprima-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Lora';
    src: url('/assets/fonts/Lora-Regular.ttf?v=2') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Lora';
    src: url('/assets/fonts/Lora-Bold.ttf?v=2') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Lora';
    src: url('/assets/fonts/Lora-Italic.ttf?v=2') format('truetype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Lora';
    src: url('/assets/fonts/Lora-BoldItalic.ttf?v=2') format('truetype');
    font-weight: bold;
    font-style: italic;
}

:root {
    --primary: #B8878C;
    --primary-light: #c9a8a8;
    --sync-fill: #f1f1ef;
    --primary-lighter: #e8d4d4;
    --primary-hover: #dcc3c6;
    --background: #FDF8F4;
    --cream: #f8f0f0;
    --text: #555;
    --text-muted: #6B6B6B;
    --border: #deb8b8;
    --white: #fff;
    --window-bg: var(--white);
    --completed: #B8878C;
    --grid-bg: linear-gradient(rgba(222, 184, 184, 0.1) 1px, transparent 1px),
                linear-gradient(90deg, rgba(222, 184, 184, 0.1) 1px, transparent 1px);
    --scale: 1;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --background: #121212;
        --white: #1e1e1e;
        --cream: #252525;
        --text: #e3e3e2;
        --text-muted: #9b9a97;
        --primary-light: #37352f;
        --sync-fill: #2a2a2a;
        --primary-lighter: #2f2f2f;
        --border: #2f2f2f;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --background: #121212;
    --sync-fill: #2a2a2a;
    --white: #1e1e1e;
    --cream: #252525;
    --text: #e3e3e2;
    --text-muted: #9b9a97;
    --primary-light: #37352f;
    --primary-lighter: #2f2f2f;
    --border: #2f2f2f;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --background: #FDF8F4;
    --sync-fill: #f1f1ef;
    --white: #fff;
    --cream: #f8f0f0;
    --text: #555;
    --text-muted: #6B6B6B;
    --border: #deb8b8;
    color-scheme: light;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: transparent !important;
}

body {
    font-family: var(--font-family);
    background: transparent !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.y2k-window {
    width: 100%;
    background: var(--window-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    zoom: var(--scale);
    max-width: 420px;
    min-height: 500px;
}

.y2k-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.y2k-title-bar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--border);
    letter-spacing: -0.3px;
}

.y2k-title-bar-left svg {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.y2k-title-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.y2k-window-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.y2k-stats-btn,
.y2k-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.15s, background-color 0.15s;
    padding: 0;
}

/* the stats hover shape matches the settings icon's, which kou-theme sizes at 18px */
.y2k-stats-btn {
    width: 18px;
    height: 18px;
}

/* and its icon matches the cog's 12px */
.y2k-title-bar-left .y2k-stats-btn svg {
    width: 12px;
    height: 12px;
}

.y2k-stats-btn:hover,
.y2k-settings-btn:hover {
    opacity: 1;
    background: var(--primary-hover);
    color: var(--primary);
}

.y2k-settings-btn svg {
    display: block;
    transition: transform 0.3s ease;
}

.y2k-settings-btn:hover svg {
    transform: rotate(45deg);
}

.y2k-content {
    flex: 1;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    background-color: var(--window-bg);
    background-image: var(--grid-bg);
    background-size: 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-lighter) transparent;
    transition: scrollbar-color 0.15s;
}

.y2k-content:hover {
    scrollbar-color: var(--primary-hover) transparent;
}

.library-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.goal-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--cream);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.goal-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.goal-progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
}

.goal-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.goal-bar-container {
    width: 80px;
    height: 6px;
    background: var(--primary-lighter);
    border-radius: 3px;
    overflow: hidden;
}

.goal-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px;
    flex: 1;
    min-height: 0;
    max-height: 380px;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
    grid-auto-rows: max-content;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 168, 168, 0.3) transparent;
    transition: scrollbar-color 0.15s;
}

.book-grid:hover {
    scrollbar-color: var(--primary-hover) transparent;
}

@supports not (scrollbar-color: auto) {
    .book-grid::-webkit-scrollbar {
        width: 4px;
    }

    .book-grid::-webkit-scrollbar-track {
        background: transparent;
    }

    .book-grid::-webkit-scrollbar-thumb {
        background: rgba(201, 168, 168, 0.3);
        border-radius: 2px;
    }

    .book-grid:hover::-webkit-scrollbar-thumb {
        background: var(--primary-hover);
    }

    .book-grid::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }
}

.book-cover-wrapper {
    aspect-ratio: 2/3;
    width: 100%;
    height: auto;
    min-height: 60px;
    background: var(--primary-lighter);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}

.book-cover-wrapper:hover {
    transform: translateY(-2px);
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-lighter) 0%, var(--cream) 100%);
    color: var(--text-muted);
    font-size: 9px;
    text-align: center;
    padding: 8px;
}

.book-cover-placeholder svg {
    margin-bottom: 4px;
    opacity: 0.5;
}

.book-rating-overlay {
    position: absolute;
    bottom: 4px;
    left: 4px;
    display: flex;
    gap: 1px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 4px;
    border-radius: 4px;
}

.book-rating-overlay svg {
    width: 8px;
    height: 8px;
}

.book-status-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    border: 1px solid var(--white);
}

.book-status-indicator.reading {
    background: #87B887;
}

.book-status-indicator.completed {
    background: var(--primary);
}

.empty-library {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-library svg {
    margin-bottom: 8px;
    color: var(--primary);
}

.empty-library p {
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.empty-library span {
    font-size: 9px;
    opacity: 0.7;
}

.y2k-add-btn {
    position: absolute;
    /* the 25px footer + 10px, so the gap above the footer line matches the 10px on the right */
    bottom: 35px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--on-accent, var(--white));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s;
    z-index: 10;
}

.y2k-add-btn:hover {
    background: var(--primary-hover);
}

.y2k-add-btn svg {
    width: 14px;
    height: 14px;
}

.y2k-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 25px;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    background: var(--window-bg);
    flex-shrink: 0;
}

.y2k-footer-left {
    font-size: 10px;
    color: var(--text-muted);
}

.y2k-progress {
    font-weight: 500;
}

.y2k-footer-right {
    font-size: 10px;
    color: var(--text-muted);
}

.y2k-book-count {
    font-weight: 500;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 10px;
    font-family: var(--font-family);
    padding: 8px 12px;
    transition: color 0.15s;
}

.back-btn:hover {
    color: var(--primary);
}

.book-detail-view {
    padding: 0;
}

.book-detail-content {
    padding: 0 12px 12px;
}

.book-detail-header {
    display: flex;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.book-detail-cover {
    width: 80px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.book-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-detail-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.book-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: flex-start;
    align-items: center;
    margin-top: 5px;
    width: 62px;
    flex-shrink: 0;
}

.book-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.book-author {
    font-size: 10px;
    color: var(--text-muted);
}

.book-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    color: var(--text-muted);
}

.book-meta span {
    background: var(--primary-lighter);
    padding: 3px 10px;
    border-radius: 20px;
}

.pages-editable {
    cursor: pointer;
    transition: opacity 0.15s;
}

.pages-editable:hover {
    opacity: 0.7;
}

.click-hint {
    font-size: 7px;
    color: var(--text-muted);
    opacity: 0.5;
    background: transparent !important;
    padding: 0 !important;
}

.book-status-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-lighter);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 9px;
    text-transform: capitalize;
}

.book-status-tag.reading {
    background: #d4edda;
}

.book-status-tag.completed {
    background: var(--primary-lighter);
}

.book-status-tag.planned {
    background: #fff3cd;
}

.status-btn {
    width: 100%;
    padding: 4px 0;
    font-size: 8px;
    border: 0.5px solid var(--border);
    border-radius: 20px;
    background: var(--window-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-btn:hover {
    background: var(--primary-hover);
    color: var(--text);
}

.status-btn.active {
    background: var(--primary-lighter);
    color: var(--text);
}

.favorite-btn {
    padding: 4px 8px;
    font-size: 8px;
    border: 0.5px solid var(--border);
    border-radius: 50%;
    background: var(--window-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.favorite-btn:hover {
    background: var(--primary-hover);
}

.favorite-btn.active {
    background: var(--primary-lighter);
}

.book-detail-rating {
    display: flex;
    gap: 2px;
    margin-top: auto;
}

.book-detail-rating svg {
    width: 14px;
    height: 14px;
}

.progress-section {
    background: var(--cream);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.progress-text {
    font-size: 10px;
    color: var(--primary);
}

.progress-bar-container {
    height: 8px;
    background: var(--primary-lighter);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.progress-input {
    width: 42px;
    padding: 4px 6px;
    font-size: 10px;
    font-family: var(--font-family);
    border: 1px solid var(--border);
    border-radius: 20px;
    text-align: center;
}

.progress-input:focus {
    outline: none;
    border-color: var(--primary);
}

.progress-total {
    font-size: 10px;
    color: var(--text-muted);
}

.stats-view {
    padding: 0;
    background-color: var(--window-bg);
    background-image: var(--grid-bg);
    background-size: 8px 8px;
}

.stats-content {
    padding: 0 12px 12px;
}

.stats-content h3 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 12px;
}

.stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--cream);
    border: 0.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 7px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stats-h4 {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.status-breakdown {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--cream);
    padding: 6px 10px;
    border-radius: 20px;
}

.favorites-section {
    margin-top: 16px;
}

.favorites-section h4 {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px;
    background: var(--cream);
    border-radius: 8px;
    max-height: calc(2 * 85px + 16px);
    overflow-y: auto;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-lighter) transparent;
    transition: scrollbar-color 0.15s;
}

.favorites-grid:hover {
    scrollbar-color: var(--primary-hover) transparent;
}

@supports not (scrollbar-color: auto) {
    .favorites-grid::-webkit-scrollbar {
        width: 4px;
    }

    .favorites-grid::-webkit-scrollbar-track {
        background: transparent;
    }

    .favorites-grid::-webkit-scrollbar-thumb {
        background: var(--primary-lighter);
        border-radius: 2px;
    }

    .favorites-grid::-webkit-scrollbar-thumb:hover {
        background: var(--primary-hover);
    }
}

.favorite-cover {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.15s;
}

.favorite-cover:hover {
    transform: scale(1.05);
}

.favorite-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 4px;
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.favorite-placeholder svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary);
    opacity: 0.5;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.reading {
    background: #87B887;
}

.status-dot.completed {
    background: var(--primary);
}

.status-dot.planned {
    background: var(--text-muted);
}

.status-count {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
}

.status-name {
    font-size: 9px;
    color: var(--text-muted);
}

.diary-section {
    margin-bottom: 12px;
}

.diary-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    display: block;
}

.thought-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
    max-height: 140px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: auto;
}

.thought-list::-webkit-scrollbar {
    width: 4px;
}

.thought-list::-webkit-scrollbar-track {
    background: transparent;
}

.thought-list::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 168, 0.3);
    border-radius: 2px;
}

.thought-list:hover::-webkit-scrollbar-thumb {
    background: var(--primary-hover);
}

@supports not selector(::-webkit-scrollbar) {
    .thought-list {
        scrollbar-width: thin;
        scrollbar-color: rgba(201, 168, 168, 0.3) transparent;
    }
}

.thought-list:empty {
    display: none;
}

.thought-item {
    flex-shrink: 0;
    padding: 7px 10px 5px;
    border-radius: 12px;
    background: var(--primary-lighter);
    color: var(--text);
    font-size: 10px;
    line-height: 1.5;
}

.thought-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-align: justify;
}

.thought-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 14px;
}

.thought-date {
    font-size: 8px;
    color: var(--text-muted);
}

.thought-delete {
    width: 14px;
    height: 14px;
    margin-right: -4.375px;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.thought-item:hover .thought-delete,
.thought-delete:focus-visible {
    opacity: 1;
}

.thought-delete:hover {
    color: var(--primary);
}

@media (hover: none) {
    .thought-delete {
        opacity: 0.6;
    }
}

.thought-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.thought-input-container {
    flex: 1;
    min-width: 0;
    display: flex;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--cream);
    transition: border-color 0.15s;
}

.thought-input-container:focus-within {
    border-color: var(--primary);
}

.thought-input {
    flex: 1;
    min-width: 0;
    min-height: 26px;
    max-height: 120px;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 10px;
    font-family: var(--font-family);
    line-height: 1.4;
    resize: none;
    outline: none;
    overflow-y: auto;
}

.thought-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.thought-pin-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: var(--on-accent, var(--white));
    cursor: pointer;
    transition: background-color 0.15s;
}

.thought-pin-btn:hover {
    background: var(--primary-hover);
}

.rating-edit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rating-edit svg {
    width: 16px;
    height: 16px;
    cursor: pointer;
    transition: transform 0.1s;
}

.rating-edit svg:hover {
    transform: scale(1.2);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--primary-lighter);
}

.settings-header h3 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-close {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.15s, background-color 0.15s;
}

.settings-close:hover {
    opacity: 1;
    background: var(--primary-hover);
}

.settings-section {
    margin-bottom: 12px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    display: block;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

#accent-color,
#bg-color {
    width: 18px;
    height: 18px;
    border: 1px solid var(--primary-lighter);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

#accent-color::-webkit-color-swatch-wrapper,
#bg-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

#accent-color::-webkit-color-swatch,
#bg-color::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

/* title bar swatch comes from kou-theme.css at 28px; kouread keeps every swatch even with its hex box */
.settings-panel #titlebar-color,
.settings-panel .titlebar-clear {
    width: 18px;
    height: 18px;
}

/* the clear x is just the x: no pad shape, full strength so it reads in light and dark */
.settings-panel .titlebar-clear {
    background: none;
    opacity: 1;
    margin-left: -6px;
}

/* a 10px x; its ink sits 8px from the hex box, the same gap as the swatch (nari, 10/02) */
.settings-panel .titlebar-clear svg {
    width: 10px;
    height: 10px;
}

.settings-panel .titlebar-clear:hover {
    color: var(--text);
}

.color-hex {
    width: 62px;
    height: 18px;
    font-size: 10px;
    font-family: inherit;
    color: var(--text);
    font-weight: 400;
    background: var(--primary-lighter);
    border: none;
    border-radius: 999px;
    padding: 3px 6px;
    text-align: center;
    outline: none;
    transition: background-color 0.15s ease;
}

.color-hex:focus {
    background: var(--primary-light);
}

.font-select {
    width: 100%;
    padding: 6px 12px;
    font-size: 10px;
    font-family: inherit;
    border: none;
    border-radius: 999px;
    background: var(--primary-lighter);
    color: var(--text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    transition: all 0.15s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 1 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.font-select:hover {
    background-color: var(--primary-hover);
}

.font-select:focus {
    border-color: var(--primary);
}

.font-select option {
    background: var(--white);
    color: var(--text);
}

.shape-options {
    display: flex;
    gap: 8px;
}

.shape-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.shape-btn:hover {
    background: var(--primary-hover);
}

/* the selected shape matches the settings icon picker: soft fill, no outline */
.shape-btn.active {
    background: var(--primary-lighter);
    border-color: transparent;
}

.shape-btn svg {
    color: var(--text-muted);
}

.shape-btn.active svg {
    color: var(--primary);
}

.goal-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.goal-input {
    width: 32px;
    height: 18px;
    padding: 0 6px;
    font-size: 10px;
    font-family: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--primary-lighter);
    border: none;
    border-radius: 999px;
    text-align: center;
    outline: none;
}

.goal-input:focus {
    background: var(--primary-light);
}

.goal-input-wrapper span {
    font-size: 9px;
    color: var(--text-muted);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.size-slider {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--primary-lighter);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.size-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
}

.add-book-panel {
    position: absolute;
    top: 36px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 300px;
    max-height: calc(100% - 50px);
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: none;
    z-index: 100;
    box-shadow: none;
    zoom: var(--scale);
}

.add-book-panel.active {
    display: block;
}

.add-book-content {
    padding: 12px;
    max-height: calc(100% - 50px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-lighter) transparent;
}

@supports not (scrollbar-color: auto) {
    .add-book-content::-webkit-scrollbar {
        width: 4px;
    }
    .add-book-content::-webkit-scrollbar-track {
        background: transparent;
    }
    .add-book-content::-webkit-scrollbar-thumb {
        background: var(--primary-lighter);
        border-radius: 2px;
    }
}

.add-book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.add-book-header h3 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-section {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.search-input {
    flex: 1;
    padding: 8px 14px;
    font-size: 10px;
    font-family: var(--font-family);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: var(--on-accent, var(--white));
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-btn:hover {
    background: var(--primary-hover);
}

.search-results {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
}

.search-result-item {
    display: flex;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-result-item:hover {
    background: var(--primary-hover);
}

.search-result-cover {
    width: 30px;
    height: 45px;
    background: var(--primary-lighter);
    border-radius: 4px;
    overflow: hidden;
}

.search-result-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-info {
    flex: 1;
}

.search-result-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.search-result-author {
    font-size: 9px;
    color: var(--text-muted);
}

.manual-entry {
    margin-bottom: 12px;
}

.manual-label {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
}

.manual-input {
    width: 100%;
    padding: 8px 14px;
    font-size: 10px;
    font-family: var(--font-family);
    border: 1px solid var(--border);
    border-radius: 20px;
    margin-bottom: 6px;
    background: var(--white);
}

.manual-input:focus {
    outline: none;
    border-color: var(--primary);
}

.manual-input:last-child {
    margin-bottom: 0;
}

.add-book-submit {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: var(--on-accent, var(--white));
    border: none;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-book-submit:hover {
    background: var(--primary-hover);
}

@media (max-width: 400px) {
    body {
        padding: 8px;
    }

    .y2k-window {
        max-width: 100%;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-panel,
    .add-book-panel {
        max-width: calc(100% - 24px);
    }
}

@supports not (scrollbar-color: auto) {
    .y2k-content::-webkit-scrollbar {
        width: 6px;
    }

    .y2k-content::-webkit-scrollbar-track {
        background: transparent;
    }

    .y2k-content::-webkit-scrollbar-thumb {
        background: var(--primary-lighter);
        border-radius: 3px;
    }

    .y2k-content::-webkit-scrollbar-thumb:hover {
        background: var(--primary-hover);
    }
}

.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    max-height: 70vh;
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: none;
    z-index: 1000;
    box-sizing: border-box;
    box-shadow: none;
}

.settings-panel.active {
    display: block;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    display: none;
    z-index: 999;
}

.settings-overlay.active {
    display: block;
}

.settings-content {
    padding: 12px;
    max-height: calc(70vh - 4px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* a thin 4px bar in the customer's own accent, like kousched */
.settings-content::-webkit-scrollbar {
    width: 4px;
}

.settings-content::-webkit-scrollbar-track {
    background: transparent;
}

.settings-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}

.sync-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--primary-lighter);
}

.sync-section label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.sync-status-panel {
    background: var(--primary-lighter);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--primary-lighter);
}

.sync-buttons-row {
    display: flex;
    flex-direction: row;
    gap: 6px;
    width: 100%;
}

.sync-buttons-row .sync-btn {
    flex: 1;
    min-width: 0;
    font-size: 10px;
}

.sync-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    min-height: 24px;
}

.sync-status-row:not(:last-child) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sync-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.3;
}

.sync-value {
    font-size: 10px;
    color: var(--text);
    font-weight: 500;
    line-height: 1.3;
    display: flex;
    align-items: center;
}

.sync-check {
    font-size: 12px;
}

.sync-time-value {
    color: var(--text-muted);
    font-size: 10px;
}

.sync-code-row {
    flex-wrap: nowrap;
    gap: 6px;
}

.sync-code-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background: var(--white);
    border-radius: 999px;
    border: 1px solid var(--primary-lighter);
    min-width: 0;
    flex-shrink: 1;
    max-width: 100%;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sync-code-pill:hover {
    background: var(--primary-hover);
}

.sync-code-pill:active {
    transform: scale(0.97);
}

.sync-code-value {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.3px;
    margin-top: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-link-section {
    margin-top: 10px;
    padding-top: 10px;
    margin-bottom: 10px;
    border-top: 1px solid var(--primary-lighter);
}

.share-link-section label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.share-link-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-lighter);
    border-radius: 999px;
    padding: 6px 6px 6px 10px;
}

.share-link-input {
    flex: 1;
    min-width: 0;
    padding: 4px 0;
    border: none;
    background: transparent;
    font-size: 9px;
    font-family: var(--font-family), sans-serif;
    color: var(--text);
    outline: none;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.share-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: var(--primary);
    color: var(--on-accent, white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.share-copy-btn:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.share-copy-btn:active {
    transform: scale(0.98);
}

.share-copy-btn svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.sync-error-panel {
    background: rgba(231, 76, 60, 0.1);
    border-radius: 999px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(231, 76, 60, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-error-icon {
    font-size: 14px;
    color: #c0392b;
}

.sync-error-message {
    font-size: 10px;
    color: #c0392b;
    flex: 1;
}

.sync-controls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.sync-btn {
    flex: 1;
    min-width: 60px;
    padding: 6px 10px;
    border: none;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 500;
    font-family: var(--font-family), sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--primary);
    color: var(--on-accent, white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sync-btn:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.sync-btn:active {
    transform: scale(0.98);
}

.sync-btn.secondary {
    background: var(--sync-fill);
    color: var(--text);
}

.sync-btn.danger {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
}

.sync-btn.danger:hover {
    background: rgba(231, 76, 60, 0.25);
}

#sync-code-input {
    flex: 1;
    min-width: 60px;
    padding: 6px 10px;
    border: none;
    border-radius: 999px;
    font-size: 9px;
    font-family: var(--font-family), sans-serif;
    background: var(--primary-lighter);
    transition: background-color 0.15s ease;
}

#sync-code-input:focus {
    outline: none;
    background: var(--primary-light);
}

.sync-hint {
    font-size: 9px;
    color: var(--text-muted);
    margin: 6px 0 0 0;
    text-align: center;
}

.setting-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.setting-toggle-row .settings-label {
    margin-bottom: 0;
}

.cute-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}

.cute-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--primary-lighter);
    transition: .2s ease;
    border-radius: 999px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--white);
    transition: .2s ease;
    border-radius: 50%;
}

.cute-toggle input:checked + .toggle-slider {
    background-color: var(--primary);
}

.cute-toggle input:checked + .toggle-slider:before {
    transform: translateX(14px);
}

.y2k-window.hide-grid .y2k-content,
.y2k-window.hide-grid .stats-view {
    background-image: none !important;
}

.y2k-window.hide-border {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
}

.y2k-window.hide-border .y2k-title-bar {
    background-color: transparent !important;
    border-bottom-color: transparent !important;
}

[data-titlebar="custom"] .y2k-window.hide-border .y2k-title-bar #settings-btn svg,
[data-titlebar="custom"] .y2k-window.hide-border .y2k-title-bar #settings-btn svg * {
    color: var(--primary, var(--border-color, #b8878c));
}

.y2k-window.hide-border .y2k-content,
.y2k-window.hide-border .y2k-footer,
.y2k-window.hide-border .goal-banner {
    background-color: transparent !important;
    border-top-color: transparent !important;
    border-bottom-color: transparent !important;
}

html.has-window-bg .y2k-window.hide-border,
html.has-window-bg .y2k-window.hide-border .y2k-content,
html.has-window-bg .y2k-window.hide-border .y2k-footer {
    background-color: var(--window-bg) !important;
}

html.has-window-bg {
    --kou-titlebar-bg: var(--white);
}

.y2k-window.hide-border .book-grid::-webkit-scrollbar {
    border-left: none !important;
}
.y2k-window.hide-border .book-grid::-webkit-scrollbar-thumb {
    border: 2px solid transparent !important;
}
.y2k-window.hide-border .book-grid::-webkit-scrollbar-button {
    border-bottom: none !important;
    border-top: none !important;
}

[data-shape="square"] .book-cover-wrapper,
[data-shape="square"] .book-detail-cover,
[data-shape="square"] .book-rating-overlay,
[data-shape="square"] .book-status-indicator,
[data-shape="square"] .book-status-tag,
[data-shape="square"] .status-btn,
[data-shape="square"] .status-item,
[data-shape="square"] .status-dot,
[data-shape="square"] .book-meta span,
[data-shape="square"] .pages-editable,
[data-shape="square"] .progress-total,
[data-shape="square"] .progress-section,
[data-shape="square"] .progress-bar-container,
[data-shape="square"] .progress-bar-fill,
[data-shape="square"] .progress-input,
[data-shape="square"] .goal-bar-container,
[data-shape="square"] .goal-bar,
[data-shape="square"] .goal-input,
[data-shape="square"] .favorite-cover,
[data-shape="square"] .favorite-placeholder,
[data-shape="square"] .favorites-grid,
[data-shape="square"] .thought-item,
[data-shape="square"] .thought-input-container,
[data-shape="square"] .thought-pin-btn,
[data-shape="square"] .thought-list::-webkit-scrollbar-thumb {
    border-radius: 0;
}

[data-shape="square"] #delete-book-btn {
    border-radius: 0 !important;
}

[data-shape="square"] .add-book-panel,
[data-shape="square"] .search-results,
[data-shape="square"] .search-result-cover,
[data-shape="square"] .add-book-submit {
    border-radius: 0;
}

[data-shape="square"] #sync-code-input {
    border-radius: 0;
}

.window-style-toggle .window-style-btn.active {
    color: var(--on-accent, var(--white));
}


/* the embed block is the first thing inside the sync section, so its own top
   margin, padding and border doubled the section's own. one divider, not two.
   nari spotted the gap in koucard 2026-10-01. */
.sync-section > .share-link-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* the title stays put while the settings scroll, like kourie's. it sits outside
   the scroller now, in the same spot as before, and the scroller keeps its 4px
   gutter so the line under the title ends where the rows do. nari 2026-10-02. */
.settings-panel.active {
    display: flex;
    flex-direction: column;
}

.settings-panel > .settings-header {
    flex-shrink: 0;
    margin: 12px 16px 0 12px;
}

.settings-panel > .settings-content {
    min-height: 0;
    scrollbar-gutter: stable;
}

/* the pill words (Curve / Square, Outline / Filled): the line is trimmed to the letters, then
   lifted so the middle point between the capital tops and the lowercase tops sits at the middle
   of the pill. it reads each font's own cap and x-heights, so it fits every widget font; same 25px
   pill. browsers without text-box or the cap unit keep a centered line. nari, 10/02 */
.settings-panel .window-style-btn {
    text-box: trim-both cap alphabetic;
    height: 25px;
    padding-top: 0;
    padding-bottom: 0;
    padding-bottom: calc((1cap - 1ex) / 2);
}

/* Imprima sits a hair high with the rule above, so it comes down a quarter pixel (nari's pick) */
@container style(--font-family: 'Imprima', sans-serif) {
    .settings-panel .window-style-btn {
        padding-bottom: calc((1cap - 1ex) / 2 - 0.5px);
    }
}

html.fill-embed body {
    padding: 0;
    height: 100vh;
    min-height: 0;
}

html.fill-embed .y2k-window {
    max-width: none;
    height: 100%;
    min-height: 0;
    zoom: 1;
}

html.fill-embed .y2k-title-bar,
html.fill-embed .y2k-content,
html.fill-embed .y2k-footer,
html.fill-embed .y2k-add-btn {
    zoom: var(--scale, 1);
}

html.fill-embed .y2k-content {
    min-height: 0;
}

html.fill-embed .book-grid {
    max-height: none;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
}

html.fill-embed .book-detail-view,
html.fill-embed .stats-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 168, 168, 0.3) transparent;
}
