/* Safe Zone Previewer — irvinPH. Same tokens and look as Decision Maker, Name Tags and Cropper. */

:root {
  --bg: #050c18;
  --panel: rgba(10, 23, 40, 0.6);
  --panel-solid: #0d1526;
  --field: rgba(15, 33, 54, 0.8);
  --text: #f8fafc;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #3fbef7;
  --accent-light: #6fd4ff;
  --accent-strong: #3aa8ea;
  --lime: #94f2b9;
  --amber: #fcd34d;
  --danger: #ff8a8a;
  --covered: rgba(255, 96, 96, 0.55);
  --ink: #07111f;
  --ink-950: #040b16;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --grad: linear-gradient(135deg, var(--accent-light), var(--accent-strong));
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Nunito Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(60rem 40rem at 72% -10%, rgb(30 110 190 / 0.22), transparent 65%),
    radial-gradient(50rem 35rem at 110% 110%, rgb(20 90 170 / 0.18), transparent 60%),
    radial-gradient(40rem 30rem at -10% 40%, rgb(20 70 140 / 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
svg { flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.1) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 999px; }

.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-accent { color: var(--accent); }
.flex-col { display: flex; flex-direction: column; }
.gap-3 { gap: 12px; }

/* ---------- Layout ---------- */
.page { display: flex; flex-direction: column; min-height: 100vh; }
.shell { flex: 1; display: flex; flex-direction: column; }
.sidebar {
  display: flex; flex-direction: column; gap: 24px; padding: 24px;
  background: rgba(4, 11, 22, 0.5);
}
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: 16px; }
.footer { flex-shrink: 0; padding: 10px 24px; border-top: 1px solid rgba(255, 255, 255, .1); text-align: center; font-size: 12px; color: var(--muted); }
.footer a { color: var(--text); font-weight: 700; text-decoration: none; transition: color .15s; }
.footer a:hover { color: var(--accent); }
.lg-only { display: none; }

@media (min-width: 1024px) {
  .page { height: 100vh; }
  .shell { flex-direction: row; min-height: 0; }
  .main-col { overflow-y: auto; }
  .sidebar {
    width: 320px; overflow-y: auto; flex-shrink: 0;
    padding: 24px 28px; border-right: 1px solid rgba(255, 255, 255, 0.06);
  }
  .main { padding: 20px; }
  .lg-only { display: revert; }
}

/* ---------- Sidebar ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand a { border-radius: 8px; transition: opacity .15s; }
.brand a:hover { opacity: .85; }
.brand-icon { width: 56px; height: 56px; object-fit: contain; }
.brand-logo { height: 60px; width: auto; }

.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.hero-title { margin: 8px 0 0; font-size: 32px; line-height: 1.12; font-weight: 900; letter-spacing: -.025em; color: #fff; }
.hero-copy { margin: 12px 0 0; font-size: 14px; line-height: 1.625; color: var(--muted); }
.divider { height: 1px; border: 0; margin: 0; background: rgba(255, 255, 255, 0.06); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.step-item { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: 12px; transition: all .2s; }
.step-circle {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.25); color: #fff; font-size: 14px; font-weight: 800; transition: all .2s;
}
.step-name { display: block; font-size: 15px; font-weight: 800; color: #fff; }
.step-hint { display: block; font-size: 13px; color: var(--muted); }
.step-check { display: none; width: 16px; height: 16px; color: var(--accent-light); }
.step-item[data-state="active"] { background: linear-gradient(to right, var(--accent-light), var(--accent)); box-shadow: 0 10px 15px -3px rgba(63, 190, 247, .2); }
.step-item[data-state="active"] .step-circle { background: var(--ink); border-color: transparent; }
.step-item[data-state="active"] .step-name { color: var(--ink-950); }
.step-item[data-state="active"] .step-hint { color: rgba(7, 17, 31, .7); }
.step-item[data-state="done"] .step-circle { background: rgba(63, 190, 247, .15); border-color: var(--accent); }
.step-item[data-state="done"] .step-num { display: none; }
.step-item[data-state="done"] .step-check { display: block; }

.section-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.section-label svg { width: 14px; height: 14px; }

/* Platform list */
.preset-list { display: flex; flex-direction: column; gap: 4px; }
.preset-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid transparent;
  border-radius: 14px; background: none; text-align: left; transition: background .15s, border-color .15s;
}
.preset-btn:hover { background: rgba(255, 255, 255, .05); }
.preset-btn[aria-checked="true"] { background: rgba(63, 190, 247, .12); border-color: rgba(63, 190, 247, .3); }
.preset-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: rgba(255, 255, 255, .06); flex-shrink: 0; }
.preset-icon svg { width: 20px; height: 20px; }
.preset-btn[aria-checked="true"] .preset-icon { background: var(--grad); color: var(--ink); }
.preset-btn strong { display: block; font-size: 14px; }
.preset-btn small { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.preset-btn[aria-checked="true"] strong { color: var(--accent); }
.preset-key { margin-left: auto; }
@media (max-width: 1023px) {
  .preset-list { flex-direction: row; overflow-x: auto; margin: 0 -24px; padding: 0 24px 4px; scrollbar-width: none; }
  .preset-btn { width: auto; flex-shrink: 0; border-color: var(--line); background: rgba(255, 255, 255, .03); white-space: nowrap; }
  .preset-key { display: none; }
}

kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px;
  padding: 1px 6px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06); font: inherit; font-size: 11px; font-weight: 700; color: #e2e8f0;
}

/* ---------- Workspace card ---------- */
.card { border-radius: 16px; border: 1px solid var(--line); background: var(--panel); }
.workspace { display: flex; flex-direction: column; overflow: hidden; background: rgba(7, 17, 31, .4); }
@media (min-width: 1200px) {
  .workspace { flex-direction: row; height: calc(100dvh - 80px); min-height: 640px; }
}

/* Stage */
.stage {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 45%, rgb(24 70 120 / .45), transparent 70%), #060f1c;
}
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.stage-heading { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.stage-title { margin: 0; font-size: 1.2rem; font-weight: 900; letter-spacing: -.02em; color: #fff; }
.readout { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.readout b { color: var(--accent); font-weight: 800; }
.stage-tools { display: flex; align-items: center; gap: 8px; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.segmented button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border: 0; border-radius: 999px;
  background: none; font-size: 14px; font-weight: 800; color: var(--muted); white-space: nowrap; transition: all .2s;
}
.segmented button:hover { color: var(--text); }
.segmented-sm button { padding: 6px 14px; font-size: 13px; }
.segmented button[aria-pressed="true"] { background: var(--grad); color: var(--ink); box-shadow: 0 6px 18px rgba(58, 168, 234, .3); }

.stage-body { position: relative; height: 78vh; min-height: 480px; overflow: hidden; }
@media (min-width: 1200px) { .stage-body { flex: 1; height: auto; min-height: 0; } }
.stage-body:fullscreen { background: radial-gradient(ellipse at 50% 45%, rgb(24 70 120 / .45), transparent 70%), #060f1c; }

/* The phone is sized in JS to fit the stage at 9:16. */
.phone {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  overflow: hidden; border-radius: 8px; background: #000;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  transition: border-radius .2s, box-shadow .2s;
}
.phone.framed {
  border-radius: var(--radius, 36px);
  box-shadow: 0 0 0 9px #0b1120, 0 0 0 10px rgba(255, 255, 255, .14), 0 30px 70px rgba(0, 0, 0, .6);
}
.media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.phone[data-fit="contain"] .media { object-fit: contain; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.screen-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 20px; text-align: center; color: var(--muted); font-size: 13px;
  background: radial-gradient(ellipse at 50% 40%, #16294a, #070f1d 75%);
}
.screen-empty svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 6px; }
.screen-empty strong { color: #fff; font-size: 15px; }
.drop-hint {
  position: absolute; inset: 12px; display: grid; place-items: center; border-radius: 16px; z-index: 5;
  border: 2px dashed var(--accent); background: rgba(6, 15, 28, .8); color: var(--accent-light); font-size: 18px; font-weight: 900;
}

/* Player bar */
.player { display: flex; align-items: center; gap: 12px; margin: 0 20px 20px; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(4, 11, 22, .55); }
.seek { flex: 1; min-width: 60px; }
.time { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 479px) { .time { display: none; } }

/* ---------- Builder column ---------- */
.builder { display: flex; flex-direction: column; border-top: 1px solid rgba(255, 255, 255, .08); background: rgba(4, 11, 22, .35); }
@media (min-width: 1200px) {
  .builder { width: 400px; flex-shrink: 0; border-top: 0; border-left: 1px solid rgba(255, 255, 255, .08); overflow-y: auto; }
}
.builder-block { padding: 22px 24px; border-bottom: 1px solid rgba(255, 255, 255, .06); display: flex; flex-direction: column; gap: 12px; }
.builder-block:last-child { border-bottom: 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.block-title { display: flex; align-items: center; gap: 10px; margin: -6px 0 0; font-size: 1.3rem; font-weight: 900; letter-spacing: -.02em; color: #fff; }
.group-title { margin: 0; font-size: 15px; font-weight: 800; color: #fff; }
.block-copy { margin: -6px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.field-caption { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* Dropzone + file card */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; border-radius: 16px; cursor: pointer; text-align: center;
  border: 2px dashed rgba(63, 190, 247, .35); background: rgba(63, 190, 247, .04); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: rgba(63, 190, 247, .1); }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone strong { margin-top: 6px; font-size: 15px; font-weight: 800; color: #fff; }
.dropzone small { font-size: 13px; color: var(--muted); }
.accent-tile { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--grad); color: var(--ink); box-shadow: 0 8px 20px rgba(58, 168, 234, .3); }
.accent-tile svg { width: 20px; height: 20px; }
.sample-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: -4px; }
.sample-btn {
  position: relative; aspect-ratio: 9 / 16; max-height: 200px; padding: 0; overflow: hidden; border-radius: 12px;
  border: 2px solid var(--line-strong); background: #000; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.sample-btn img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s, opacity .15s; opacity: .85; }
.sample-btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(4, 11, 22, .85), transparent 45%); }
.sample-btn:hover { border-color: rgba(63, 190, 247, .6); transform: translateY(-2px); }
.sample-btn:hover img { transform: scale(1.05); opacity: 1; }
.sample-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 190, 247, .25); }
.sample-btn[aria-pressed="true"] img { opacity: 1; }
.sample-play {
  position: absolute; z-index: 1; left: 50%; top: 45%; transform: translate(-50%, -50%); display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; background: rgba(4, 11, 22, .55); color: #fff; backdrop-filter: blur(4px); transition: background .15s, color .15s;
}
.sample-play svg { width: 16px; height: 16px; margin-left: 2px; }
.sample-btn:hover .sample-play, .sample-btn[aria-pressed="true"] .sample-play { background: var(--grad); color: var(--ink); }
.sample-label { position: absolute; z-index: 1; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 12px; font-weight: 800; color: #fff; }

.file-card { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .035); animation: pop .25s ease-out; }
.file-thumb { width: 36px; height: 64px; border-radius: 8px; overflow: hidden; background: #000; flex-shrink: 0; }
.file-thumb canvas { width: 100%; height: 100%; display: block; }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.file-main strong { max-width: 100%; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-main small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { margin-top: 3px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: rgba(148, 242, 185, .12); color: var(--lime); }
.badge.warn { background: rgba(252, 211, 77, .12); color: var(--amber); }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }

/* Fields */
.field {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .1);
  background: var(--field); font-size: 15px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s;
}
.field:hover { border-color: rgba(255, 255, 255, .2); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 190, 247, .18); }
.margin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.margin-field { display: flex; flex-direction: column; gap: 6px; }
.field-unit { position: relative; display: block; }
.field-unit .field { padding-right: 40px; }
.field-unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--dim); pointer-events: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 800; text-decoration: none; transition: transform .15s, background .15s, opacity .15s, box-shadow .15s, color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: var(--ink); box-shadow: 0 10px 28px rgba(58, 168, 234, .28); }
.btn-ghost { background: rgba(255, 255, 255, .06); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.btn-ghost[aria-pressed="true"] { background: rgba(63, 190, 247, .14); color: var(--accent-light); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--dim); transition: all .15s; flex-shrink: 0; }
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn-danger:hover { background: rgba(255, 138, 138, .12); color: var(--danger); }
.icon-btn-lg { width: 38px; height: 38px; border-radius: 10px; color: var(--text); }
.icon-btn-lg svg { width: 20px; height: 20px; }
.icon-btn-lg:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: var(--accent-light); }
#playButton { background: var(--grad); color: var(--ink); border-radius: 50%; }
#playButton svg { width: 18px; height: 18px; }

/* Slider */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row output { width: 44px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.range { flex: 1; accent-color: var(--accent-strong); }

/* Toggles */
.toggles { display: flex; flex-direction: column; gap: 2px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }
.toggle-row strong { display: block; font-size: 14px; }
.toggle-row small { display: block; font-size: 12px; color: var(--muted); }
.toggle-row.disabled { opacity: .45; cursor: not-allowed; }
.toggle {
  appearance: none; position: relative; width: 44px; height: 24px; margin: 0; border-radius: 999px; flex-shrink: 0; cursor: pointer;
  background: rgba(255, 255, 255, .12); transition: background .2s;
}
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle:checked { background: var(--accent-strong); }
.toggle:checked::after { transform: translateX(20px); }
.toggle:disabled { cursor: not-allowed; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .035); font-size: 13px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 18px; height: 18px; border-radius: 4px; }
.legend-safe { border: 2px dashed var(--accent); }
.legend-covered { background: var(--covered); }

.info-card { display: flex; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: rgba(10, 23, 40, .6); }
.info-icon { width: 28px; height: 28px; color: var(--accent); }
.info-card h3 { margin: 0; font-size: 15px; font-weight: 800; color: var(--accent); }
.info-card p { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: #0f1f36; border: 1px solid rgba(63, 190, 247, .4);
  font-size: 14px; font-weight: 700; transition: all .25s; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
