:root {
    --bg: #f6f0e6;
    --bg-strong: #fffaf2;
    --card: rgba(255, 252, 246, 0.92);
    --text: #22303a;
    --muted: #68747f;
    --line: rgba(34, 48, 58, 0.11);
    --shadow: 0 16px 40px rgba(82, 64, 38, 0.08);
    --primary: #2a4b5f;
    --primary-soft: rgba(42, 75, 95, 0.12);
    --danger: #c6553c;
    --danger-soft: rgba(198, 85, 60, 0.12);
    --success: #2c8b57;
    --success-soft: rgba(44, 139, 87, 0.12);
    --warning: #bf7a1f;
    --warning-soft: rgba(191, 122, 31, 0.14);
    --core: #d95b43;
    --fixed: #2f82c7;
    --sleep: #7d58a5;
    --waste: #8a8f98;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(217, 91, 67, 0.10), transparent 32%),
        radial-gradient(circle at top right, rgba(47, 130, 199, 0.10), transparent 28%),
        linear-gradient(180deg, #fffaf4 0%, var(--bg) 100%);
    color: var(--text);
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

body {
    min-width: 320px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.auth-overlay {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: min(420px, 100%);
    background: rgba(255, 252, 246, 0.96);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    margin: 0 0 10px;
    font-size: 1.6rem;
}

.auth-card p {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.auth-gap {
    margin-top: 14px;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
    background: rgba(255, 250, 242, 0.86);
}

.eyebrow {
    color: var(--warning);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.title-row h1 {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.layout {
    width: min(1280px, calc(100vw - 32px));
    margin: 22px auto 40px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.section-head h2,
.section-head h3 {
    margin: 0;
    font-size: 1.08rem;
}

.section-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.pill,
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill {
    background: rgba(42, 75, 95, 0.08);
    color: var(--primary);
}

.sync-status {
    background: rgba(42, 75, 95, 0.08);
    color: var(--primary);
    cursor: pointer;
}

.sync-status.syncing {
    background: var(--warning-soft);
    color: var(--warning);
}

.sync-status.success {
    background: var(--success-soft);
    color: var(--success);
}

.sync-status.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.sync-status.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.74);
    color: var(--text);
    border-color: var(--line);
}

.btn-soft {
    background: var(--primary-soft);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

.stack-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.readonly-banner,
.feedback {
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid transparent;
    font-size: 0.92rem;
}

.readonly-banner {
    background: var(--warning-soft);
    border-color: rgba(191, 122, 31, 0.2);
    color: var(--warning);
}

.feedback {
    margin-top: 14px;
    background: var(--danger-soft);
    border-color: rgba(198, 85, 60, 0.18);
    color: var(--danger);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-span-2 {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field label {
    font-size: 0.92rem;
    color: var(--muted);
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(34, 48, 58, 0.14);
    background: rgba(255, 255, 255, 0.88);
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(42, 75, 95, 0.46);
    box-shadow: 0 0 0 4px rgba(42, 75, 95, 0.10);
}

.field textarea {
    min-height: 96px;
    resize: vertical;
}

.field-note {
    font-size: 0.84rem;
    color: var(--muted);
}

.radio-panel,
.recall-box,
.duration-bar,
.stats-grid,
.chart-grid {
    border-radius: var(--radius-md);
}

.radio-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: rgba(42, 75, 95, 0.05);
    padding: 12px;
    border: 1px solid var(--line);
}

.radio-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid transparent;
}

.radio-option:hover {
    border-color: rgba(42, 75, 95, 0.14);
}

.radio-option input {
    margin-top: 2px;
}

.duration-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.duration-chip {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    color: var(--primary);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.plan-action {
    margin-top: 18px;
}

.review-gap {
    margin-top: 16px;
}

.modal-gap {
    margin-top: 22px;
}

.prompt-gap {
    margin-top: 18px;
}

.table-shell {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(34, 48, 58, 0.08);
    vertical-align: top;
    text-align: left;
    font-size: 0.92rem;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
}

.table-empty {
    padding: 26px 14px;
    text-align: center;
    color: var(--muted);
}

.task-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
}

.task-title {
    font-weight: 700;
    line-height: 1.4;
    word-break: break-word;
}

.task-meta {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-core {
    background: rgba(217, 91, 67, 0.12);
    color: var(--core);
    border-color: rgba(217, 91, 67, 0.16);
}

.badge-fixed {
    background: rgba(47, 130, 199, 0.12);
    color: var(--fixed);
    border-color: rgba(47, 130, 199, 0.18);
}

.badge-sleep {
    background: rgba(125, 88, 165, 0.12);
    color: var(--sleep);
    border-color: rgba(125, 88, 165, 0.18);
}

.badge-waste {
    background: rgba(138, 143, 152, 0.12);
    color: var(--waste);
    border-color: rgba(138, 143, 152, 0.18);
}

.badge-ok {
    background: var(--success-soft);
    color: var(--success);
}

.badge-fail {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-abort {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-sync {
    background: rgba(191, 122, 31, 0.14);
    color: var(--warning);
}

.delta {
    font-weight: 700;
}

.delta.early {
    color: var(--success);
}

.delta.late {
    color: var(--danger);
}

.recall-box {
    background: rgba(42, 75, 95, 0.06);
    border-left: 4px solid var(--primary);
    padding: 14px 16px;
    line-height: 1.7;
}

.review-block {
    background: rgba(255, 255, 255, 0.70);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
}

.review-block.warning {
    background: rgba(191, 122, 31, 0.07);
    border-color: rgba(191, 122, 31, 0.18);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
}

.stat-card h4 {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.86rem;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-core {
    color: var(--core);
}

.stat-waste {
    color: var(--waste);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.chart-card {
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px;
    min-height: 300px;
}

.focus-overlay,
.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 100;
}

.focus-overlay.is-visible,
.modal.is-visible {
    display: flex;
}

.focus-overlay {
    background:
        radial-gradient(circle at top, rgba(217, 91, 67, 0.14), transparent 34%),
        linear-gradient(180deg, #fffaf4 0%, #fff4df 100%);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.focus-panel {
    width: min(920px, 100%);
    text-align: center;
}

.focus-category {
    color: var(--muted);
    font-size: 1rem;
    margin-bottom: 10px;
}

.focus-task {
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.18;
    font-weight: 800;
    margin: 0;
    word-break: break-word;
}

.timer-display {
    margin: 24px 0 12px;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: clamp(3.8rem, 10vw, 7rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.focus-deadline {
    color: var(--muted);
    font-size: 1rem;
}

.progress-bar {
    width: min(860px, 100%);
    height: 12px;
    background: rgba(34, 48, 58, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin: 28px auto 36px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.8s linear;
}

.modal {
    background: rgba(34, 48, 58, 0.48);
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-card {
    width: min(560px, 100%);
    background: var(--bg-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 20px 46px rgba(34, 48, 58, 0.20);
}

.modal-card h3 {
    margin: 0 0 10px;
    font-size: 1.12rem;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    max-width: min(420px, calc(100vw - 24px));
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 16px 34px rgba(34, 48, 58, 0.18);
    background: rgba(34, 48, 58, 0.92);
    color: #fff;
    font-size: 0.92rem;
    line-height: 1.5;
}

.toast.success {
    background: rgba(44, 139, 87, 0.95);
}

.toast.error {
    background: rgba(198, 85, 60, 0.96);
}

.toast.warning {
    background: rgba(191, 122, 31, 0.95);
}

@media (max-width: 920px) {
    .topbar {
        padding: 16px;
    }

    .layout {
        width: min(100vw - 20px, 100%);
        margin-top: 14px;
    }

    .form-grid,
    .radio-panel,
    .chart-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .topbar,
    .header-actions,
    .section-head {
        align-items: stretch;
    }

    .title-row h1 {
        font-size: 1.34rem;
    }

    .card {
        padding: 18px;
        border-radius: 18px;
    }

    .btn,
    .sync-status,
    .pill {
        width: 100%;
        justify-content: center;
    }

    .header-actions > * {
        width: 100%;
    }

    .duration-bar {
        gap: 8px;
    }

    .duration-chip {
        flex: 1 1 calc(50% - 8px);
        text-align: center;
    }
}
