/* Face Restore — the reference diagram as a layout: stage strip → (input photo → glowing enhancement panel → stats card)
 * → "Input → Detect → Enhance → Output" caption → controls + HD result. Dark navy, blue/purple gradients, cyan accents. */
:root {
  --bg: #0a0d1c; --bg-2: #10142a; --card: #151a33; --card-2: #1b2140; --line: #273056; --line-2: #34407a; --text: #e9ecfa; --muted: #9ba4cc; --faint: #66709b;
  --accent: #5b6cff; --accent-2: #9b7bff; --accent-soft: rgba(91,108,255,.18); --ok: #37d399; --warn: #ffb547; --err: #ff6b7a; --cyan: #4fd1ff;
  --grad: linear-gradient(135deg, #5b6cff, #9b7bff 55%, #4fd1ff); --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: radial-gradient(1200px 600px at 50% -10%, #1a2150 0%, var(--bg) 60%) fixed, var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--cyan); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* top bar */
.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: rgba(16,20,42,.85); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: #c9cffb; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.top-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.top-link:hover { color: var(--text); }
.lang-select, .select { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 13px; }
.device-badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.device-badge.is-gpu { color: var(--ok); border-color: rgba(55,211,153,.4); }

.diagram { flex: 1 0 auto; max-width: 1280px; width: 100%; margin: 0 auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; }

/* Row 1: stage strip (dark rounded labels joined by gradient arrows, each pointing down to the row beneath) */
.pipeline { display: grid; grid-template-columns: 1fr 28px 1fr 28px 1fr 28px 1fr 28px 1fr; align-items: center; gap: 0; padding-bottom: 18px; }
.stage { position: relative; background: linear-gradient(180deg, #232a50, #171c38); border: 1px solid var(--line-2); border-radius: 12px; padding: 9px 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); transition: border-color .2s, box-shadow .2s; }
.stage-name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.stage-sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 15px; }
.stage::after { content: ""; position: absolute; left: 50%; bottom: -16px; width: 0; height: 0; transform: translateX(-50%); border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 9px solid var(--accent-2); filter: drop-shadow(0 0 4px rgba(155,123,255,.7)); }
.stage.is-active { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-soft), 0 0 22px rgba(91,108,255,.45); }
.stage.is-active .stage-name { color: #fff; }
.stage.is-active::after { animation: nudge 1.1s ease-in-out infinite; border-top-color: var(--cyan); }
.stage.is-done { border-color: rgba(79,209,255,.55); }
.stage.is-done::after { border-top-color: var(--cyan); }
.stage.is-done .stage-sub { color: var(--cyan); }
.stage.is-skipped { opacity: .55; }
.stage-arrow { height: 2px; background: linear-gradient(90deg, var(--accent), var(--cyan)); position: relative; margin: 0 2px; }
.stage-arrow::after { content: ""; position: absolute; right: -1px; top: -5px; border-left: 8px solid var(--cyan); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 4px); } }

/* Row 2: input → panel → stats */
.visual { display: grid; grid-template-columns: minmax(200px, 1fr) 36px minmax(0, 3fr) 36px minmax(210px, 1fr); align-items: stretch; gap: 0; }
.v-arrow { align-self: center; height: 2px; background: linear-gradient(90deg, var(--accent), var(--cyan)); position: relative; margin: 0 6px; }
.v-arrow::after { content: ""; position: absolute; right: -1px; top: -6px; border-left: 10px solid var(--cyan); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.v-input { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.v-frame { flex: 1; min-height: 300px; border-radius: 12px; overflow: hidden; background: #000 repeating-conic-gradient(#141833 0 25%, #0e1128 0 50%) 0 0 / 18px 18px; border: 1px solid var(--line-2); display: grid; place-items: center; position: relative; }
.v-cap, .tile figcaption { text-align: center; font-size: 13px; color: var(--text); font-weight: 600; }
.input-view { width: 100%; height: 100%; display: grid; place-items: center; }
.input-view canvas { max-width: 100%; max-height: 100%; object-fit: contain; display: block; image-rendering: auto; }
.drop-zone { width: 100%; height: 100%; display: grid; place-items: center; padding: 16px; text-align: center; transition: background .15s; }
.drop-zone.is-over { background: var(--accent-soft); }
.drop-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.drop-sub { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.demo-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.demo-thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; font-size: 11px; color: var(--muted); }
.demo-thumb img { border-radius: 6px; display: block; width: 96px; height: 64px; object-fit: cover; }
.demo-thumb:hover { border-color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--cyan); text-decoration: underline; font-size: 12.5px; padding: 4px; }

.v-panel { position: relative; border-radius: 16px; padding: 12px 14px 14px; background: linear-gradient(180deg, rgba(30,37,80,.9), rgba(17,21,44,.95)); border: 1px solid rgba(79,209,255,.55); box-shadow: 0 0 0 1px rgba(91,108,255,.25), 0 0 34px rgba(79,209,255,.22), inset 0 0 40px rgba(91,108,255,.08); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.v-panel-head { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.v-panel-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.faces-count { font-size: 12px; color: var(--cyan); }
.face-tabs { margin-left: auto; display: flex; gap: 4px; }
.face-tab { border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.face-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; position: relative; }
.tile canvas { width: 100%; aspect-ratio: 1; height: auto; border-radius: 10px; background: #0b0e1e; border: 1px solid var(--line-2); display: block; }
.tile-empty { position: absolute; inset: 0 0 26px 0; display: grid; place-items: center; font-size: 12px; color: var(--faint); pointer-events: none; }
.v-panel:not(.is-empty) .tile-empty { display: none; }
.v-panel.is-empty .tile canvas { border-style: dashed; }
.tile[data-tile="marks"] canvas { box-shadow: 0 0 0 1px rgba(79,209,255,.35); }
.bracket { height: 12px; margin: 2px 8px 0; border: 2px solid var(--line-2); border-top: 0; border-radius: 0 0 10px 10px; position: relative; }
.bracket::after { content: ""; position: absolute; left: 50%; bottom: -10px; width: 2px; height: 10px; background: var(--line-2); transform: translateX(-50%); }

.v-stats { border-radius: 16px; padding: 14px 16px; background: linear-gradient(180deg, #1c2246, #12162e); border: 1px solid var(--line-2); box-shadow: var(--shadow); display: flex; align-items: center; min-width: 0; }
.kv { margin: 0; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.kv div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.kv dt { color: var(--text); font-size: 14px; white-space: nowrap; }
.kv dd { margin: 0; font-weight: 700; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.c-cyan { color: var(--cyan); } .c-ok { color: var(--ok); } .c-muted { color: var(--muted); font-weight: 500; }
.kv dd small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); }

.flow-caption { margin: 2px 0 6px; text-align: center; font-size: 18px; font-weight: 800; letter-spacing: 1px; display: flex; justify-content: center; gap: 12px; }
.flow-arrow { color: var(--cyan); }

/* Row 3: controls + HD result */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.result { display: flex; flex-direction: column; overflow: hidden; }
.stage-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.field { display: flex; align-items: center; gap: 8px; }
.field-label { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn { border: 0; background: transparent; border-radius: 8px; padding: 5px 10px; font-size: 13px; color: var(--muted); }
.seg-btn.is-active { background: var(--accent); color: #fff; }
.seg-btn.is-unavailable { text-decoration: line-through; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.primary-btn { border: 0; border-radius: 10px; padding: 8px 18px; font-weight: 700; font-size: 14px; background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(91,108,255,.35); }
.primary-btn:disabled { box-shadow: none; }
.pill-btn { border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--text); }
.pill-btn:hover:not(:disabled) { border-color: var(--accent); }
.pill-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress { position: relative; height: 18px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-inline { width: 220px; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--grad); transition: width .15s; }
.progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.notice { margin: 10px 12px 0; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: #dfe3ff; }
.notice.is-error { background: rgba(255,107,122,.15); color: #ffc2c9; }
.notice.is-warn { background: rgba(255,181,71,.15); color: #ffd9a1; }
.example-note { margin: 10px 12px 0; font-size: 12px; color: var(--warn); }
.result-body { min-height: 120px; }
.result-empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--faint); font-size: 14px; }
.stage-view { display: flex; flex-direction: column; }
.compare-wrap { min-height: 320px; max-height: 78vh; display: grid; place-items: center; padding: 12px; overflow: auto; }
.compare { position: relative; overflow: hidden; border-radius: 10px; background: #000 repeating-conic-gradient(#1a1e33 0 25%, #14172a 0 50%) 0 0 / 20px 20px; user-select: none; touch-action: none; max-width: 100%; }
.compare canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cmp-before { z-index: 1; }
.cmp-after { z-index: 2; clip-path: inset(0 0 0 var(--split, 50%)); }
.cmp-handle { position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; background: #fff; transform: translateX(-1px); cursor: ew-resize; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.cmp-grip { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.5); display: grid; place-items: center; }
.cmp-grip::before { content: "◀ ▶"; font-size: 10px; color: #333; letter-spacing: 2px; }
.cmp-tag { position: absolute; z-index: 4; top: 10px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; }
.cmp-tag-before { left: 10px; } .cmp-tag-after { right: 10px; }
.compare.is-full { max-width: none; max-height: none; }

.models-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-2); }
.model-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.model-row { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; font-size: 12.5px; padding: 5px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.model-row .dot { grid-row: 1 / span 2; }
.model-name { font-weight: 600; }
.model-meta { display: flex; gap: 8px; color: var(--muted); font-size: 11.5px; }
.model-row.is-unavailable { opacity: .6; }
.models-row .progress { flex: 1 1 200px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot-idle { background: var(--faint); } .dot-busy { background: var(--warn); animation: pulse 1.2s infinite; } .dot-ok { background: var(--ok); } .dot-err { background: var(--err); } .dot-off { background: transparent; border: 1.5px solid var(--faint); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,181,71,.6); } 50% { box-shadow: 0 0 0 5px rgba(255,181,71,0); } }
.hint { margin: 0; font-size: 12px; color: var(--muted); flex-basis: 100%; }
.hint-warn { color: var(--warn); }

/* content below the fold */
.content { max-width: 880px; margin: 28px auto 0; padding: 0 20px 24px; color: #d6daf0; }
.content h1 { font-size: 26px; line-height: 1.25; margin: 0 0 12px; }
.content h2 { font-size: 19px; margin: 26px 0 10px; }
.lead { font-size: 16px; color: var(--muted); }
.steps li, .plain li { margin: 8px 0; }
.plain { padding-left: 18px; }
details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.footer { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: space-between; padding: 14px 16px 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

@media (max-width: 1080px) {
  .visual { grid-template-columns: 1fr 1fr; grid-template-areas: "input stats" "arrow arrow" "panel panel"; gap: 12px; }
  .v-input { grid-area: input; } .v-stats { grid-area: stats; } .v-panel { grid-area: panel; }
  .v-arrow { display: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { height: auto; padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .topbar-actions { flex-wrap: wrap; row-gap: 6px; }
  .top-link { white-space: nowrap; }
  .diagram { padding: 12px 10px 8px; }
  .pipeline { grid-template-columns: 1fr; gap: 12px; padding-bottom: 12px; }
  .stage-arrow { display: none; } .stage::after { display: none; }
  .visual { grid-template-columns: 1fr; grid-template-areas: "input" "panel" "stats"; }
  .v-frame { min-height: 220px; }
  .flow-caption { font-size: 15px; gap: 8px; letter-spacing: 0; flex-wrap: wrap; }
  .compare-wrap { min-height: 240px; }
  .progress-inline { width: 140px; }
  .content h1 { font-size: 22px; }
}
