:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1f2421;
  --muted: #5d655f;
  --border: #dedbd2;
  --primary: #2a6f62;
  --primary-ink: #ffffff;
  --primary-soft: #e3f0ec;
  --danger: #b4322a;
  --amber: #c98a12;
  --green: #2f9a5b;
  --red: #c8372d;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141716;
    --surface: #1c201e;
    --surface-2: #242927;
    --text: #e9ece9;
    --muted: #a3aca6;
    --border: #333a37;
    --primary: #5cbfa8;
    --primary-ink: #0f1513;
    --primary-soft: #1f322d;
    --danger: #f0766b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); font-weight: 500; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 0.875rem; }
.btn.big { width: 100%; padding: 16px; font-size: 1.05rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost, .danger-text { background: transparent; color: var(--danger); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline; cursor: pointer; }
.small-link { font-size: 0.875rem; }

/* cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1200px) / 2)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; inset: 8px 9px 8px 9px; border: 2.5px solid var(--primary-ink); border-radius: 3px 8px 8px 3px; border-left-width: 2.5px; }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
.screen-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 0.9rem; margin-right: 6px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); display: grid; gap: 12px; }
.login-card h1 { margin-top: 12px; }
input[type="password"], input:not([type]), textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid color-mix(in srgb, var(--muted) 55%, var(--border));
  border-radius: 10px; padding: 12px 14px;
}
textarea { resize: vertical; min-height: 90px; }
label { font-weight: 600; }

/* ready light */
.ready { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--muted); }
.ready .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 25%, transparent); }
.ready.green .dot { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.ready.red .dot { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); }
.ready.amber .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.debug-lights { display: flex; flex-wrap: wrap; gap: 16px; padding: 6px 16px; font-family: ui-monospace, monospace; font-size: 0.75rem; background: var(--surface-2); }

/* projects */
.project-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.thumb { position: relative; aspect-ratio: 16 / 10; border: 0; padding: 0; background: color-mix(in srgb, var(--a) 18%, var(--surface-2)); cursor: pointer; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb-ph { font-size: 3rem; font-weight: 700; color: var(--a); }
.badge { position: absolute; top: 10px; left: 10px; background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.project-meta { padding: 14px 16px 16px; display: grid; gap: 6px; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }

/* create */
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 18px; display: grid; gap: 4px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.over, .drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: flex; gap: 8px; align-items: baseline; }
.style-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.style-grid.compact { grid-template-columns: repeat(2, 1fr); }
.style-card {
  text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border);
  border-radius: 12px; padding: 12px; cursor: pointer; display: grid; gap: 4px;
}
.style-card[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); }
.style-swatch { height: 34px; border-radius: 8px; margin-bottom: 4px; background: linear-gradient(90deg, var(--a) 0 30%, color-mix(in srgb, var(--a) 15%, #fff) 30% 100%); }
.style-bold .style-swatch { background: linear-gradient(90deg, #15181b 0 55%, var(--a) 55% 100%); }
.style-warm .style-swatch { background: linear-gradient(90deg, #f3e7d3 0 60%, var(--a) 60% 100%); border-radius: 18px; }
.style-academic .style-swatch { background: linear-gradient(90deg, #fbfaf6 0 70%, var(--a) 70% 100%); border: 1px solid #d8d2c4; border-radius: 2px; }
.style-academic .style-name { font-family: Charter, "Bitstream Charter", Georgia, serif; }
.style-name { font-weight: 700; }
.style-desc { font-size: 0.85rem; color: var(--muted); }
.compact .style-desc { display: none; }
.accents { border: 0; padding: 0; margin: 0; }
.accents legend { font-weight: 600; margin-bottom: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; position: relative; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }

/* review */
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.finding { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-weight: 400; cursor: pointer; }
.finding input { grid-row: span 3; width: 20px; height: 20px; accent-color: var(--primary); }
.finding-cat { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.finding-text { font-weight: 600; word-break: break-word; }
.highlighted { white-space: pre-wrap; max-height: 360px; overflow: auto; background: var(--surface-2); border-radius: 10px; padding: 14px; margin-top: 10px; font-size: 0.92rem; }
mark { background: #ffe08a; color: #1f2421; border-radius: 3px; padding: 0 2px; }

/* building */
.build-card { display: grid; gap: 16px; max-width: 640px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; }
.steps li.done { color: var(--text); }
.steps li.done .tick { background: var(--green); border-color: var(--green); }
.steps li.done .tick::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.steps li.current { color: var(--text); font-weight: 700; }
.steps li.current .tick { border-color: var(--primary); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.debug { margin-top: 20px; font-family: ui-monospace, monospace; font-size: 0.78rem; }
.debug ol { max-height: 320px; overflow: auto; padding-left: 18px; }

/* result */
.summary { background: var(--primary-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; white-space: pre-line; }
.result-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.preview-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg-btn { border: 0; background: transparent; font: inherit; font-size: 0.875rem; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.seg-btn.on { background: var(--primary); color: var(--primary-ink); }
.frame-holder { height: 75vh; min-height: 480px; display: flex; justify-content: center; background: var(--surface-2); }
.frame-holder iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width 0.25s; }
.frame-holder.phone iframe { width: 390px; max-width: 100%; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.side .card { padding: 16px; }
.shots { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; align-items: start; }
.shots img { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }

@media (max-width: 900px) {
  .result-grid { grid-template-columns: 1fr; }
  .frame-holder { height: 70vh; }
}
@media (max-width: 520px) {
  .ready-text { display: none; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
