/* Old Photo Revive — warm paper palette, light and dark. */
:root {
  --bg: #f7f2ea; --surface: #fffdf9; --surface-2: #f1e9dd; --line: #e2d6c4;
  --text: #2a231b; --muted: #6f6253; --accent: #a5652d; --accent-ink: #fff;
  --accent-soft: #f3e3cf; --ok: #3f7a52; --warn: #a2501f; --err: #b3261e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 24px rgba(60, 40, 20, .07);
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120e; --surface: #1e1a15; --surface-2: #27221b; --line: #3a3229;
    --text: #efe6da; --muted: #b0a291; --accent: #d79a5d; --accent-ink: #1b140c;
    --accent-soft: #3a2a1b; --ok: #7fbf8f; --warn: #e3a06b; --err: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15120e; --surface: #1e1a15; --surface-2: #27221b; --line: #3a3229;
  --text: #efe6da; --muted: #b0a291; --accent: #d79a5d; --accent-ink: #1b140c;
  --accent-soft: #3a2a1b; --ok: #7fbf8f; --warn: #e3a06b; --err: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 700; font-size: 17px; white-space: nowrap; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.device { font-size: 12px; color: var(--muted); white-space: nowrap; }
.top-link { font-size: 14px; text-decoration: none; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 16px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 22px 20px 40px; }
.hero h1 { font-size: clamp(24px, 3.4vw, 34px); font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
.lede { color: var(--muted); margin: 8px 0 20px; max-width: 720px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stage-col { min-width: 0; }

.btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 6px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkish { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); min-height: 380px; display: grid; place-items: center; text-align: center; padding: 24px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop svg { color: var(--accent); }
.drop-title { font-size: 19px; font-weight: 600; margin: 8px 0 2px; }
.drop-sub, .fine { color: var(--muted); margin: 0 0 12px; }
.fine { font-size: 12.5px; margin: 14px 0 0; }
.drop-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.viewer-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.viewer-note { color: var(--muted); font-size: 13px; flex: 1; min-width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: var(--surface); color: var(--text); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg-btn:disabled { opacity: .5; cursor: not-allowed; }

.compare { position: relative; border-radius: 10px; overflow: hidden; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 20px 20px; touch-action: none; user-select: none; }
.compare canvas { display: block; width: 100%; height: auto; }
.cmp-after { position: absolute; inset: 0; height: 100% !important; clip-path: inset(0 0 0 50%); }
.handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); pointer-events: none; }
.handle::after { content: "⇆"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #333; display: grid; place-items: center; font-size: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.split { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.tag { position: absolute; top: 10px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; }
.tag-l { left: 10px; } .tag-r { right: 10px; }
.compare.no-after .cmp-after, .compare.no-after .handle, .compare.no-after .tag-r, .compare.no-after .split { display: none; }
.side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side figure { margin: 0; } .side canvas { width: 100%; height: auto; display: block; border-radius: 8px; }
.side figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.stats { font-size: 13px; color: var(--muted); }
.dl { display: flex; gap: 8px; }
.example-note { font-size: 13.5px; background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 10px 0 0; }
.faces-tip { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); position: sticky; top: 70px; }
.panel-title { font-size: 16px; margin-bottom: 8px; }
.steps { list-style: none; margin: 0 0 8px; padding: 0; }
.step { padding: 10px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 2px; }
.step-head { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.step-head input { width: 17px; height: 17px; accent-color: var(--accent); }
.ai { font-style: normal; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: auto; }
.step-sub { margin: 2px 0 6px 25px; font-size: 13px; color: var(--muted); }
.step .seg, .step .slider-row { margin-left: 25px; }
.step.off .step-sub, .step.off .seg, .step.off .slider-row { opacity: .45; }
.slider-row { display: grid; grid-template-columns: 62px 1fr 42px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.slider-row input { accent-color: var(--accent); width: 100%; }
.slider-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.run-hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; text-align: center; }
.status-ok { color: var(--ok); } .status-wait { color: var(--warn); }

.progress { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.progress-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.progress-head span { font-variant-numeric: tabular-nums; color: var(--muted); }
.stages { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
.stages li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; color: var(--muted); }
.stages li::before { content: "○"; width: 16px; flex: none; }
.stages li.active { color: var(--text); font-weight: 600; } .stages li.active::before { content: "◐"; color: var(--accent); }
.stages li.done::before { content: "●"; color: var(--ok); }
.stages li.skip { opacity: .55; } .stages li.skip::before { content: "–"; }
.stages .label { flex: 1; } .stages .t { font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.error { color: var(--err); font-size: 13.5px; margin: 10px 0 0; }

.explain { margin-top: 36px; }
.explain h2 { font-size: 20px; margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card h3 { font-size: 15px; margin-bottom: 6px; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.honest { font-size: 13.5px; color: var(--muted); margin-top: 14px; }
.foot { border-top: 1px solid var(--line); padding: 18px 20px 30px; text-align: center; font-size: 12.5px; color: var(--muted); }
.foot p { max-width: 900px; margin: 4px auto; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 16px; }
  .pill, .device { display: none; }
  .wrap { padding: 16px 16px 32px; }
  .drop { min-height: 300px; }
  .cards { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr; }
  .dl { width: 100%; } .dl .btn { flex: 1; }
}
