:root {
  --brand: #0B7A4B; --brand-soft: rgba(11,122,75,.1);
  --ink: rgba(0,0,0,.9); --ink-2: #565656; --ink-3: #8b8b8b;
  --bg: #f7f7f7; --surface: #fff; --line: #e7e7e7; --line-2: #d9d9d9;
  --danger: #C8102E; --warn: #8a6100; --warn-bg: #fff4d6;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
/* Follows the browser's light/dark setting. */
@media (prefers-color-scheme: dark) {
  :root { --brand: #3fb67c; --brand-soft: rgba(63,182,124,.14); --ink: rgba(255,255,255,.9); --ink-2: #b3b3b3; --ink-3: #8b8b8b;
          --bg: #0f1110; --surface: #171918; --line: #2a2d2b; --line-2: #3a3d3b; --warn: #e6b450; --warn-bg: rgba(230,180,80,.12); }
  .btn:hover, .finding:hover { background: #202321 !important; }
  .msg.err { background: rgba(200,16,46,.15) !important; }
  .pill.high, .finding .sev.high { background: rgba(200,16,46,.18) !important; }
  .paysheet { background: #1a1c1b !important; color: rgba(255,255,255,.9) !important; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--ink-3); font-size: 12px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 16px; }
.brand svg { display: block; }
.word span { color: var(--ink-3); font-weight: 400; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.app-id { flex: 1; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }

a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 7px 14px; min-height: 34px; font-weight: 500; transition: opacity .2s ease, background .2s ease; }
.btn:hover { background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { opacity: .92; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; font-size: 16px; color: var(--ink-2); }
.icon:hover { background: var(--bg); }

.studio { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 340px) minmax(360px, 1fr) minmax(400px, 440px); }
.pane { min-height: 0; display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); background: var(--surface); }
.pane.sim { background: var(--bg); border: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 50px; }
.pane-head h2 { margin: 0; font-size: 14px; font-weight: 500; flex: 1; }

/* designer */
.chat { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.sys { color: var(--ink-2); background: var(--bg); }
.msg.me { background: var(--brand); color: #fff; align-self: flex-end; max-width: 90%; }
.msg.ai { background: var(--bg); border: 1px solid var(--line); }
.msg.err { background: #fdecee; color: var(--danger); }
.msg .chg { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.ideas { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.ideas button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--ink-2); }
.ask { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.ask textarea { resize: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; font: 13px/1.5 var(--font); }
.ask textarea:focus, #code:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.thinking { display: flex; gap: 4px; padding: 12px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: show 1.3s ease infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes show { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* editor */
.files { flex: 1; display: flex; gap: 2px; overflow-x: auto; }
.files button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font-size: 12px; color: var(--ink-2); white-space: nowrap; font-family: var(--mono); }
.files button.on { background: var(--bg); color: var(--ink); }
.files button .rm { margin-inline-start: 6px; color: var(--ink-3); }
#code { flex: 1; border: 0; resize: none; padding: 14px 16px; font: 12.5px/1.6 var(--mono); color: var(--ink); tab-size: 2; white-space: pre; overflow: auto; }
.status { padding: 6px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); display: flex; gap: 12px; }
.status .bad { color: var(--danger); } .status .warn { color: var(--warn); } .status .ok { color: var(--brand); }

/* simulator */
.seg { display: flex; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: 12px; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #fff; }
.phone-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px; }
/* Scales to the space available, keeping a phone's proportions. */
.phone { position: relative; height: min(720px, 100%); aspect-ratio: 1 / 2; min-height: 480px; border-radius: 36px; background: #111; padding: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.phone > * { flex: none; }
.statusbar, .navbar { background: #fff; color: #111; }
.phone.dark .statusbar, .phone.dark .navbar { background: #1a1c1b; color: #e3e3df; }
.statusbar { display: flex; justify-content: space-between; padding: 8px 22px 2px; font-size: 12px; font-weight: 600; border-radius: 26px 26px 0 0; }
.navbar { display: grid; grid-template-columns: 40px 1fr 88px; align-items: center; height: 44px; padding: 0 8px; border-bottom: 1px solid rgba(0,0,0,.06); }
.nav-back { font-size: 26px; line-height: 1; padding-inline-start: 6px; }
.nav-title { text-align: center; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capsule { justify-self: end; display: flex; align-items: center; gap: 0; height: 30px; border: 1px solid rgba(128,128,128,.35); border-radius: 15px; padding: 0 10px; }
.capsule i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; box-shadow: 6px 0 0 currentColor, -6px 0 0 currentColor; margin: 0 8px; }
.capsule b { width: 1px; height: 16px; background: rgba(128,128,128,.35); margin: 0 8px; }
.capsule i.x { box-shadow: none; width: 10px; height: 10px; border-radius: 50%; background: transparent; border: 2px solid currentColor; }
#frame { flex: 1; width: 100%; border: 0; background: #fff; border-radius: 0 0 26px 26px; }
.phone.dark #frame { background: #101211; }
.toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 240px; padding: 12px 18px; border-radius: 8px; background: rgba(30,30,30,.9); color: #fff; font-size: 14px; text-align: center; animation: show .3s ease; }
.sheet-bg { position: absolute; inset: 10px; border-radius: 26px; background: rgba(0,0,0,.45); }
.paysheet { position: absolute; left: 10px; right: 10px; bottom: 10px; background: #fff; color: #111; border-radius: 16px 16px 26px 26px; padding: 10px 18px 18px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.paysheet .grip { width: 36px; height: 4px; border-radius: 2px; background: #ddd; margin: 0 auto 6px; }
.pay-app { font-size: 13px; color: var(--ink-2); }
.pay-amt { font-size: 32px; font-weight: 600; }
.pay-desc { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.pay-method { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.console { height: 150px; overflow: auto; border-top: 1px solid var(--line); background: var(--surface); font: 11.5px/1.5 var(--mono); padding: 8px 12px; }
.console div { white-space: pre-wrap; overflow-wrap: anywhere; }
.console .call { color: var(--ink-2); } .console .error { color: var(--danger); } .console .warn { color: var(--warn); } .console .info { color: var(--brand); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.06); display: flex; flex-direction: column; z-index: 10; animation: show .2s ease; }
.drawer-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 500; }
#drawerBody { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.summary { display: flex; gap: 8px; }
.pill { padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 500; background: var(--bg); }
.pill.high { background: #fdecee; color: var(--danger); } .pill.medium { background: var(--warn-bg); color: var(--warn); } .pill.ok { background: var(--brand-soft); color: var(--brand); }
.finding { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.finding:hover { background: #fafafa; }
.finding .sev { flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; }
.finding .sev.high { background: #fdecee; color: var(--danger); } .finding .sev.medium { background: var(--warn-bg); color: var(--warn); } .finding .sev.low { background: var(--bg); color: var(--ink-2); }
.finding .where { font: 11px var(--mono); color: var(--ink-3); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 500; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--ink-3); }
code, .mono { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; grid-auto-rows: minmax(420px, auto); overflow: auto; }
  .pane { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .phone { height: 640px; }
  .phone-wrap { min-height: 680px; }
}
