*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f2f0ee;
  --surface: #fff;
  --surface2: #ebe9e5;
  --border: rgba(0,0,0,0.10);
  --border-med: rgba(0,0,0,0.17);
  --border-strong: rgba(0,0,0,0.27);
  --text: #1c1917;
  --text-muted: #6b6560;
  --text-faint: #a09a95;
  --accent: #c0392b;
  --accent-light: #fdf0ee;
  --accent-text: #922b21;
  --green: #0f766e;
  --green-light: #f0fdf9;
  --amber: #b45309;
  --amber-light: #fffbeb;
  --indigo: #4f46e5;
  --indigo-light: #eef2ff;
  --indigo-text: #3730a3;
  --violet: #7c3aed;
  --violet-light: #f5f3ff;
  --r: 7px;
  --r-lg: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1614; --surface: #242120; --surface2: #2c2a27;
    --border: rgba(255,255,255,0.08); --border-med: rgba(255,255,255,0.14); --border-strong: rgba(255,255,255,0.23);
    --text: #ede8e3; --text-muted: #9a928a; --text-faint: #625a54;
    --accent: #e05444; --accent-light: #3d1a16; --accent-text: #f4a79e;
    --green: #14b8a6; --green-light: #0d2926;
    --amber: #f59e0b; --amber-light: #291d00;
    --indigo: #818cf8; --indigo-light: #1e1b4b; --indigo-text: #a5b4fc;
    --violet: #a78bfa; --violet-light: #241b3d;
  }
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; line-height: 1.5; }

.hdr { background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 0 1.5rem; height: 52px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 200; }
.hdr-logo { width: 28px; height: 28px; background: var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; flex-shrink: 0; }
.hdr-title { font-size: 14px; font-weight: 500; }
.hdr-sub { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.steps { display: flex; gap: 2px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 3px; margin-bottom: 1.5rem; }
.step-btn { flex: 1; padding: 7px 10px; border: none; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer; border-radius: var(--r); display: flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; transition: background 0.12s, color 0.12s; white-space: nowrap; }
.step-btn .num { width: 17px; height: 17px; border-radius: 50%; background: var(--surface2); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; flex-shrink: 0; }
.step-btn.active { background: var(--accent); color: #fff; }
.step-btn.active .num { background: rgba(255,255,255,0.22); }
.step-btn.done { color: var(--green); }
.step-btn:not(.active):hover { background: var(--surface2); color: var(--text); }

.panel { display: none; }
.panel.active { display: block; }

/* ── Step 1 ── */
.sec-title { font-size: 16px; font-weight: 500; margin-bottom: 3px; }
.sec-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 1.1rem; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 1.25rem; }
.model-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 20px 16px 18px; cursor: pointer; transition: border-color 0.12s, transform 0.08s; position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.model-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.model-card:active { transform: translateY(0); }
.model-card.sel { border: 2px solid var(--accent); background: var(--accent-light); }
.model-card.sel::after { content: ''; position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/12px no-repeat; border-radius: 50%; }
.mc-icon { width: 100%; height: 92px; display: flex; align-items: center; justify-content: center; }
.mc-icon svg { width: 100%; height: 100%; }

/* ── Step 2: full-width phone on top, two-col below ── */
.phone-stage {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem 1rem;
  margin-bottom: 1.25rem;
}
.phone-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.phone-stage-bar h2 { font-size: 13px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.page-tabs { display: flex; gap: 4px; }
.page-tab { padding: 4px 14px; font-size: 12px; font-weight: 500; border: 0.5px solid var(--border-med); border-radius: 5px; background: var(--surface2); color: var(--text-muted); cursor: pointer; font-family: inherit; transition: all 0.1s; }
.page-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* SVG is rendered full-width via a viewBox — container just sets width */
#phone-svg-wrap { width: 100%; }
#phone-svg-wrap svg { width: 100%; height: auto; display: block; }

/* ── Bottom two-col ── */
.bottom-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ── Editor panel ── */
.editor-panel {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.editor-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.editor-empty i { font-size: 28px; display: block; margin-bottom: 8px; }

.key-editor-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface2);
  border-bottom: 0.5px solid var(--border);
}
.key-num-badge {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.key-editor-hdr h3 { font-size: 13px; font-weight: 500; flex: 1; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); font-size: 18px; padding: 2px; line-height: 1; }
.close-btn:hover { color: var(--text); }
.key-editor-body { padding: 16px; }

.type-pills { display: flex; gap: 8px; margin-bottom: 14px; }
.type-pill {
  flex: 1; padding: 10px 8px; border: 0.5px solid var(--border-med);
  border-radius: var(--r); background: var(--surface2);
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; text-align: center; font-family: inherit; transition: all 0.12s;
}
.type-pill:hover { border-color: var(--accent); color: var(--accent); }
.type-pill.active-blf  { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.type-pill.active-park { background: var(--amber);  color: #fff; border-color: var(--amber); }
.type-pill.active-speeddial { background: var(--violet); color: #fff; border-color: var(--violet); }
.type-pill.pill-clear { flex: 0 0 42px; color: var(--text-faint); font-size: 13px; }

.field-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-row label { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.field-row input, .field-row select {
  padding: 8px 10px; border: 0.5px solid var(--border-med); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; width: 100%;
}
.field-row input::placeholder { color: var(--text-faint); }
.field-row input:focus, .field-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2.5px rgba(192,57,43,0.12); }
.field-row select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }

/* ── Key list panel ── */
.keylist-panel {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.keylist-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 0.5px solid var(--border);
}
.keylist-hdr .lbl { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); flex: 1; }
.keylist-body { padding: 6px; display: flex; flex-direction: column; gap: 3px; }

.kli {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r);
  cursor: pointer; transition: background 0.1s;
  border: 0.5px solid transparent;
}
.kli:hover { background: var(--surface2); }
.kli.sel { background: var(--accent-light); border-color: var(--accent); }
.kli.cfg-blf  { background: var(--indigo-light); border-color: var(--indigo); }
.kli.cfg-park { background: var(--amber-light); border-color: var(--amber); }
.kli.cfg-speeddial { background: var(--violet-light); border-color: var(--violet); }
.kli.cfg-adv  { background: var(--green-light); border-color: var(--green); }
.kli.page-key { opacity: 0.35; pointer-events: none; }

.kli-num {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--surface2); border: 0.5px solid var(--border-med);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0;
}
.kli-num.blf  { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.kli-num.park { background: var(--amber); border-color: var(--amber); color: #fff; }
.kli-num.speeddial { background: var(--violet); border-color: var(--violet); color: #fff; }
.kli-num.adv  { background: var(--green); border-color: var(--green); color: #fff; }
.kli-info { flex: 1; min-width: 0; }
.kli-type  { font-size: 10px; color: var(--text-muted); }
.kli-name  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kli-ext   { font-size: 11px; color: var(--text-muted); }
.kli-empty { font-size: 12px; color: var(--text-faint); font-style: italic; }
.kli-chevron { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }

/* ── Hints & warnings ── */
.hint-box { border-radius: var(--r); padding: 9px 12px; font-size: 12px; display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.hint-box.info { background: var(--accent-light); border: 0.5px solid rgba(192,57,43,0.18); color: var(--accent-text); }
.hint-box.warn { background: var(--amber-light); border: 0.5px solid rgba(180,83,9,0.2); color: var(--amber); }

.view-tabs { display:flex; gap:3px; background:var(--surface2); border-radius:var(--r); padding:3px; }
.view-tab { padding:5px 12px; font-size:12px; font-weight:500; border:none; background:transparent; color:var(--text-muted); cursor:pointer; border-radius:5px; font-family:inherit; transition:all 0.12s; white-space:nowrap; }
.view-tab.active { background:var(--surface); color:var(--text); box-shadow:0 0 0 0.5px var(--border-med); }
.view-tab.exp-tab { position:relative; }

.exp-count-badge { position:absolute; top:-4px; right:-4px; width:14px; height:14px; border-radius:50%; background:var(--accent); color:#fff; font-size:9px; font-weight:600; display:flex; align-items:center; justify-content:center; }
.mode-btn { padding: 5px 12px; font-size: 12px; font-weight: 500; border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 5px; font-family: inherit; transition: all 0.12s; }
.mode-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 0.5px var(--border-med); }

/* ── Misc ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0.5px solid var(--border-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: background 0.1s, transform 0.08s; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #1a3fa0; border-color: #1a3fa0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.progress-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--surface2); border-radius: 20px; font-size: 12px; color: var(--text-muted); }
.progress-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Step 3 */
.output-box { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 1.25rem; }
.output-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface2); border-bottom: 0.5px solid var(--border); }
.output-toolbar .lbl { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); flex: 1; }
.output-code { font-family: 'SF Mono','Fira Mono','Consolas',monospace; font-size: 12px; line-height: 1.75; padding: 1rem 1.25rem; white-space: pre; overflow-x: auto; min-height: 140px; }
.oc-comment { color: var(--text-faint); } .oc-key { color: var(--accent); } .oc-val { color: var(--green); }

.email-form { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 1.1rem 1.25rem; }
.frow { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.frow label { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.frow input, .frow textarea { padding: 7px 9px; border: 0.5px solid var(--border-med); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; width: 100%; }
.frow textarea { min-height: 72px; resize: vertical; }
.frow input:focus, .frow textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2.5px rgba(192,57,43,0.12); }
.frow input[readonly] { background: var(--surface2); color: var(--text-muted); cursor: not-allowed; }

.toast { position: fixed; bottom: 1.25rem; right: 1.25rem; background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: var(--r); font-size: 13px; font-weight: 500; z-index: 999; opacity: 0; transform: translateY(6px); transition: all 0.18s; pointer-events: none; display: flex; align-items: center; gap: 7px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 640px) { .bottom-cols { grid-template-columns: 1fr; } }
