:root {
    --bg: #f6f3ed;
    --ink: #19231f;
    --muted: #69716b;
    --line: #ded8cd;
    --panel: #fffdf8;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --accent: #c2410c;
    --soft: #e4f2ee;
    --danger: #b42318;
    --success: #1f7a4c;
    --shadow: 0 16px 40px rgba(25, 35, 31, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 12px 13px;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

h1,
h2,
p {
    margin-top: 0;
}

.install-body,
.login-shell {
    display: grid;
    place-items: center;
    padding: 24px;
}

.install-shell {
    width: min(720px, 100%);
}

.install-card,
.login-card,
.study-card,
.ai-output {
    background: var(--panel);
    border: 1px solid rgba(222, 216, 205, .8);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.install-card h1,
.login-card h1 {
    margin-bottom: 8px;
}

.install-card p,
.login-card p,
.page-heading p {
    color: var(--muted);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid h2 {
    margin: 18px 0 0;
    font-size: 18px;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.primary-button,
.inline-actions button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.primary-button {
    min-height: 48px;
    background: var(--primary);
    color: #fff;
    padding: 0 18px;
}

.primary-button.is-loading {
    position: relative;
    opacity: .88;
    cursor: wait;
}

.primary-button.is-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    display: inline-block;
    margin-right: 8px;
    vertical-align: -3px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}

.primary-button:active {
    background: var(--primary-dark);
}

.loading-note {
    display: none;
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.loading-note.show {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.alert.success {
    background: #e9f7ef;
    color: var(--success);
    border-color: #bae6c9;
}

.alert.error {
    background: #fff0ee;
    color: var(--danger);
    border-color: #f4b9b2;
}

.alert.warning {
    background: #fff7e6;
    color: #8a4b00;
    border-color: #f2d49a;
}

.muted {
    color: var(--muted);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 10px 16px;
    background: rgba(246, 243, 237, .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.app-brand span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.logout-link {
    color: var(--muted);
    font-size: 14px;
}

.app-shell {
    width: min(780px, 100%);
    margin: 0 auto;
    padding: 16px 14px 92px;
}

.hero-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 22px;
    border-radius: 8px;
    background: #123b37;
    color: #fff;
    margin-bottom: 16px;
}

.today-hero {
    position: relative;
    overflow: hidden;
    min-height: 206px;
    align-items: end;
    background:
        linear-gradient(135deg, rgba(18, 59, 55, .96), rgba(7, 34, 31, .92)),
        linear-gradient(45deg, #0f766e, #c2410c);
}

.today-hero::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    right: -72px;
    top: -72px;
    border: 28px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
}

.hero-copy {
    position: relative;
    z-index: 1;
}

.hero-panel h1 {
    margin-bottom: 8px;
    font-size: clamp(26px, 7vw, 42px);
    line-height: 1.02;
}

.hero-panel p {
    color: rgba(255, 255, 255, .78);
    margin-bottom: 0;
}

.eyebrow {
    display: block;
    color: #a8e6d7;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.progress-ring {
    width: 78px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at center, #123b37 57%, transparent 58%),
        conic-gradient(#56d3bd calc(var(--progress) * 1%), rgba(255,255,255,.22) 0);
}

.progress-ring.large {
    position: relative;
    z-index: 1;
    width: 96px;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at center, #123b37 55%, transparent 56%),
        conic-gradient(#f6c667 calc(var(--progress) * 1%), rgba(255,255,255,.22) 0);
}

.progress-ring span {
    font-weight: 800;
}

.progress-ring small {
    margin-top: 0;
    color: rgba(255, 255, 255, .72);
    font-size: 11px;
    font-weight: 800;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 18px;
}

.hero-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    background: #f6c667;
    color: #16231f;
    font-weight: 800;
    font-size: 14px;
}

.hero-button.ghost {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .24);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.metric-card {
    display: grid;
    gap: 4px;
    min-height: 102px;
    padding: 14px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 10px 26px rgba(25, 35, 31, .05);
}

.metric-card span,
.metric-card small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    font-size: 28px;
    line-height: 1;
}

.focus-card {
    background: #fffdf8;
    border: 1px solid rgba(15, 118, 110, .24);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}

.time-plan,
.mission-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.time-plan article,
.mission-list article {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 4px 12px;
    padding: 13px;
    border-radius: 8px;
    background: #f7fbf8;
    border: 1px solid #dbece7;
}

.mission-list article {
    grid-template-columns: 42px 1fr;
    background: #fffaf0;
    border-color: #f1dec0;
}

.time-plan article span,
.mission-list article span {
    grid-row: span 2;
    align-self: start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.mission-list article span {
    min-height: 42px;
    border-radius: 50%;
    background: #f6c667;
    color: #3b2a10;
    font-size: 18px;
}

.time-plan article strong,
.mission-list article strong {
    font-size: 15px;
}

.mission-list article strong {
    font-size: 17px;
}

.time-plan article p,
.mission-list article p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.mission-list article small {
    display: block;
    margin-top: 7px;
    color: #7a5a2a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.today-check {
    margin-bottom: 14px;
}

.section-title,
.day-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.section-title h2,
.day-card h2,
.error-card h2,
.ai-output h2 {
    font-size: 18px;
    margin-bottom: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

.task-block {
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.task-block:first-of-type {
    margin-top: 14px;
}

.task-block p {
    color: var(--muted);
    margin: 6px 0 0;
}

.checklist {
    display: grid;
    gap: 12px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    color: var(--ink);
    background: #f9f6ef;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
}

.check-row input {
    width: 20px;
    height: 20px;
}

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0;
}

.quick-card,
.day-card,
.error-card,
.mini-item {
    display: grid;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.quick-card.accent {
    border-color: rgba(194, 65, 12, .34);
    background: #fff7ed;
}

.quick-card span,
.mini-item span,
.day-meta,
.day-card p,
.error-card p {
    color: var(--muted);
    font-size: 14px;
}

.review-card .mini-item {
    margin-top: 10px;
}

.text-link {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
}

.empty-state.compact {
    padding: 10px 0 0;
    text-align: left;
}

.page-heading {
    padding: 10px 2px 4px;
}

.page-heading h1 {
    margin-bottom: 6px;
    font-size: 30px;
}

.timeline,
.error-list {
    display: grid;
    gap: 10px;
}

.day-card {
    grid-template-columns: 44px 1fr;
}

.day-card.today {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, .12);
}

.day-number {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--soft);
    color: var(--primary-dark);
    font-weight: 800;
}

.inline-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.inline-actions button {
    min-height: 38px;
    padding: 0 12px;
    background: var(--soft);
    color: var(--primary-dark);
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 20px;
}

.ai-output {
    margin-top: 14px;
}

.ai-output pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 14px 0 0;
    font-family: inherit;
    line-height: 1.5;
}

.quiz-history {
    margin-top: 14px;
}

.quiz-mini {
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-top: 10px;
}

.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
}

.quiz-card {
    display: grid;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.quiz-card.correct {
    border-color: #8dd6aa;
    background: #f3fbf6;
}

.quiz-card.wrong {
    border-color: #f0b2a9;
    background: #fff7f5;
}

.quiz-card.complete {
    background: #f7fbf8;
    border-color: #b9ddd3;
}

.quiz-card h2 {
    margin-bottom: 0;
    font-size: 22px;
}

.quiz-card p {
    margin-bottom: 0;
    line-height: 1.55;
}

.eyebrow-dark {
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.quiz-form {
    display: grid;
    gap: 10px;
}

.option-row {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    min-height: 54px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

.option-row input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.option-row span {
    line-height: 1.45;
}

.answer-result,
.explanation-box {
    display: grid;
    gap: 5px;
    padding: 13px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}

.answer-result.right {
    border-color: #9bd7b2;
    background: #f1fbf5;
}

.answer-result span,
.explanation-box p,
.explanation-box small {
    color: var(--muted);
}

.explanation-box small {
    font-weight: 800;
}

.primary-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.progress-bar {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7df;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.hero-actions.normal {
    margin-top: 4px;
}

.ghost-light {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--primary-dark);
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: rgba(255, 253, 248, .96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.bottom-nav a {
    display: grid;
    place-items: center;
    gap: 4px;
    min-height: 52px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.bottom-nav a.active {
    color: var(--primary-dark);
    background: var(--soft);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: block;
    background: currentColor;
    mask-size: contain;
    mask-position: center;
    mask-repeat: no-repeat;
}

.nav-icon.home {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 10.8 12 3l9 7.8V21h-6v-6H9v6H3z'/%3E%3C/svg%3E");
}

.nav-icon.calendar {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 2h2v3h6V2h2v3h4v17H3V5h4zm12 8H5v10h14z'/%3E%3C/svg%3E");
}

.nav-icon.target {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 10 10h-2a8 8 0 1 1-8-8zm0 4a6 6 0 1 0 6 6h-2a4 4 0 1 1-4-4zm0 4a2 2 0 1 0 2 2h-2z'/%3E%3C/svg%3E");
}

.nav-icon.spark {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2 2.2 6.3L21 10l-6.8 1.7L12 18l-2.2-6.3L3 10l6.8-1.7zm7 12 1 3 3 1-3 1-1 3-1-3-3-1 3-1zM5 14l.8 2.2L8 17l-2.2.8L5 20l-.8-2.2L2 17l2.2-.8z'/%3E%3C/svg%3E");
}

.nav-icon.settings {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.4 13.5a7.8 7.8 0 0 0 0-3l2-1.5-2-3.4-2.4 1a7.6 7.6 0 0 0-2.6-1.5L14 2.5h-4l-.4 2.6A7.6 7.6 0 0 0 7 6.6l-2.4-1-2 3.4 2 1.5a7.8 7.8 0 0 0 0 3l-2 1.5 2 3.4 2.4-1a7.6 7.6 0 0 0 2.6 1.5l.4 2.6h4l.4-2.6a7.6 7.6 0 0 0 2.6-1.5l2.4 1 2-3.4zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z'/%3E%3C/svg%3E");
}

.settings-hint {
    color: var(--muted);
    margin: 12px 0 16px;
    font-size: 14px;
    line-height: 1.45;
}

.admin-check {
    display: flex;
}

.settings-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.settings-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 8px;
    background: #f9f6ef;
    border: 1px solid var(--line);
}

.settings-list span {
    color: var(--muted);
    font-size: 14px;
}

.settings-list strong {
    text-align: right;
}

@media (max-width: 560px) {
    .two-cols,
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .metric-card {
        min-height: 92px;
        padding: 11px;
    }

    .metric-card strong {
        font-size: 24px;
    }

    .hero-panel {
        padding: 18px;
    }

    .today-hero {
        grid-template-columns: 1fr;
    }

    .progress-ring {
        width: 68px;
    }

    .progress-ring.large {
        position: absolute;
        right: 18px;
        top: 18px;
        width: 72px;
        opacity: .96;
    }

    .hero-copy {
        padding-top: 58px;
    }

    .time-plan article {
        grid-template-columns: 72px 1fr;
        padding: 12px;
    }

    .mission-list article {
        grid-template-columns: 38px 1fr;
        padding: 12px;
    }

    .mission-list article span {
        min-height: 38px;
        font-size: 16px;
    }
}
