:root {
    --ink: #1f2937;
    --muted: #64748b;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #e2e8f0;
    --primary: #635bff;
    --primary-dark: #4f46e5;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
}

html {
    background: #eef2ff;
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(circle at 0 0, rgba(99, 91, 255, 0.08), transparent 32rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%) !important;
    color: var(--ink) !important;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif !important;
    line-height: 1.5;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 64px;
    padding: 14px clamp(16px, 4vw, 42px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 24px rgba(30, 41, 59, 0.16) !important;
    backdrop-filter: blur(14px);
}

.topbar h1 {
    letter-spacing: -0.01em !important;
}

.topbar a,
.topbar button,
.topbar .rewards-btn {
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease !important;
}

.topbar a:hover,
.topbar button:hover,
.topbar .rewards-btn:hover {
    transform: translateY(-1px);
}

.container {
    width: min(100% - 32px, 1080px);
    margin: clamp(20px, 4vw, 36px) auto !important;
    padding: 0 !important;
}

.card,
.selector-card,
.stat-card,
.dish-row,
.book-card,
.reward-card {
    border: 1px solid rgba(226, 232, 240, 0.85) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.card:hover,
.selector-card:hover,
.stat-card:hover,
.dish-row:hover,
.book-card:hover,
.reward-card:hover {
    border-color: #cbd5e1 !important;
    box-shadow: var(--shadow-md) !important;
}

input,
textarea,
select {
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    background: var(--surface) !important;
    color: var(--ink) !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.14) !important;
}

button,
.btn {
    border-radius: 10px !important;
    font-weight: 650 !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease !important;
}

button:not(:disabled):hover,
.btn:not(.btn-disabled):hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 5px 12px rgba(15, 23, 42, 0.12);
}

a {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 700px) {
    body {
        overflow-x: hidden;
        font-size: 15px;
    }

    .container {
        width: min(100% - 20px, 1080px);
        margin-top: 16px !important;
    }

    .topbar {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 10px !important;
        padding: 12px 14px !important;
    }

    .topbar h1 {
        max-width: calc(100% - 42px);
        font-size: 1rem !important;
        line-height: 1.3;
    }

    .topbar > a:first-child {
        min-width: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar .count {
        margin-left: auto;
    }

    .topbar-links {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .topbar-links::-webkit-scrollbar {
        display: none;
    }

    .topbar-links a {
        flex: 0 0 auto;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    .card,
    .selector-card {
        padding: 16px !important;
        border-radius: 14px !important;
    }

    .stats,
    .summary-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px !important;
    }

    .stat-card,
    .stat-chip,
    .summary-card {
        min-width: 0 !important;
        width: 100%;
        padding: 10px !important;
    }

    .book-grid,
    .rewards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .book-card {
        min-width: 0;
    }

    .cover-wrap {
        height: 150px !important;
    }

    .book-card .book-info,
    .book-card .book-title,
    .dish-header-name,
    .card-name {
        overflow-wrap: anywhere;
    }

    .add-form .row,
    .master-form,
    .filter-bar,
    .selector-card,
    .detail-actions,
    .task-actions,
    .book-actions,
    .card-actions {
        width: 100%;
    }

    .add-form .row > *,
    .master-form > *,
    .filter-bar > *,
    .selector-card > * {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        width: 100%;
    }

    .dish-toolbar {
        align-items: stretch !important;
    }

    .dish-toolbar .search-bar,
    .dish-toolbar .dish-sort,
    .dish-toolbar .count-badge {
        flex: 1 1 100% !important;
        width: 100% !important;
    }

    .dish-filter {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-bottom: 12px;
    }

    .dish-filter button {
        min-height: 40px;
    }

    .add-form input,
    .add-form textarea,
    .add-form select,
    .add-form button,
    .master-form input,
    .master-form button,
    .filter-bar input,
    .filter-bar select {
        width: 100% !important;
        min-height: 42px;
    }

    .detail-actions,
    .task-actions,
    .book-actions,
    .card-actions {
        gap: 6px !important;
    }

    .detail-actions > *,
    .task-actions > *,
    .book-actions > *,
    .card-actions > * {
        flex: 1 1 auto;
    }

    .btn,
    button,
    input,
    select,
    textarea {
        min-height: 42px;
    }

    textarea {
        min-height: 88px;
    }

    .cal-grid {
        gap: 2px !important;
    }

    .cal-day {
        min-height: 54px !important;
        padding: 5px !important;
        font-size: 0.72rem !important;
    }

    .modal,
    .sug-modal {
        width: calc(100% - 20px) !important;
        max-height: calc(100vh - 32px) !important;
        border-radius: 16px !important;
    }

    .table-wrap {
        margin-left: -4px;
        margin-right: -4px;
    }

    table {
        min-width: 620px;
    }

    .flow-toolbar {
        flex-wrap: wrap;
    }

    .flow-palette {
        width: 100% !important;
    }
}

@media (max-width: 420px) {
    .book-grid,
    .rewards-grid {
        grid-template-columns: 1fr !important;
    }

    .cover-wrap {
        height: 190px !important;
    }

    .stats,
    .summary-row {
        grid-template-columns: 1fr;
    }

    .topbar-links a {
        font-size: 0.74rem !important;
        padding-left: 9px !important;
        padding-right: 9px !important;
    }
}

.purchase-row.highlight-global { background-color: #fff9c4; border-left: 4px solid #fbc02d; }
.static-time-field { display: none; }
.static-time-field.visible { display: inline-block; }
.btn-cancel { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.btn-cancel:hover { background: #e2e8f0; }
