:root {
    color-scheme: light;
    --ink: #1e2a25;
    --muted: #66716b;
    --paper: #fffdf8;
    --canvas: #f3f0e8;
    --line: #dcd8cd;
    --accent: #166b50;
    --accent-dark: #0d523c;
    --recording: #bd3e35;
    --error: #a6302a;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100svh;
    color: var(--ink);
    background:
        radial-gradient(circle at 100% 0, rgba(22, 107, 80, .1), transparent 35%),
        var(--canvas);
}

button, textarea, input { font: inherit; }
a { color: var(--accent); }

.app-shell {
    min-height: 100svh;
    display: grid;
    align-items: center;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
}
.app-shell--top { align-items: start; }

.card {
    width: min(100%, 620px);
    margin: auto;
    padding: 28px 20px 24px;
    background: var(--paper);
    border: 1px solid rgba(30, 42, 37, .08);
    border-radius: 24px;
    box-shadow: 0 18px 55px rgba(49, 54, 45, .1);
}

.landing { overflow: hidden; }
.landing-logo { width: 210px; height: auto; display: block; margin: 0 0 22px; }
.feature-list { margin: 30px 0; border-block: 1px solid var(--line); }
.feature-list p { display: flex; gap: 14px; margin: 0; padding: 15px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.feature-list p:last-child { border-bottom: 0; }
.feature-list span { color: var(--accent); font-size: .78rem; letter-spacing: .08em; }
.action-stack { display: grid; gap: 11px; }

.button {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
}
.button--primary { color: #fff; background: var(--accent); }
.button--primary:hover { background: var(--accent-dark); }
.button--secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.button--danger { color: var(--error); background: transparent; border-color: rgba(166, 48, 42, .35); }
.button:disabled { cursor: wait; opacity: .6; }

.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: -8px 0 28px; color: var(--muted); font-size: .9rem; }
.topbar form { margin: 0; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.topbar__actions a { font-weight: 700; text-decoration: none; }
.text-button { padding: 6px; border: 0; color: var(--accent); background: transparent; cursor: pointer; font-weight: 700; }

.app-nav { position: relative; z-index: 10; display: flex; justify-content: space-between; align-items: center; margin: -10px 0 28px; }
.app-logo { width: 54px; height: 54px; display: block; overflow: hidden; border-radius: 15px; box-shadow: 0 4px 13px rgba(30, 42, 37, .15); }
.app-logo img { width: 100%; height: 100%; display: block; object-fit: cover; }
.app-logo:focus-visible, .menu-toggle:focus-visible { outline: 3px solid rgba(22, 107, 80, .3); outline-offset: 3px; }
.app-menu { position: relative; }
.menu-toggle { width: 48px; height: 48px; display: grid; align-content: center; justify-items: center; gap: 5px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: #fff; box-shadow: 0 3px 11px rgba(30, 42, 37, .08); cursor: pointer; }
.menu-toggle span { width: 20px; height: 2px; display: block; border-radius: 999px; background: currentColor; transition: transform .18s ease, opacity .18s ease; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.menu-panel { position: absolute; top: calc(100% + 9px); right: 0; width: min(250px, calc(100vw - 64px)); padding: 8px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 16px 36px rgba(30, 42, 37, .17); }
.menu-panel[hidden] { display: none; }
.menu-panel a, .menu-panel button { width: 100%; min-height: 45px; display: flex; align-items: center; padding: 10px 13px; border: 0; border-radius: 9px; color: var(--ink); background: transparent; cursor: pointer; font: inherit; font-weight: 700; text-align: left; text-decoration: none; }
.menu-panel a:hover, .menu-panel button:hover { color: var(--accent); background: #f3f0e8; }
.menu-panel a[aria-current="page"] { color: var(--accent); background: rgba(22, 107, 80, .08); }
.menu-panel form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--line); }
.menu-panel form button { color: var(--error); }

.legal-footer { width: min(100%, 820px); display: flex; justify-content: center; gap: 20px; margin: 18px auto 0; color: var(--muted); font-size: .82rem; }
.legal-footer a { color: inherit; text-decoration: none; }
.legal-footer a:hover, .legal-footer a[aria-current="page"] { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.legal-card { width: min(100%, 820px); }
.legal-card h1 { max-width: none; }
.legal-updated { margin: 12px 0 0; color: var(--muted); font-size: .86rem; }
.legal-copy { display: grid; gap: 28px; margin-top: 34px; }
.legal-copy section { padding-top: 24px; border-top: 1px solid var(--line); }
.legal-copy h2 { margin: 0 0 12px; font-size: 1.2rem; line-height: 1.3; }
.legal-copy p { margin: 0 0 12px; line-height: 1.7; }
.legal-copy p:last-child { margin-bottom: 0; }
.legal-copy address { font-style: normal; line-height: 1.7; }

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: .76rem;
    font-weight: 750;
    letter-spacing: .09em;
    text-transform: uppercase;
}

h1 {
    max-width: 14em;
    margin: 0;
    font-size: clamp(1.8rem, 8vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: -.035em;
}

.intro {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.recorder {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
    padding: 24px 14px 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #faf8f2;
}

.status {
    min-height: 1.5em;
    margin: 0 0 16px;
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.status[data-state="recording"], .status[data-state="error"] { color: var(--error); }
.status[data-state="success"] { color: var(--accent); }

.record-button {
    min-width: 210px;
    min-height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 14px 21px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 7px 18px rgba(22, 107, 80, .23);
    cursor: pointer;
    font-weight: 750;
    touch-action: manipulation;
    transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.record-button:hover { background: var(--accent-dark); }
.record-button:active { transform: scale(.98); }
.record-button:focus-visible { outline: 3px solid rgba(22, 107, 80, .3); outline-offset: 3px; }
.record-button:disabled { cursor: wait; opacity: .6; }
.record-button.is-recording { background: var(--recording); animation: pulse 1.7s ease-in-out infinite; }
.record-button__icon { width: 20px; height: 20px; display: inline-grid; place-items: center; flex: 0 0 auto; line-height: 1; }
.record-button__mic { display: block; }
.record-button__stop { display: none; width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.record-button.is-recording .record-button__mic { display: none; }
.record-button.is-recording .record-button__stop { display: block; }

.hint {
    max-width: 340px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.45;
    text-align: center;
}

.report label {
    display: block;
    margin-bottom: 9px;
    font-weight: 750;
}
.report textarea { min-height: clamp(163px, 22.5svh, 244px); }

textarea {
    display: block;
    width: 100%;
    min-height: clamp(250px, 36svh, 390px);
    resize: vertical;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    background: #fff;
    line-height: 1.55;
}

.report > label:not(:first-child) { margin-top: 18px; }
.date-input {
    display: block; width: 100%; min-height: 50px; padding: 11px 14px;
    border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff;
}
.date-input:focus { border-color: var(--accent); outline: 3px solid rgba(22, 107, 80, .12); }

textarea::placeholder { color: #929991; }
textarea:focus { border-color: var(--accent); outline: 3px solid rgba(22, 107, 80, .12); }
.save-button { width: 100%; margin-top: 14px; }
noscript { display: block; margin-top: 16px; color: var(--error); }

.auth-card { max-width: 500px; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--muted); text-decoration: none; }
.back-link--compact { margin-bottom: 0; }
.auth-form { display: grid; margin-top: 28px; }
.auth-form label { margin: 15px 0 7px; font-weight: 750; }
.auth-form input {
    width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 12px; color: var(--ink); background: #fff;
}
.auth-form input:focus { border-color: var(--accent); outline: 3px solid rgba(22, 107, 80, .12); }
.auth-form .button { margin-top: 24px; }
.field-hint { margin: 5px 0 -8px; color: var(--muted); font-size: .8rem; }
.form-message { margin: 20px 0 0; padding: 12px 14px; border-radius: 10px; }
.form-message--error { color: var(--error); background: rgba(166, 48, 42, .08); }
.form-message--success { color: var(--accent); background: rgba(22, 107, 80, .08); }
.auth-switch { margin: 22px 0 0; color: var(--muted); text-align: center; }

.reports-card { width: min(100%, 760px); }
.reports-header { margin-bottom: 28px; }
.week-toolbar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 10px; margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #fff; text-align: center; }
.week-toolbar div { display: grid; gap: 3px; }
.week-toolbar strong { font-size: 1.06rem; }
.week-toolbar span { color: var(--muted); font-size: .82rem; }
.week-arrow { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--accent); background: #f2f0e9; font-size: 1.25rem; font-weight: 800; text-decoration: none; }
.week-arrow:hover { background: #e8e5db; }
.week-picker { position: relative; z-index: 5; margin-bottom: 14px; }
.week-picker summary { min-height: 68px; display: grid; grid-template-columns: minmax(0, 1fr) auto 22px; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; list-style: none; }
.week-picker summary::-webkit-details-marker { display: none; }
.week-picker summary:focus-visible { outline: 3px solid rgba(22, 107, 80, .2); outline-offset: 3px; }
.week-picker[open] summary { border-radius: 15px 15px 8px 8px; }
.week-picker__label { min-width: 0; display: grid; gap: 3px; }
.week-picker__label strong { font-size: 1rem; }
.week-picker__label small { overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.week-picker__count { color: var(--muted); font-size: .8rem; font-weight: 700; text-align: right; white-space: nowrap; }
.week-picker__chevron { width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent); transition: transform .16s ease; }
.week-picker__chevron svg { display: block; }
.week-picker[open] .week-picker__chevron { transform: rotate(180deg); }
.week-picker__options { position: absolute; top: calc(100% + 6px); right: 0; left: 0; max-height: min(430px, 58svh); overflow-y: auto; padding: 7px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 16px 36px rgba(30, 42, 37, .16); }
.week-picker__options a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; }
.week-picker__options a:hover { background: #f3f0e8; }
.week-picker__options a[aria-current="page"] { color: var(--accent); background: rgba(22, 107, 80, .08); }
.help-card { width: min(100%, 820px); }
.help-header { margin-bottom: 24px; }
.help-picker { margin-bottom: 30px; }
.help-picker summary { grid-template-columns: minmax(0, 1fr) 22px; }
.help-picker .week-picker__options a { grid-template-columns: minmax(0, 1fr); }
.help-article { padding-top: 30px; border-top: 1px solid var(--line); }
.help-article > header h2 { margin: 0; font-size: clamp(1.45rem, 5vw, 2rem); line-height: 1.2; letter-spacing: -.025em; }
.help-article > header > p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.help-steps { display: grid; gap: 16px; margin: 28px 0 0; padding: 0; list-style: none; counter-reset: none; }
.help-steps > li { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.help-step-number { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font-weight: 800; }
.help-steps h3 { margin: 6px 0 8px; font-size: 1.05rem; }
.help-steps p { margin: 0; color: var(--muted); line-height: 1.65; }
.help-placeholders { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.help-placeholders li { display: grid; gap: 3px; padding: 10px 12px; border-radius: 9px; background: #f3f0e8; }
.help-placeholders code { width: fit-content; color: var(--accent-dark); font-weight: 800; }
.help-placeholders span { color: var(--muted); font-size: .82rem; }
.help-note { margin-top: 24px; padding: 13px 14px; border-left: 4px solid #d59a24; border-radius: 8px; color: #60470f; background: #fff6d9; font-size: .88rem; line-height: 1.55; }
.help-note code { overflow-wrap: anywhere; }
.help-pro-tip { margin-top: 12px; padding: 13px 14px; border-left: 4px solid var(--accent); border-radius: 8px; color: var(--accent-dark); background: rgba(22, 107, 80, .08); font-size: .88rem; line-height: 1.55; }
.help-finished { margin-top: 22px; padding: 22px; border-radius: 15px; color: var(--ink); background: rgba(22, 107, 80, .08); }
.help-finished > strong { font-size: 1.1rem; }
.help-finished p { margin: 7px 0 16px; color: var(--muted); line-height: 1.6; }
.help-finished .button { width: 100%; }
.week-actions { margin-bottom: 26px; }
.week-actions form { margin: 0; }
.week-actions .button { width: 100%; }
.version-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 22px 0; padding: 5px; border-radius: 14px; background: #eeece5; }
.version-tab { padding: 11px 14px; border-radius: 10px; color: var(--muted); font-weight: 750; text-align: center; text-decoration: none; }
.version-tab.is-active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(49, 54, 45, .08); }
.version-tab.is-disabled { opacity: .48; }
.reports-list { display: grid; gap: 14px; }
.report-day { margin: 18px 0 0; font-size: 1.08rem; letter-spacing: -.01em; }
.report-day:first-child { margin-top: 0; }
.report-item { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.report-item__header { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.report-link { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; color: var(--ink); line-height: 1.6; text-decoration: none; }
.report-link:hover { color: var(--accent); }
.report-link:focus-visible { border-radius: 6px; outline: 3px solid rgba(22, 107, 80, .2); outline-offset: 4px; }
.report-link__arrow { flex: 0 0 auto; color: var(--accent); font-size: 1.25rem; }
.report-detail-card { width: min(100%, 760px); }
.detail-back-link { margin-bottom: 24px; }
.report-detail-header { margin-bottom: 28px; }
.report-full-text { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; overflow-wrap: anywhere; line-height: 1.75; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.detail-actions .button { flex: 1 1 190px; }
.delete-report-form { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.delete-report-form .button { width: 100%; }
.edit-report-form > label { display: block; margin-bottom: 9px; font-weight: 750; }
.edit-report-form textarea { min-height: clamp(280px, 48svh, 520px); }
.not-found > p { margin: 14px 0 22px; color: var(--muted); }
.empty-state { padding: 34px 18px; border: 1px dashed var(--line); border-radius: 15px; text-align: center; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.ai-edit-form { display: grid; }
.ai-edit-form label { margin-bottom: 9px; font-weight: 750; }
.ai-edit-form textarea { min-height: clamp(360px, 55svh, 650px); }
.ai-edit-form .button { margin-top: 14px; }
.ai-meta { margin: 9px 0 0; color: var(--muted); font-size: .8rem; }
.ai-actions, .export-panel { margin-top: 30px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #faf8f2; }
.ai-actions h2, .export-panel h2 { margin: 0; font-size: 1.15rem; }
.ai-actions p { margin: 9px 0 16px; color: var(--muted); line-height: 1.5; }
.ai-actions form, .export-panel form { margin: 0; }
.ai-actions .button, .export-panel > .button, .export-panel form > .button { width: 100%; }
.export-options { display: grid; gap: 10px; margin: 16px 0; padding: 0; border: 0; }
.export-options legend { margin-bottom: 10px; font-weight: 750; }
.export-options label { display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.export-options label.is-disabled { cursor: not-allowed; opacity: .5; }
.export-options input { accent-color: var(--accent); }
.export-panel .field-hint { margin: 12px 0 16px; line-height: 1.45; }

.settings-card { width: min(100%, 820px); }
.settings-header { margin-bottom: 30px; }
.settings-section { padding-top: 28px; border-top: 1px solid var(--line); }
.settings-section + .settings-section { margin-top: 34px; }
.settings-section h2 { margin: 0; font-size: 1.35rem; }
.settings-section h3 { margin: 0 0 12px; font-size: 1rem; }
.section-description { margin: 10px 0 14px; color: var(--muted); line-height: 1.55; }
.settings-form { display: grid; margin-top: 18px; }
.settings-form label { margin: 14px 0 7px; font-weight: 750; }
.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input:not([type]) {
    width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 12px; color: var(--ink); background: #fff;
}
.settings-form input:disabled { color: var(--muted); background: #f1efe9; }
.settings-form input[type="file"] { width: 100%; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; }
.settings-form .prompt-textarea { min-height: 190px; }
.settings-form .button { margin-top: 22px; }
.placeholder-list, .check-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.placeholder-list code, .check-list code { padding: 3px 6px; border-radius: 5px; background: #eeece5; font-size: .86rem; }
.check-list span { color: var(--accent); font-weight: 800; }
.template-summary, .template-check, .template-preview { margin-top: 28px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.template-summary p { margin: 0; color: var(--muted); line-height: 1.6; }
.template-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.template-actions form { display: contents; }
.template-actions .button { flex: 1 1 190px; }
.form-message--warning { color: #76540c; background: #fff6d9; }
.preview-frame { max-height: 520px; margin-top: 14px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.preview-frame table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.preview-frame td { min-width: 100px; padding: 10px; border: 1px solid var(--line); vertical-align: top; white-space: pre-wrap; }
.preview-text { padding: 16px; white-space: normal; line-height: 1.6; }

@keyframes pulse {
    50% { box-shadow: 0 0 0 10px rgba(189, 62, 53, .12); }
}

@media (min-width: 600px) {
    .app-shell { padding: 36px; }
    .card { padding: 42px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
