/* DispoKit studio — design tokens + shell. Quietly premium; nothing SaaS-generic. */
:root {
  --t-ink: #1e2124;
  --t-ink-soft: #4c5250;
  --t-paper: #f4f3ee;
  --t-surface: #ffffff;
  --t-green: #1f3a2e;
  --t-green-soft: #e7efe9;
  --t-gold: #a67c2b;
  --t-hairline: #e0ddd4;
  --t-danger: #a33326;
  --t-focus: #2f6fd0;
  --t-radius: 10px;
  --t-shadow: 0 1px 2px rgba(30, 33, 36, .06), 0 8px 24px rgba(30, 33, 36, .07);
  --t-font: 'Source Sans 3', -apple-system, sans-serif;
  --t-font-display: 'Fraunces', Georgia, serif;
  --t-font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--t-paper); color: var(--t-ink); font: 16px/1.5 var(--t-font); }
button { font: inherit; cursor: pointer; }
a { color: var(--t-green); }
:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: var(--t-surface);
  border-bottom: 1px solid var(--t-hairline);
  position: sticky; top: 0; z-index: 30;
}
.wordmark { font: 700 15px/1 var(--t-font); letter-spacing: .34em; text-transform: uppercase; color: var(--t-green); text-decoration: none; }
.wordmark b { color: var(--t-gold); }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; min-height: 40px;
  border: 1px solid var(--t-hairline); border-radius: 999px;
  background: var(--t-surface); color: var(--t-ink);
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--t-gold); }
.chip.quiet { border-color: transparent; color: var(--t-ink-soft); }
main { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--t-radius); border: 1px solid transparent;
  font-weight: 700; font-size: 15.5px; text-decoration: none;
  background: var(--t-green); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--t-surface); color: var(--t-ink); border-color: var(--t-hairline); }
.btn.ghost { background: transparent; color: var(--t-green); }
.btn.danger { background: transparent; color: var(--t-danger); border-color: transparent; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }

/* ---------- cards / layout ---------- */
.card { background: var(--t-surface); border: 1px solid var(--t-hairline); border-radius: var(--t-radius); box-shadow: var(--t-shadow); }
.h1 { font: 600 30px/1.2 var(--t-font-display); margin: 0 0 6px; }
.sub { color: var(--t-ink-soft); margin: 0 0 22px; }
.stack { display: grid; gap: 16px; }

/* ---------- dashboard ---------- */
.deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.deal-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; border: 1px solid var(--t-hairline); border-radius: var(--t-radius); background: var(--t-surface); box-shadow: var(--t-shadow); text-decoration: none; color: inherit; }
.deal-card:hover { border-color: var(--t-green); }
.deal-thumb { height: 130px; background: var(--t-green-soft); display: grid; place-items: center; color: var(--t-green); font: 600 13px/1 var(--t-font); letter-spacing: .2em; text-transform: uppercase; overflow: hidden; }
.deal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.deal-meta { padding: 14px 16px 16px; display: grid; gap: 4px; }
.deal-title { font-weight: 700; font-size: 16.5px; }
.deal-sub { color: var(--t-ink-soft); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.badge.draft { background: #f0eee7; color: #6b6a5f; }
.badge.ready { background: var(--t-green-soft); color: var(--t-green); }
.badge.live { background: #e9f4ec; color: #14683a; }

/* ---------- new deal ---------- */
.paste-box {
  width: 100%; min-height: 220px; resize: vertical;
  padding: 18px; border: 1px solid var(--t-hairline); border-radius: var(--t-radius);
  font: 15.5px/1.55 var(--t-font); color: var(--t-ink); background: var(--t-surface);
}
.paste-box:focus { border-color: var(--t-green); outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 46, .12); }
.dropzone {
  border: 1.5px dashed var(--t-hairline); border-radius: var(--t-radius);
  padding: 22px; text-align: center; color: var(--t-ink-soft); background: var(--t-surface);
}
.dropzone.dragover { border-color: var(--t-green); background: var(--t-green-soft); }
.photo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-card { position: relative; border: 1px solid var(--t-hairline); border-radius: 8px; overflow: hidden; background: var(--t-surface); }
.photo-card img { width: 100%; height: 84px; object-fit: cover; display: block; }
.photo-card .pc-meta { font-size: 11.5px; color: var(--t-ink-soft); padding: 5px 8px; display: flex; justify-content: space-between; gap: 6px; }
.photo-card .pc-bar { height: 3px; background: var(--t-green); width: 0%; transition: width .3s; }
.photo-card .pc-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(20, 24, 21, .72); color: #fff; font-size: 13px; line-height: 1; }
.photo-card.failed { border-color: var(--t-danger); }

/* ---------- generating ---------- */
.genstage { max-width: 620px; margin: 40px auto; text-align: center; }
.genstage .steps { display: grid; gap: 12px; margin: 28px 0; text-align: left; }
.genstep { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: var(--t-radius); border: 1px solid var(--t-hairline); background: var(--t-surface); color: var(--t-ink-soft); }
.genstep .ico { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--t-hairline); flex: none; display: grid; place-items: center; font-size: 12px; }
.genstep.active { border-color: var(--t-green); color: var(--t-ink); }
.genstep.active .ico { border-color: var(--t-green); }
.genstep.active .ico::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--t-green); animation: pulse 1.2s ease-in-out infinite; }
.genstep.done { color: var(--t-ink); }
.genstep.done .ico { background: var(--t-green); border-color: var(--t-green); color: #fff; }
@keyframes pulse { 50% { opacity: .35; } }
.fact-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.fact-chip { padding: 6px 12px; border-radius: 999px; background: var(--t-green-soft); color: var(--t-green); font-weight: 600; font-size: 13.5px; animation: chipin .3s ease-out; }
@keyframes chipin { from { transform: scale(.85); opacity: 0; } }

/* ---------- gallery ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tpl-cell { border: 1px solid var(--t-hairline); border-radius: var(--t-radius); background: var(--t-surface); overflow: hidden; text-align: left; padding: 0; }
.tpl-cell:hover, .tpl-cell.selected { border-color: var(--t-green); box-shadow: 0 0 0 2px rgba(31, 58, 46, .25); }
.tpl-frame { position: relative; width: 100%; aspect-ratio: 850 / 1100; overflow: hidden; background: #eee; }
.tpl-frame .flyer-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.tpl-name { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 700; font-size: 14.5px; }
.tpl-name small { color: var(--t-ink-soft); font-weight: 400; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 200px 1fr 300px; gap: 18px; align-items: start; }
.tray { position: sticky; top: 76px; display: grid; gap: 10px; }
.tray h3, .inspector h3 { font: 700 12.5px/1 var(--t-font); letter-spacing: .18em; text-transform: uppercase; color: var(--t-ink-soft); margin: 0 0 4px; }
.tray-photo { position: relative; border: 1px solid var(--t-hairline); border-radius: 8px; overflow: hidden; background: var(--t-surface); cursor: grab; touch-action: none; padding: 0; }
.tray-photo img { width: 100%; height: 92px; object-fit: cover; display: block; pointer-events: none; }
.tray-photo.armed { outline: 3px solid var(--t-focus); }
.tray-photo .used { position: absolute; top: 5px; left: 5px; background: rgba(20, 24, 21, .78); color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; letter-spacing: .06em; }
.canvas-wrap { display: grid; gap: 12px; }
.canvas-scaler { position: relative; width: 100%; }
.canvas-scaler .flyer-canvas { transform-origin: 0 0; }
.inspector { position: sticky; top: 76px; display: grid; gap: 14px; }
.check-chip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid #eadfc4; background: #fbf6e8; border-radius: 8px; font-size: 13.5px; }
.check-chip.conflict { border-color: #e7c4b4; background: #fdf0ea; }
.check-chip button { margin-left: auto; }
.tpl-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tpl-strip button { aspect-ratio: 17/22; border: 1.5px solid var(--t-hairline); border-radius: 6px; background: var(--t-surface); overflow: hidden; padding: 0; position: relative; }
.tpl-strip button.selected { border-color: var(--t-green); box-shadow: 0 0 0 1.5px var(--t-green); }
.tpl-strip .mini { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--t-ink-soft); }
.exportbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border-radius: var(--t-radius); background: var(--t-surface); border: 1px solid var(--t-hairline); }
.save-note { font-size: 13px; color: var(--t-ink-soft); margin-left: auto; }
.save-note.err { color: var(--t-danger); font-weight: 700; }

/* pan/zoom overlay */
.adjust-overlay { position: fixed; inset: 0; background: rgba(16, 20, 17, .55); z-index: 60; display: grid; place-items: center; }
.adjust-panel { background: var(--t-surface); border-radius: 14px; padding: 18px; display: grid; gap: 12px; max-width: min(92vw, 560px); }
.adjust-stage { position: relative; overflow: hidden; border-radius: 8px; background: #111; touch-action: none; cursor: move; }
.adjust-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.adjust-row { display: flex; gap: 10px; align-items: center; }
.adjust-row input[type="range"] { flex: 1; }
.adjust-row label { font-size: 13.5px; font-weight: 600; color: var(--t-ink-soft); }
.adjust-row input[type="text"] { flex: 1; min-height: 40px; border: 1px solid var(--t-hairline); border-radius: 8px; padding: 6px 12px; font: inherit; }

/* ---------- modal / paywall ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(16, 20, 17, .5); z-index: 70; display: grid; place-items: center; padding: 18px; }
.modal { background: var(--t-surface); border-radius: 14px; padding: 26px; width: min(480px, 94vw); display: grid; gap: 14px; }
.modal h2 { font: 600 24px/1.2 var(--t-font-display); margin: 0; }
.pack-row { display: flex; justify-content: space-between; align-items: center; border: 1.5px solid var(--t-hairline); border-radius: var(--t-radius); padding: 14px 16px; }
.pack-row.featured { border-color: var(--t-gold); background: #fdfaf2; }
.pack-row .pk-name { font-weight: 700; }
.pack-row .pk-per { color: var(--t-ink-soft); font-size: 13px; }
.pack-row .pk-price { font: 600 22px/1 var(--t-font-display); }

/* ---------- states ---------- */
.empty-state { text-align: center; padding: 60px 20px; display: grid; gap: 14px; justify-items: center; }
.empty-state .h1 { margin: 0; }
.skeleton { border-radius: var(--t-radius); background: linear-gradient(100deg, #ecebe5 40%, #f6f5f0 50%, #ecebe5 60%); background-size: 200% 100%; animation: sk 1.2s infinite linear; min-height: 120px; }
@keyframes sk { to { background-position: -200% 0; } }
.error-box { border: 1px solid #e7c4b4; background: #fdf0ea; color: #7d2a1c; border-radius: var(--t-radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--t-ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; z-index: 90; box-shadow: var(--t-shadow); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  main { padding: 16px 12px 90px; }
  .editor { grid-template-columns: 1fr; }
  .tray { position: static; grid-auto-flow: column; grid-auto-columns: 110px; overflow-x: auto; padding-bottom: 6px; }
  .tray h3 { display: none; }
  .inspector { position: static; }
  .exportbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-radius: 0; border-left: 0; border-right: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .exportbar .btn { min-height: 48px; flex: 1; }
  .save-note { display: none; }
}
