/* Sandbox UI. Uses the OurTown palette so the tool looks like it belongs to
   the platform it would ship inside. */

:root {
  --gold: #f8a800;
  --gold-deep: #a66a04;
  --navy: #295f98;
  --navy-deep: #1f3e63;
  --cream: #f7f2e8;
  --cream-50: #fdfaf3;
  --ink: #2f2f2f;
  --ink-soft: #5a5651;
  --line: rgba(47, 47, 47, .14);
  --ok: #3f5648;
  --warn: #a66a04;
  --err: #a64332;
  --radius: 14px;
  --shadow: 0 4px 20px -8px rgba(47,47,47,.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: Poppins, Inter, system-ui, sans-serif; font-weight: 800; letter-spacing: -.01em; }

/* --- Chrome ------------------------------------------------------------- */

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 14px 24px;
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .mark { font-family: Poppins, sans-serif; font-weight: 800; font-size: 19px; color: var(--gold-deep); }
.brand .sub { font-size: 13px; color: var(--ink-soft); }
.badge-env {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(41,95,152,.1); color: var(--navy); padding: 5px 10px; border-radius: 999px;
}

main { display: grid; grid-template-columns: 380px 1fr; gap: 0; align-items: start; }
@media (max-width: 1000px) { main { grid-template-columns: 1fr; } }

.panel {
  background: #fff; border-right: 1px solid var(--line);
  padding: 20px; min-height: calc(100vh - 57px);
}
.stage { padding: 22px 24px 60px; min-width: 0; }

/* --- Form --------------------------------------------------------------- */

fieldset { border: 0; margin-bottom: 22px; }
legend {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 10px;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 10px 0 4px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 13px; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--cream-50);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swatch-row { display: flex; align-items: center; gap: 8px; }
input[type=color] {
  width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.hexi { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset {
  font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.preset:hover { border-color: var(--gold); }
.preset .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.hint { font-size: 11.5px; color: var(--ink-soft); line-height: 1.45; margin-top: 6px; }
.hint strong { color: var(--err); }

/* --- Buttons ------------------------------------------------------------ */

button {
  font: inherit; cursor: pointer; border: 0; border-radius: 10px;
  font-weight: 700; transition: transform .06s ease, filter .15s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-push {
  width: 100%; padding: 14px; font-size: 15px; margin-top: 6px;
  background: var(--gold); color: var(--ink); box-shadow: var(--shadow);
}
.btn-push:hover:not(:disabled) { filter: brightness(1.04); }
.btn-ghost {
  padding: 8px 14px; font-size: 13px; background: #fff;
  border: 1px solid var(--line); color: var(--ink);
}

/* --- Selectors ---------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .dim { opacity: .6; font-weight: 500; margin-left: 4px; }

.group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 8px;
}

/* --- Preview ------------------------------------------------------------ */

.preview-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; min-height: 320px;
  display: flex; align-items: center; justify-content: center;
}
.preview-wrap img {
  max-width: 100%; max-height: 62vh; display: block;
  border-radius: 6px; box-shadow: 0 2px 14px -6px rgba(0,0,0,.3);
}
.preview-wrap.busy::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.6);
  border-radius: var(--radius);
}
.spinner {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(47,47,47,.15); border-top-color: var(--gold);
  animation: spin .7s linear infinite; display: none;
}
.preview-wrap.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.meta-line { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin-top: 10px; flex-wrap: wrap; }
.meta-line code { font-family: ui-monospace, monospace; background: rgba(47,47,47,.06); padding: 1px 5px; border-radius: 4px; }

.err-box {
  background: #fbf0ec; border: 1px solid rgba(166,67,50,.3); color: var(--err);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.5;
}

/* --- Warnings ----------------------------------------------------------- */

.warnings { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.warn-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
}
.warn-item .k {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--warn); white-space: nowrap; padding-top: 1px;
}
.warn-item .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin: 0 3px; }

/* --- Generate panel ----------------------------------------------------- */

.gen {
  margin-top: 20px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.bar { height: 9px; border-radius: 999px; background: rgba(47,47,47,.1); overflow: hidden; margin: 12px 0 8px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--navy); border-radius: 999px; transition: width .2s ease; }
.gen-status { font-size: 12.5px; color: var(--ink-soft); display: flex; justify-content: space-between; gap: 12px; }
.gen-status .file { font-family: ui-monospace, monospace; font-size: 11.5px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.stat { background: var(--cream); border-radius: 10px; padding: 8px 14px; }
.stat b { display: block; font-family: Poppins, sans-serif; font-size: 20px; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .07em; }
.btn-dl {
  background: var(--navy); color: #fff; padding: 11px 18px; font-size: 14px;
  text-decoration: none; border-radius: 10px; display: inline-block; font-weight: 700;
}
.btn-dl.alt { background: var(--gold); color: var(--ink); }

/* --- Static demo additions --------------------------------------------- */
.demo-note{background:rgba(41,95,152,.08);border:1px solid rgba(41,95,152,.2);border-radius:10px;
  padding:10px 13px;font-size:12px;line-height:1.5;color:var(--ink-soft);margin-bottom:16px}
.demo-note b{color:var(--navy)}
input[readonly],textarea[readonly]{background:#fff;color:var(--ink-soft);cursor:default}
.preset[aria-pressed=true]{border-color:var(--navy);background:var(--navy);color:#fff}
