/* Prompt Arsenal - red, black and chrome to match the Midnight Forge Prompt Arsenal logo. */
:root, [data-theme="dark"] {
  --bg: #0a0607; --bg2: #120a0b; --panel: #151011; --panel2: #1d1517; --panel3: #261c1e;
  --line: #3a2629; --line2: #52343a;
  --text: #f4eeee; --muted: #b3a3a5; --faint: #86787a;
  --red: #ff2d3a; --red-hi: #ff5a63; --red-deep: #b5121c; --red-soft: rgba(255, 45, 58, .14);
  --chrome: linear-gradient(180deg, #ffffff 0%, #c9c9cf 45%, #8d8d96 55%, #e9e9ee 100%);
  --ok: #4fd18b; --warn: #ffb547; --bad: #ff5a63;
  --input: #0d0809; --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --r: 14px; --r-sm: 10px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f1f1; --bg2: #efe7e7; --panel: #ffffff; --panel2: #f8f3f3; --panel3: #f0e6e6;
  --line: #e4d4d5; --line2: #d3bcbe;
  --text: #1c1213; --muted: #6c5a5c; --faint: #8f7e80;
  --red: #d8101d; --red-hi: #e8323d; --red-deep: #a00c16; --red-soft: rgba(216, 16, 29, .08);
  --ok: #138a4c; --warn: #b26b00; --bad: #c8101c;
  --input: #ffffff; --shadow: 0 14px 40px rgba(60, 10, 15, .12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  background: radial-gradient(1100px 520px at 85% -10%, rgba(255, 45, 58, .16), transparent 60%), radial-gradient(700px 400px at -10% 110%, rgba(255, 45, 58, .08), transparent 60%), var(--bg);
  font: 15px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[data-theme="light"] body { background: radial-gradient(1100px 520px at 85% -10%, rgba(216, 16, 29, .07), transparent 60%), var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red-hi); outline-offset: 2px; }
.hidden { display: none !important; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { background: var(--panel3); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
h1, h2, h3, p { margin: 0; }
.mini { font-size: 12.5px; color: var(--muted); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px;
  padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand img { width: 44px; height: 44px; filter: drop-shadow(0 0 10px rgba(255, 45, 58, .35)); }
.brand span { display: flex; flex-direction: column; line-height: 1.05; }
.brand b { font-size: 15px; letter-spacing: .08em; font-weight: 900; background: var(--chrome); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="light"] .brand b { background: none; color: var(--text); }
.brand i { font-style: normal; font-size: 10.5px; letter-spacing: .32em; color: var(--red); font-weight: 800; margin-top: 3px; }
.views { display: flex; gap: 4px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.views::-webkit-scrollbar { display: none; }
.view-btn {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; border: 1px solid transparent;
  background: none; color: var(--muted); font-weight: 650; white-space: nowrap;
}
.view-btn:hover { color: var(--text); background: var(--panel2); }
.view-btn.on { color: var(--text); background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.view-btn em { font-style: normal; font-size: 11px; background: var(--red); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 18px; text-align: center; }
.view-btn em:empty { display: none; }
.top-tools { display: flex; gap: 6px; align-items: center; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border-radius: var(--r-sm);
  background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-weight: 650; white-space: nowrap;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--line2); background: var(--panel3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--red-hi), var(--red-deep)); border-color: var(--red); color: #fff; box-shadow: 0 6px 20px rgba(255, 45, 58, .25); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: none; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.big { padding: 11px 18px; font-size: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-sm); background: none; border: 1px solid transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--panel2); border-color: var(--line); }
.link { background: none; border: 0; color: var(--red-hi); font-weight: 700; font-size: 12.5px; padding: 3px 4px; display: inline-flex; align-items: center; gap: 4px; }
.link .ic { width: 14px; height: 14px; }
.link:hover { text-decoration: underline; }

/* ---------- layout ---------- */
#view { max-width: 1440px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-left)) 110px; outline: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.panel-head h1 { font-size: 22px; letter-spacing: -.01em; }
.panel-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.grow { flex: 1 1 200px; }
.welcome { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; margin-bottom: 14px; border-radius: var(--r); background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }

/* ---------- modes ---------- */
.modes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.mode {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 13px;
}
.mode .ic { width: 22px; height: 22px; }
.mode:hover { color: var(--text); border-color: var(--line2); }
.mode.on { color: var(--text); border-color: var(--mc); background: linear-gradient(180deg, color-mix(in srgb, var(--mc) 22%, var(--panel)), var(--panel)); box-shadow: 0 0 0 1px var(--mc) inset, 0 8px 24px color-mix(in srgb, var(--mc) 25%, transparent); }
.mode.on .ic { color: var(--mc); }

/* ---------- build ---------- */
.build { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.output { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.starters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.field small { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: -2px; }
.field input, .field select, .field textarea, .row > input, .row > select, .chip-add, .var input {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm); background: var(--input); border: 1px solid var(--line); min-width: 0;
}
.row > select { width: auto; }
.field textarea { resize: vertical; min-height: 56px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .row > input:focus, .row > select:focus, .chip-add:focus, .var input:focus, #out:focus {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft);
}
.field input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--red); height: 26px; }
.rv { color: var(--red-hi); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { color: var(--text); border-color: var(--line2); }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.chip.ghost { background: none; border-style: dashed; }
.starter { border-style: dashed; }
.chip-add { margin-top: 4px; font-size: 13px; padding: 8px 11px; }
.vars { margin-top: 14px; padding: 12px; border-radius: var(--r-sm); border: 1px dashed var(--line2); display: grid; gap: 8px; }
.var { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.var code { flex: none; color: var(--red-hi); }
.actions-row { margin: 16px 0 0; }

/* ---------- output ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 14px; width: fit-content; }
.tab { padding: 7px 16px; border-radius: 999px; border: 0; background: none; color: var(--muted); font-weight: 700; }
.tab.on { background: var(--red); color: #fff; }
.out-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--red-soft); color: var(--red-hi); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }
.meter { height: 4px; border-radius: 4px; background: var(--panel3); overflow: hidden; margin-bottom: 8px; }
.meter i { display: block; height: 100%; background: var(--ok); transition: width .2s; }
.meter.over i { background: var(--bad); }
#out {
  width: 100%; min-height: 220px; resize: vertical; padding: 14px; border-radius: var(--r-sm); background: var(--input);
  border: 1px solid var(--line2); font: 13.5px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text);
}
.edited { font-size: 12.5px; color: var(--warn); margin-top: 6px; }
.out-actions { margin: 12px 0 4px; align-items: center; }
.extra { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin: 10px 0; background: var(--panel2); }
.extra pre, .card pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 ui-monospace, Consolas, monospace; color: var(--text); }
.take pre { max-height: 180px; overflow: auto; }
.health { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.score { font-weight: 900; color: var(--red-hi); }
.bar { height: 6px; border-radius: 6px; background: var(--panel3); overflow: hidden; margin-bottom: 10px; }
.bar i { display: block; height: 100%; transition: width .25s; }
.bar i.hi { background: var(--ok); } .bar i.mid { background: var(--warn); } .bar i.lo { background: var(--bad); }
#checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
#checks li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13.5px; }
#checks li .ic { width: 15px; height: 15px; position: relative; top: 2px; }
#checks li.ok .ic { color: var(--ok); }
#checks li.todo .ic { color: var(--red-hi); }
#checks em { flex-basis: 100%; padding-left: 23px; font-style: normal; font-size: 12.5px; color: var(--muted); }
.empty { padding: 24px; border: 1px dashed var(--line2); border-radius: var(--r); color: var(--muted); grid-column: 1 / -1; }
.empty b { color: var(--text); display: block; margin-bottom: 6px; }
.empty p { margin-top: 6px; }
.mobile-bar { display: none; }

/* ---------- cards (templates, library) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-top: 14px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line); border-top: 3px solid var(--mc); min-width: 0; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-top > .ic { color: var(--mc); }
.card-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { font-size: 12px; color: var(--muted); }
.card pre { max-height: 130px; overflow: hidden; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; align-items: center; }
.card-actions .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.fav.on { color: var(--warn); }
.fav.on .ic { fill: currentColor; }
.stars { display: flex; gap: 2px; }
.stars button { background: none; border: 0; padding: 0 2px; font-size: 17px; color: var(--line2); line-height: 1; }
.stars button.on { color: var(--warn); }
.tag-filter { margin-top: 4px; }
.lib-tools { align-items: center; }

/* ---------- doctor / convert ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.split textarea { min-height: 220px; font: 13.5px/1.55 ui-monospace, Consolas, monospace; }
.report-top { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; flex: none; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--panel3) 0); }
.ring b { width: 68px; height: 68px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-size: 24px; font-weight: 900; }
.ring.hi { --c: var(--ok); } .ring.mid { --c: var(--warn); } .ring.lo { --c: var(--bad); }
#dReport h3 { font-size: 14px; margin: 14px 0 8px; }
.issues, .goods { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.issues li { padding: 10px 12px; border-radius: var(--r-sm); background: var(--panel2); border-left: 3px solid var(--bad); font-size: 13.5px; }
.issues.miss li { border-left-color: var(--warn); }
.issues em { display: block; font-style: normal; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.goods li { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.goods .ic { color: var(--ok); width: 15px; height: 15px; }

/* ---------- modal / palette / toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px 20px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 4px 20px 8px; display: grid; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.radio-row { display: grid; gap: 8px; }
.radio-row label { display: flex; gap: 8px; align-items: baseline; }
.radio-row input { accent-color: var(--red); }
.palette-back { place-items: start center; padding-top: 12vh; }
.palette { width: min(620px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.palette input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 16px; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette li { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.palette li.on, .palette li:hover { background: var(--red-soft); color: var(--text); }
.palette-foot { padding: 8px 14px; border-top: 1px solid var(--line); }
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 300; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-weight: 700; box-shadow: var(--shadow); transition: .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--red); font-weight: 900; padding: 0; }
@keyframes fade { from { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .modes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .build, .split { grid-template-columns: 1fr; }
  .output { position: static; max-height: none; }
  .views .view-btn span { display: none; }
  .views .view-btn { padding: 9px 11px; }
  .mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 8px; padding: 10px max(16px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  .mobile-bar .btn { flex: 1; }
  #toast { bottom: 84px; }
}
@media (max-width: 640px) {
  .top { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand span, .hide-sm { display: none; }
  .brand img { width: 38px; height: 38px; }
  .views { margin: 0; flex: 1; justify-content: center; }
  .view-btn { padding: 8px 9px; }
  .modes { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .mode { padding: 9px 4px; font-size: 12px; }
  .fields { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .panel-head h1 { font-size: 19px; }
  .out-actions .btn:not(.primary) span { display: none; }
  .out-actions .btn.primary { flex: 1 1 100%; }
  .cards { grid-template-columns: 1fr; }
  .row > select { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* mode accent colors (kept here so the strict security policy needs no inline styles) */
.m-image { --mc: #ff3b3b; }
.m-video { --mc: #ff7a2f; }
.m-music { --mc: #ff3d8b; }
.m-chat { --mc: #ffb02e; }
.m-code { --mc: #c9ccd6; }
.m-marketing { --mc: #ff5f45; }
.m-character { --mc: #b86bff; }
.m-voice { --mc: #3fb5ff; }

/* owner login (testing only) */
.gate { max-width: 360px; margin: 10vh auto; padding: 28px; display: grid; gap: 14px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.gate img { margin: 0 auto; filter: drop-shadow(0 0 14px rgba(255, 45, 58, .35)); }
.gate h1 { font-size: 22px; } .gate p { color: var(--muted); }
.gate .field { text-align: left; }
.gate-err { color: var(--bad) !important; min-height: 1.2em; }
.gate-soon { margin: 0 auto; padding: 5px 14px; border: 1px solid var(--red); border-radius: 999px; color: var(--red-hi); font-weight: 800; letter-spacing: .2em; font-size: 12px; }
.gate-ref { display: block; margin-top: 6px; word-break: break-all; user-select: all; font-size: 12px; color: var(--text); }
