:root {
    --bg: #f7f4ee;
    --ink: #1e2724;
    --muted: #65706c;
    --line: #ded7cc;
    --panel: #fffaf2;
    --accent: #2f6f67;
    --accent-2: #9b4d34;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 72px; }
.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 24px;
    padding: 18px max(18px, calc((100vw - 1120px) / 2));
    border-bottom: 1px solid var(--line); background: rgba(247, 244, 238, .92);
}
.brand { font-weight: 800; font-size: 1.1rem; }
nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; color: var(--muted); }
h1 { max-width: 760px; margin: 0; font-size: clamp(2.2rem, 6vw, 5rem); line-height: .95; letter-spacing: 0; }
h2 { margin: 0; font-size: 1.05rem; }
.lead { max-width: 680px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.eyebrow { margin: 0 0 12px; text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; color: var(--accent-2); }
.hero { min-height: 68vh; display: grid; align-items: center; }
.page-head { margin-bottom: 32px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 0 18px; border: 0; border-radius: 6px; background: var(--accent); color: #fff;
    font-weight: 750; cursor: pointer;
}
.button.secondary, .button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.button.small { min-height: 34px; padding: 0 12px; }
.button.google { width: 100%; background: #1e2724; }
.button:disabled { cursor: wait; opacity: .68; }
.auth-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .75fr); gap: 46px; align-items: start; }
.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px;
    box-shadow: 0 20px 55px rgba(30, 39, 36, .08);
}
.form-stack, .upload-form { display: grid; gap: 12px; }
label { font-weight: 750; color: var(--ink); }
input {
    width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 6px;
    background: #fff; padding: 10px 12px; font: inherit;
}
.separator { display: grid; place-items: center; height: 44px; color: var(--muted); }
.demo-box { margin-top: 18px; display: grid; gap: 6px; color: var(--muted); font-size: .95rem; }
.demo-box strong { color: var(--ink); }
.demo-box a { color: var(--accent); font-weight: 800; }
.flash { margin-bottom: 18px; padding: 12px 14px; border-radius: 6px; background: #e7f4ef; color: #235a4f; }
.flash.error { background: #f8e2dc; color: #84341f; }
.flash.notice { background: #fff0c9; color: #694a00; }
.recipe-options { display: grid; gap: 0; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.recipe-options legend { padding: 0 8px; margin-left: 10px; font-weight: 800; }
.option-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start; padding: 16px; background: #fff; cursor: pointer; }
.option-row + .option-row { border-top: 1px solid var(--line); }
.option-row input { width: 18px; min-height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
.option-row span { display: grid; gap: 4px; }
.option-row small { color: var(--muted); font-weight: 500; line-height: 1.45; }
.restoration-progress { display: grid; gap: 14px; margin-top: 18px; }
.restoration-progress[hidden] { display: none; }
.restoration-progress__header { display: flex; align-items: center; gap: 12px; }
.restoration-progress__header::before {
    width: 14px;
    height: 14px;
    border: 2px solid #b9cfca;
    border-top-color: var(--accent);
    border-radius: 50%;
    content: "";
    animation: progress-spin .8s linear infinite;
}
.restoration-progress p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.restoration-progress.is-error { border-color: #c96a50; }
.restoration-progress.is-error .restoration-progress__header::before { animation: none; border-color: #c96a50; }
@keyframes progress-spin { to { transform: rotate(360deg); } }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stats div { padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.stats strong { display: block; font-size: 2rem; }
.stats span { color: var(--muted); }
.photo-grid { display: grid; gap: 22px; }
.photo-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
figure { margin: 0; background: #ebe5da; }
figure img, .placeholder { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: grid; place-items: center; color: var(--muted); }
figcaption { padding: 10px 12px; color: var(--muted); background: var(--panel); font-size: .88rem; }
figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.photo-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; flex-wrap: wrap; }
.saturation-editor {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) 58px minmax(90px, auto);
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.saturation-editor label { font-size: .9rem; }
.saturation-editor input[type="range"] { min-height: 24px; padding: 0; accent-color: var(--accent); cursor: pointer; }
.saturation-editor output { color: var(--accent); font-weight: 800; text-align: right; }
.saturation-editor__status { min-height: 20px; color: var(--muted); font-size: .82rem; text-align: right; }
.photo-summary { display: grid; gap: 8px; }
.recipe-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.recipe-tags span { padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: .76rem; font-weight: 750; }
.missing-content-callout { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border-top: 1px solid #e7c66e; background: #fff5d9; }
.missing-content-callout p { max-width: 700px; margin: 5px 0 0; color: #6c5620; line-height: 1.45; }
.missing-content-callout form { flex: 0 0 auto; }
.status { border-radius: 999px; padding: 6px 10px; font-size: .82rem; font-weight: 800; background: #ece6dc; }
.status.restored { background: #dcefe8; color: #246356; }
.status.failed { background: #f4d9d0; color: #80341f; }
.empty-state { padding: 34px; border: 1px dashed var(--line); border-radius: 8px; text-align: center; }
.text-button {
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    min-height: 32px;
    padding: 0 10px;
}
.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}
.photo-dialog {
    width: min(960px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 24px 90px rgba(30, 39, 36, .35);
}
.photo-dialog::backdrop { background: rgba(30, 39, 36, .62); }
.photo-dialog__bar,
.photo-dialog__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
}
.photo-dialog__bar { border-bottom: 1px solid var(--line); }
.photo-dialog__actions { border-top: 1px solid var(--line); }
.photo-dialog img {
    display: block;
    width: 100%;
    max-height: calc(100vh - 190px);
    object-fit: contain;
    background: #ebe5da;
}
.api-access-layout { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(0, 1.3fr); gap: 22px; align-items: start; }
.credential-reveal { margin-bottom: 22px; border-color: var(--accent); }
.credential-reveal label { display: block; margin: 18px 0 7px; }
.credential-value { overflow-x: auto; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.credential-value code { white-space: nowrap; }
.token-list { display: grid; gap: 10px; }
.token-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.token-row div { display: grid; gap: 4px; }
.token-row span, .token-row small { color: var(--muted); }
.api-guide { margin-top: 22px; }
.api-guide ol { padding-left: 22px; color: var(--muted); line-height: 1.65; }
.api-guide code { overflow-wrap: anywhere; }

@media (max-width: 760px) {
    .auth-layout, .stats, .comparison, .api-access-layout { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .photo-dialog__bar, .photo-dialog__actions { padding: 12px; }
    .missing-content-callout { align-items: stretch; flex-direction: column; }
    .missing-content-callout .button { width: 100%; }
    .saturation-editor { grid-template-columns: auto 58px; }
    .saturation-editor input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
    .saturation-editor__status { grid-column: 1 / -1; text-align: left; }
    .token-row { align-items: stretch; flex-direction: column; }
}
