:root {
  --rail: #1b1b1b; --panel: #232323; --row: #2e2e2e; --row-line: #3a3a3a; --ink: #f1f1f1; --muted: #a2a2a2;
  --accent: #3b8cff; --ok: #19b35c; --danger: #e5484d; --page: #f4f5f7; --card: #fff; --line: #e3e5e8; --text: #16181c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

.btn { min-height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.btn:hover { border-color: #b8bcc3; }
.btn--primary { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn--primary:disabled { opacity: .5; cursor: default; }
.btn--danger { color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 6px; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea { min-height: 40px; padding: 8px 12px; border: 1px solid #c9ced5; border-radius: 8px; background: #fff; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 0; }

/* dashboard */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.top strong { font-size: 17px; }
.dash { max-width: 1040px; margin: 0 auto; padding: 28px 24px 60px; display: flex; flex-direction: column; gap: 28px; }
.dash h2 { margin: 0 0 12px; font-size: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.tile h3 { margin: 0; font-size: 16px; }
.tile .hint { color: #6b7280; font-size: 13px; }
.tile .row-actions { display: flex; gap: 8px; margin-top: auto; }
.tile--new { border-style: dashed; align-items: flex-start; justify-content: center; cursor: pointer; }
.box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.steps { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: #f1f2f4; padding: 2px 6px; border-radius: 5px; }

/* editor shell */
.editor { display: grid; grid-template-columns: 84px 360px 1fr; grid-template-rows: 60px 1fr; height: 100vh; }
.ebar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.ebar input.name { border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 16px; padding: 6px 8px; border-radius: 6px; min-width: 0; width: 280px; }
.ebar input.name:hover, .ebar input.name:focus { border-color: var(--line); }
.ebar .spacer { flex: 1; }
.ebar .state { font-size: 13px; color: #6b7280; }
.rail { background: var(--rail); display: flex; flex-direction: column; padding-top: 8px; }
.rail button { background: none; border: 0; color: var(--muted); padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; cursor: pointer; }
.rail button svg { width: 24px; height: 24px; }
.rail button[aria-current="true"] { color: #fff; background: #2b2b2b; }
.panel { background: var(--panel); color: var(--ink); overflow-y: auto; padding: 18px 18px 60px; }
.panel h2 { margin: 4px 0 18px; text-align: center; font-weight: 500; font-size: 18px; }
.group { background: var(--row); border-radius: 10px; margin-bottom: 18px; overflow: hidden; }
.group-title { padding: 14px 16px 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; min-height: 52px; }
.prow + .prow { border-top: 1px solid var(--row-line); }
.prow label, .prow .lbl { font-size: 15px; }
.prow select, .prow input[type="text"], .prow input[type="number"] { background: transparent; border: 0; color: var(--accent); text-align: right; font-size: 15px; max-width: 170px; }
.prow select option { color: #111; }
.prow input[type="text"] { color: var(--ink); background: #262626; border: 1px solid var(--row-line); border-radius: 6px; padding: 6px 8px; text-align: left; max-width: 190px; }
.prow input[type="range"] { accent-color: var(--accent); width: 140px; }
.prow input[type="color"] { width: 34px; height: 34px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.prow textarea { width: 100%; min-height: 140px; background: #1b1b1b; color: var(--ink); border: 1px solid var(--row-line); border-radius: 8px; padding: 10px; font: 13px ui-monospace, Menlo, monospace; }
.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #5a5a5a; border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(22px); }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px; }
.choices--3 { grid-template-columns: repeat(3, 1fr); }
.choice { background: #3a3a3a; border: 2px solid transparent; border-radius: 10px; padding: 12px 8px 8px; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; }
.choice[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.choice .pic { width: 100%; height: 58px; border-radius: 6px; display: grid; gap: 4px; padding: 6px; }
.choice .pic i { display: block; border-radius: 3px; }
.reviews-list .item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.reviews-list .item + .item { border-top: 1px solid var(--row-line); }
.reviews-list .item.off { opacity: .45; }
.reviews-list .who { flex: 1; min-width: 0; }
.reviews-list .who b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reviews-list .who span { font-size: 12.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reviews-list .rating { color: #4cd38a; font-size: 13px; white-space: nowrap; }
.eye { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.eye:hover { color: #fff; background: #3a3a3a; }
.search { width: 100%; margin: 0 0 10px; background: #1b1b1b; border: 1px solid var(--row-line); border-radius: 8px; padding: 9px 12px; color: var(--ink); }
.note { color: var(--muted); font-size: 13px; padding: 0 4px 12px; }

/* preview */
.stage { overflow: auto; background: #fff; position: relative; display: flex; flex-direction: column; }
.stage-bar { display: flex; justify-content: flex-end; gap: 4px; padding: 10px 14px; }
.stage-bar button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; color: #6b7280; }
.stage-bar button[aria-pressed="true"] { color: var(--text); border-color: #9aa0a8; }
.frame { margin: 0 auto; width: 100%; padding: 30px 32px 60px; transition: max-width .2s; }
.frame.mobile { max-width: 390px; padding: 20px 12px; border: 1px solid var(--line); border-radius: 22px; margin-top: 10px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal .box { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 14px; }
.modal pre { margin: 0; background: #16181c; color: #e8eaed; padding: 16px; border-radius: 10px; font: 13px/1.6 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #16181c; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .editor { grid-template-columns: 64px 1fr; grid-template-rows: 60px auto 1fr; height: auto; min-height: 100vh; }
  .panel { grid-column: 2; max-height: 55vh; }
  .stage { grid-column: 1 / -1; }
  .rail button { font-size: 10px; }
}
