/* ── Base ── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--t-14); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ── Header chrome ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .in {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
  height: 60px; display: flex; align-items: center; gap: var(--s-4);
}
.logo { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.logo .mark { width: 26px; height: 26px; display: block; }
.logo .word { font-family: var(--font-display); font-weight: 700; font-size: var(--t-20);
  letter-spacing: -0.02em; text-transform: lowercase; }
.nav { margin-left: auto; display: flex; gap: var(--s-3); }
.nav a { color: var(--muted); font-weight: 500; padding: 4px 0; position: relative; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--accent); }
.nav a.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 2px; background: var(--accent); }

/* ── Layout / page titles ── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: var(--s-5) var(--gutter) var(--s-6); }
h1.page { font-family: var(--font-display); font-weight: 700; font-size: var(--t-28);
  letter-spacing: -0.02em; margin: 0; }
.sub { color: var(--muted); font-size: var(--t-14); margin: 6px 0 0; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-4); }

/* ── Buttons ── */
.btn { font-family: var(--font-body); font-size: var(--t-14); font-weight: 600;
  height: var(--control-h); padding: 0 var(--s-2); border-radius: var(--r-control);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease); }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { filter: none; background: var(--bg); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn.iconbtn { padding: 0; width: var(--control-h); background: var(--surface);
  color: var(--muted); border-color: var(--line); font-size: 18px; }

/* spinner inside async buttons */
.spinner { width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Inputs ── */
label.fld { display: block; font-weight: 600; font-size: var(--t-13); margin: 0 0 6px; }
input[type=text], input[type=number], input[type=password], select, .input {
  width: 100%; height: var(--control-h); font-family: var(--font-body); font-size: var(--t-14);
  padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: var(--focus); outline-offset: 1px; border-color: var(--accent); }
.field-err { color: var(--error); font-size: var(--t-13); margin-top: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.pwwrap { position: relative; }
.pwwrap .reveal { position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: var(--t-13); font-weight: 600; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--card-pad); }
.card + .card { margin-top: var(--s-3); }
.card h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--t-20);
  letter-spacing: -0.01em; margin: 0 0 4px; }
.card .cardsub { color: var(--muted); font-size: var(--t-13); margin: 0 0 var(--s-3); }

/* ── Chips (status) ── */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-chip); font-size: var(--t-13); font-weight: 600; }
.chip.published { background: var(--published-bg); color: var(--published-ink); }
.chip.processing { background: var(--processing-bg); color: var(--processing-ink); }
.chip.failed { background: var(--failed-bg); color: var(--failed-ink); }
.chip.draft { background: var(--draft-bg); color: var(--draft-ink); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.processing .dot { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }

/* ── Guides grid ── */
.toolbar { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-3); }
.toolbar input { max-width: 280px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 32px; padding: 0 12px; border-radius: var(--r-chip); border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: var(--t-13); cursor: pointer; }
.pill.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.gcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: visible; display: flex; flex-direction: column; }
.gcard .thumbwrap { position: relative; }
.gcard .thumb { aspect-ratio: 16 / 9; width: 100%; border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--bg); object-fit: cover; display: block; }
.gcard .thumb.ph { display: grid; place-items: center; color: var(--muted); font-size: 30px; }
.gcard .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(22,21,15,0.82);
  color: #fff; font-family: var(--font-mono); font-size: 12px; padding: 2px 7px; border-radius: 6px; }
.gcard .chip.float { position: absolute; left: 10px; top: 10px; box-shadow: 0 1px 4px rgba(22,21,15,0.12); }
.gcard .body { padding: var(--s-2); display: flex; flex-direction: column; gap: 4px; flex: 1; }
.gcard h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--t-16); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.gcard .callout { background: var(--processing-bg); color: var(--processing-ink); font-size: var(--t-13);
  border-radius: var(--r-control); padding: 8px 10px; margin-top: 4px; }
.gcard .actions { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: var(--s-2); }
.gcard .actions .btn { height: 34px; font-size: var(--t-13); flex: 1; }
.gcard .actions .btn.iconbtn { flex: 0 0 34px; width: 34px; }

/* overflow menu */
.menu { position: relative; }
.menu .pop { position: absolute; right: 0; bottom: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-control); box-shadow: var(--hover-shadow);
  min-width: 170px; padding: 6px; z-index: 20; display: none; }
.menu.open .pop { display: block; }
.menu .pop button { display: block; width: 100%; text-align: left; background: none; border: 0;
  font-family: var(--font-body); font-size: var(--t-14); color: var(--ink); padding: 8px 10px;
  border-radius: 6px; cursor: pointer; }
.menu .pop button:hover { background: var(--bg); }
.menu .pop button.danger { color: var(--error); }

/* clickable card hover shadow */
.gcard:hover { box-shadow: var(--hover-shadow); }

/* ── Empty state ── */
.empty { text-align: center; padding: var(--s-6) var(--s-3); }
.empty .glyph { font-size: 48px; color: var(--muted); }
.empty h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-20); margin: var(--s-2) 0 4px; }
.empty p { color: var(--muted); margin: 0 0 var(--s-3); }

/* ── Create screen ── */
.narrow { max-width: 640px; margin: 0 auto; }
.drop { border: 2px dashed var(--line); border-radius: 12px; min-height: 220px;
  display: grid; place-items: center; text-align: center; cursor: pointer; padding: var(--s-3);
  transition: border-color var(--dur-hover) var(--ease), background var(--dur-hover) var(--ease); }
.drop:hover { border-color: var(--muted); }
.drop.over { border-color: var(--accent); background: var(--published-bg); }
.drop .glyph { font-size: 34px; color: var(--muted); }
.drop .big { font-weight: 600; font-size: var(--t-16); margin-top: var(--s-1); }
.drop .small { color: var(--muted); font-size: var(--t-13); margin-top: 4px; }
.filerow { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line);
  border-radius: var(--r-control); padding: 12px 14px; background: var(--surface); }
.filerow .fname { font-family: var(--font-mono); font-size: var(--t-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .fmeta { color: var(--muted); font-family: var(--font-mono); font-size: 12px; margin-left: auto; }
.filerow .rm { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }

/* accordion */
.acc { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.acc > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary .chev { margin-left: auto; color: var(--muted); transition: transform var(--dur-panel) var(--ease); }
.acc[open] > summary .chev { transform: rotate(90deg); }
.acc .inner { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.reset-note { color: var(--muted); font-size: var(--t-13); margin-top: var(--s-2); }
.reset-note a { font-weight: 600; }

/* ── Pipeline controls (shared Create + Settings) ── */
.pc-field { margin-top: var(--s-3); }
.pc-field:first-child { margin-top: 0; }
.pc-label { font-weight: 600; font-size: var(--t-14); display: flex; align-items: baseline; gap: 8px; }
.pc-label .val { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 400; }
.pc-desc { color: var(--muted); font-size: var(--t-13); margin-top: 2px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-control); padding: 3px; margin-top: 8px; }
.seg button { border: 0; background: none; font-family: var(--font-body); font-weight: 600;
  font-size: var(--t-13); color: var(--muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22,21,15,0.10); }
.toggle-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.switch { position: relative; width: 40px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px;
  transition: background var(--dur-hover) var(--ease); }
.switch .track::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  background: var(--surface); border-radius: 50%; transition: transform var(--dur-hover) var(--ease);
  box-shadow: 0 1px 2px rgba(22,21,15,0.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: var(--focus); outline-offset: 2px; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--surface); font-size: var(--t-14); font-weight: 500;
  padding: 10px 16px; border-radius: var(--r-control); opacity: 0; pointer-events: none;
  transition: opacity var(--dur-hover) var(--ease), transform var(--dur-hover) var(--ease); z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Console (job logs) ── */
.console { background: #131109; color: #E8E6E0; font-family: var(--font-mono); font-size: 12px;
  border-radius: var(--r-control); padding: 12px 14px; height: 260px; overflow: auto;
  white-space: pre-wrap; margin-top: var(--s-3); }
.console .done { color: #5FB98C; } .console .err { color: #E88; }

/* ── Editor (aligned to tokens) ── */
.editor { display: grid; grid-template-columns: 1fr 320px; gap: var(--s-4); align-items: start; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-2); }
.step-label { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.frameWrap { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; line-height: 0; }
.frameWrap img { max-width: 100%; max-height: 60vh; border-radius: var(--r-control); display: block; }
.marker { position: absolute; width: 28px; height: 28px; border: 3px solid var(--accent); border-radius: 50%;
  transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.ticks { position: relative; height: 14px; margin: 6px 0; }
.tick { position: absolute; top: 0; width: 2px; height: 8px; background: var(--muted); cursor: pointer; opacity: 0.5; }
.tick.tap { height: 12px; background: var(--accent); opacity: 1; }
.hlist { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.hl { border: 1px solid var(--line); border-radius: var(--r-control); padding: 10px; background: var(--surface); }
.hl.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--published-bg); }
.hl .h { display: flex; justify-content: space-between; align-items: center; }
.hl .n { font-weight: 700; font-family: var(--font-mono); }
.hl input[type=text] { margin-top: 6px; height: 34px; font-size: var(--t-13); }
.hl .meta { font-size: 11px; color: var(--muted); font-family: var(--font-mono); margin-top: 4px; }
.hl .x { background: none; border: 0; color: var(--error); cursor: pointer; font-size: 16px; }

/* ── Load animation: staggered fade-up on guide cards ── */
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stagger { opacity: 0; animation: fadeup var(--dur-panel) var(--ease) forwards; }

@media (max-width: 760px) {
  .two { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .stagger { opacity: 1; }
}
