/* ──────────────────────────────────────────────────────────────
   DXM Prompt Lab — theme tokens + base styles
   Each .theme-* scope defines its own palette via CSS custom props.
   All component styles read these vars, so the same markup
   re-skins itself by changing the parent class.
   ────────────────────────────────────────────────────────────── */

.dxm {
  --leading-tight: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
}

/* ── Dark (softened — not too dark) ───────────────────────────── */
.theme-dark {
  --bg-base:        #1e2024;
  --bg-card:        #262930;
  --bg-hover:       #2d3038;
  --bg-elevated:    #2f323a;
  --bg-input:       #24272d;
  --border:         #3a3d44;
  --border-strong:  #4a4d55;
  --text-primary:   #e4e6ea;
  --text-secondary: #9aa0a8;
  --text-tertiary:  #6b7079;
  --accent:         #5aa3ff;
  --accent-dim:     rgba(90,163,255,.18);
  --accent-text:    #ffffff;
  --success:        #5ee089;
  --warning:        #fbbf24;
  --danger:         #f87171;
  --code-bg:        #2a2d34;
  --code-text:      #e4e6ea;

  --font-sans:        "SF Pro Text", -apple-system, "Inter", "PingFang SC", system-ui, sans-serif;
  --font-display:     "SF Pro Display", -apple-system, "Inter", "PingFang SC", system-ui, sans-serif;
  --font-mono:        "SF Mono", "JetBrains Mono", "Menlo", monospace;
  --font-choice-lbl:  "JetBrains Mono", "SF Mono", monospace;
  --font-choice-txt:  "SF Pro Text", "PingFang SC", sans-serif;
  --font-msg:         "SF Pro Text", "PingFang SC", sans-serif;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
}

/* ── Parchment ─────────────────────────────────────────────────── */
.theme-parchment {
  --bg-base:        #f5ebd6;
  --bg-card:        #ebe1cc;
  --bg-hover:       #e1d6bb;
  --bg-elevated:    #ede3ce;
  --bg-input:       #f0e5cd;
  --border:         #d4c5a3;
  --border-strong:  #b5996e;
  --text-primary:   #2a1f15;
  --text-secondary: #7a6951;
  --text-tertiary:  #a89377;
  --accent:         #a64b2a;
  --accent-dim:     rgba(166,75,42,.14);
  --accent-text:    #fefaf0;
  --success:        #5a7d3e;
  --warning:        #b8801f;
  --danger:         #8b2c2c;
  --code-bg:        #ddd0b0;
  --code-text:      #2a1f15;

  --font-sans:        "Source Han Serif SC", "Songti SC", "Georgia", "Garamond", serif;
  --font-display:     "Source Han Serif SC", "Songti SC", "Playfair Display", "Garamond", serif;
  --font-mono:        "Courier Prime", "Courier New", "Source Han Serif SC", monospace;
  --font-choice-lbl:  "Courier Prime", "Courier New", monospace;
  --font-choice-txt:  "Garamond", "Source Han Serif SC", "Newsreader", serif;
  --font-msg:         "Newsreader", "Garamond", "Source Han Serif SC", serif;

  --radius-sm: 2px;
  --radius:    4px;
  --radius-lg: 6px;
}

/* ── Light Clean (softened — not too bright) ──────────────────── */
.theme-light {
  --bg-base:        #ecedef;
  --bg-card:        #e3e4e7;
  --bg-hover:       #dadbdf;
  --bg-elevated:    #e8e9ec;
  --bg-input:       #e7e8eb;
  --border:         #cdced2;
  --border-strong:  #b6b7bc;
  --text-primary:   #2a2c30;
  --text-secondary: #62656b;
  --text-tertiary:  #8a8d93;
  --accent:         #3b6fd9;
  --accent-dim:     rgba(59,111,217,.13);
  --accent-text:    #ffffff;
  --success:        #2f9152;
  --warning:        #d97316;
  --danger:         #c83434;
  --code-bg:        #dedfe2;
  --code-text:      #2a2c30;

  --font-sans:        "SF Pro Text", -apple-system, "Inter", "PingFang SC", system-ui, sans-serif;
  --font-display:     "SF Pro Display", -apple-system, "Inter", "PingFang SC", system-ui, sans-serif;
  --font-mono:        "SF Mono", "JetBrains Mono", Menlo, monospace;
  --font-choice-lbl:  "JetBrains Mono", monospace;
  --font-choice-txt:  "SF Pro Text", "PingFang SC", sans-serif;
  --font-msg:         "SF Pro Text", "PingFang SC", sans-serif;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
}

/* ── Base layout (phone container) ─────────────────────────────── */
.dxm {
  width: 100%;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* When inside an iOS device frame: leave room for status bar + home indicator */
.dxm.ios-safe {
  padding-top: 54px;
  padding-bottom: 30px;
}
/* When in unrolled (scroll-unfurled) mode for review: cap nothing, let content
   determine height. Used for the long Settings artboards. */
.dxm.unrolled {
  height: auto;
  min-height: 100%;
  overflow: visible;
}
.dxm.unrolled .settings { overflow: visible; }
.dxm * { box-sizing: border-box; }
.dxm button { font: inherit; color: inherit; }

/* ── App status bar (top) ──────────────────────────────────────── */
.appbar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  background: var(--bg-base);
}
.appbar .title-col {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.appbar .title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar .subtitle {
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  margin-top: 1px;
}
.appbar .iconbtn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-secondary);
}
.appbar .iconbtn:hover { background: var(--bg-hover); color: var(--text-primary); }
.appbar .iconbtn svg { width: 16px; height: 16px; }

/* Metrics line below title — tiny chips */
.metrics {
  flex-shrink: 0;
  padding: 0 14px 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}
.metrics .pill {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--text-secondary);
  letter-spacing: .02em;
}
.metrics .pill.accent { color: var(--accent); border-color: var(--accent-dim); }
.metrics .sep { color: var(--text-tertiary); opacity: .5; }
.metrics .grow { flex: 1; }

/* ── Bottom tab bar ────────────────────────────────────────────── */
.tabbar {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
  padding: 6px 0 8px;
}
.tabbar button {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  position: relative;
  cursor: pointer;
}
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -8px; left: 30%; right: 30%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.tabbar svg { width: 18px; height: 18px; }
.tabbar .badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* ── Chat ──────────────────────────────────────────────────────── */
.chatscroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}
.chatscroll::-webkit-scrollbar { width: 4px; }
.chatscroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg-user {
  align-self: flex-end;
  max-width: 84%;
  background: var(--accent-dim);
  color: var(--text-primary);
  padding: 10px 13px;
  border-radius: var(--radius);
  font-family: var(--font-msg);
  font-size: 14px;
  line-height: var(--leading-relaxed);
  border: 1px solid transparent;
}
.theme-parchment .msg-user {
  border-color: var(--border);
  background: var(--bg-card);
}

.msg-assistant {
  align-self: stretch;
  font-family: var(--font-msg);
  font-size: 14px;
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}
.theme-parchment .msg-assistant {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}
.msg-assistant .speaker {
  font-family: var(--font-choice-lbl);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
  font-weight: 600;
}
.msg-assistant p { margin: 0 0 8px; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant strong { font-weight: 600; color: var(--text-primary); }
.msg-assistant em { font-style: italic; color: var(--text-secondary); }
.msg-assistant code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.msg-assistant pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border);
}

/* Streaming cursor */
.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 1.2s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Loading dots (single-char animation) */
.loading {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-size: 14px;
}
.loading::after {
  content: "···";
  display: inline-block;
  animation: dots 1.4s steps(4) infinite;
  overflow: hidden;
  width: 1ch;
  vertical-align: bottom;
  white-space: nowrap;
}
@keyframes dots {
  0%   { width: 0; }
  33%  { width: 1ch; }
  66%  { width: 2ch; }
  100% { width: 3ch; }
}

/* Per-message meta line */
.msg-meta {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.msg-meta .sep { opacity: .4; }
.msg-meta .ratebtn {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 3px;
  opacity: .55;
  transition: opacity .12s;
}
.msg-meta .ratebtn:hover { opacity: 1; color: var(--text-primary); background: var(--bg-hover); }

/* ── Choice cards ──────────────────────────────────────────────── */
.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.choice {
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .2s;
}
.choice:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.choice .lbl {
  flex-shrink: 0;
  width: 76px;
  font-family: var(--font-choice-lbl);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.theme-parchment .choice .lbl { letter-spacing: .15em; }
.choice .txt {
  flex: 1;
  font-family: var(--font-choice-txt);
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}
.theme-parchment .choice .txt { font-style: italic; }
.choice[data-used="picked"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  opacity: .8;
}
.choice[data-used="used"] {
  opacity: .42;
  border-style: dashed;
  cursor: not-allowed;
}

/* ── Composer ──────────────────────────────────────────────────── */
.composer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
  padding: 8px 12px 10px;
}
.debug-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  overflow: hidden;
  white-space: nowrap;
}
.debug-dots {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.debug-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: block;
}
.debug-dots i.off { background: var(--border-strong); }
.debug-row .chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.debug-row .chip.mode-chip { color: var(--accent); border-color: var(--accent-dim); }

.composer .input-shell {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 12px;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: var(--leading-normal);
  min-height: 22px;
  max-height: 160px;
}
.composer textarea::placeholder { color: var(--text-tertiary); }
.composer .sendbtn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.composer .sendbtn svg { width: 14px; height: 14px; }
.composer .sendbtn:disabled { background: var(--border-strong); cursor: not-allowed; }

/* ── Theme dropdown ────────────────────────────────────────────── */
.theme-menu {
  position: absolute;
  top: 100%;
  right: 8px;
  margin-top: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 180px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.theme-light .theme-menu, .theme-parchment .theme-menu {
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.theme-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
}
.theme-menu button:hover { background: var(--bg-hover); }
.theme-menu .dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
}
.theme-menu .dot.on { background: var(--accent); border-color: var(--accent); }

/* ── Settings (Settings tab) ───────────────────────────────────── */
.settings {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  font-size: 13px;
}
.set-group {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 18px;
}
.set-group > h3 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.set-group > h3 .help {
  font-family: var(--font-sans);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-tertiary);
  font-weight: normal;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.set-row:last-child { margin-bottom: 0; }
.set-row .label {
  flex-shrink: 0;
  width: 72px;
  font-size: 12px;
  color: var(--text-secondary);
}
.set-row .value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  text-align: right;
}
.set-row .help-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 9px;
  color: var(--text-tertiary);
  cursor: help;
}

.slider {
  position: relative;
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
}
.slider-track {
  height: 3px;
  width: 100%;
  background: var(--border);
  border-radius: 2px;
  position: relative;
}
.slider-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 2px;
}
.slider-thumb {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px var(--bg-base);
}

.segment {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.segment button {
  flex: 1;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: .05em;
}
.segment button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.dropdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text-primary);
  flex: 1;
}
.dropdown.with-tag {
  gap: 8px;
}
.dropdown .tag {
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}

.model-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  padding-left: 4px;
  margin-top: 4px;
  margin-bottom: 10px;
}

/* Variables table */
.vars-row {
  display: flex;
  gap: 4px;
  align-items: center;
  border-top: 1px dashed var(--border);
  padding: 6px 0;
}
.vars-row:first-of-type { border-top: 0; padding-top: 0; }
.vars-row .k {
  width: 150px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: -0.1px;
  color: var(--accent);
  min-width: 0;
}
.vars-row .v {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 11px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vars-row .help {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  cursor: help;
  display: grid;
  place-items: center;
  font-size: 9px;
  padding: 0;
}
.vars-row .help:hover { color: var(--accent); border-color: var(--accent); }
.vars-row .x {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  display: grid; place-items: center;
}
.vars-row .x:hover { background: var(--bg-hover); color: var(--danger); }

.add-btn {
  margin-top: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Block cards */
.block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  margin-bottom: 8px;
  overflow: hidden;
  transition: opacity .15s;
}
.block.disabled { opacity: .42; }
.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  cursor: pointer;
}
.block-check {
  width: 14px; height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--bg-base);
}
.block-check.on {
  background: var(--accent);
  border-color: var(--accent);
}
.block-check.on::after {
  content: "";
  width: 4px; height: 8px;
  border-right: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: rotate(45deg) translate(-1px, -1px);
}
.block-grip {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: grab;
  flex-shrink: 0;
  line-height: 1;
}
.block-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.block-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.block-name .en {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 6px;
  font-weight: normal;
}
.block-tok {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.block-arrow {
  color: var(--text-tertiary);
  font-size: 10px;
  flex-shrink: 0;
  transition: transform .15s;
}
.block.open .block-arrow { transform: rotate(90deg); }

.block-body {
  padding: 0 10px 12px;
  border-top: 1px solid var(--border);
}
.block-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  margin-top: 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 120px;
  outline: none;
}
.block-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  gap: 8px;
  flex-wrap: wrap;
}
.block-foot .trigger {
  display: flex;
  gap: 6px;
  align-items: center;
}
.block-foot .trigger-sel {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 7px 1px 6px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* Interaction mode */
.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 0;
  cursor: pointer;
  border-top: 1px dashed var(--border);
}
.radio-row:first-of-type { border-top: 0; padding-top: 0; }
.radio-circle {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.radio-circle.on {
  border-color: var(--accent);
}
.radio-circle.on::after {
  content: "";
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.radio-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.radio-label .hint {
  font-weight: normal;
  color: var(--text-tertiary);
  font-size: 11.5px;
  margin-left: 6px;
}

.kw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kw {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 9px 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.kw .x {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  cursor: pointer;
}
.kw.add {
  border-style: dashed;
  color: var(--text-tertiary);
  cursor: pointer;
}

.subsection-h {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 14px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.subsection-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Template / appearance buttons */
.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-sans);
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
}

/* History row */
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  gap: 6px;
}
.hist-row:first-of-type { border-top: 0; padding-top: 4px; }
.hist-row .meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hist-row .ts { color: var(--text-tertiary); font-size: 10.5px; }
.hist-row .note { color: var(--text-primary); font-family: var(--font-sans); font-size: 12px; }
.hist-row .acts { display: flex; gap: 4px; flex-shrink: 0; }
.hist-row .acts button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 3px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  cursor: pointer;
  font-family: var(--font-mono);
}
.hist-row .acts button:hover { color: var(--accent); border-color: var(--accent); }

/* Save bar (sticky bottom of settings) */
.savebar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--warning);
  z-index: 5;
}
.savebar .actions { display: flex; gap: 6px; }
.savebar .actions .btn.primary {
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .72; }
}

/* ── Gate screens ──────────────────────────────────────────────── */
.gate-blank {
  flex: 1;
  background: #fff;
  position: relative;
}
.gate-blank .hit-zone {
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  /* fully invisible in real product — outlined here only for spec visibility */
  outline: 1px dashed rgba(255, 80, 80, .55);
  outline-offset: -8px;
}
.gate-blank .spec-note {
  position: absolute;
  top: 90px;
  right: 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 9px;
  color: rgba(255,80,80,.85);
  text-align: right;
  letter-spacing: .04em;
  line-height: 1.4;
}
.gate-blank .progress {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  gap: 3px;
}
.gate-blank .progress i {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255,80,80,.7);
  /* spec visibility — also invisible in production */
}
.gate-blank .progress i.off { background: rgba(255,80,80,.18); }

.gate-pwd {
  flex: 1;
  background: var(--bg-base);
  display: grid;
  place-items: center;
  position: relative;
}
.gate-pwd .pwd-input {
  width: 220px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: .4em;
  text-align: center;
  padding: 8px 0;
}
.gate-pwd .pwd-shake {
  animation: shake .2s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.gate-pwd .pwd-arrow {
  position: absolute;
  bottom: calc(50% - 38px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* ── Runtime additions (DXM Prompt Lab production) ─────────────── */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #fff;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body { display: flex; flex-direction: column; }
#gate-blank, #gate-password, #app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Production gate-blank: no spec markings, plain white */
#gate-blank {
  background: #fff;
  position: relative;
  cursor: default;
}

/* Password gate: full screen, dark themed */
#gate-password {
  background: var(--bg-base, #1e2024);
  color: var(--text-primary, #e4e6ea);
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  align-items: center;
  justify-content: center;
}
#gate-password .pwd-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
#gate-password .pwd-input {
  width: 220px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-strong, #4a4d55);
  outline: none;
  color: var(--text-primary, #e4e6ea);
  font-family: var(--font-mono, monospace);
  font-size: 16px;
  letter-spacing: .4em;
  text-align: center;
  padding: 8px 0;
}
#gate-password .pwd-hint {
  color: var(--text-tertiary, #6b7079);
  font-size: 11px;
  letter-spacing: .14em;
}

/* App fade-in */
#app.fade-in { animation: appfade .35s ease-out; }
@keyframes appfade { from { opacity: 0; } to { opacity: 1; } }

/* Send animation (composer button press) */
.composer .sendbtn.sending { animation: send-pulse .25s ease-out; }
@keyframes send-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(.86); }
  100% { transform: scale(1); }
}

/* Tooltip (popover used by [?] dots) */
.tooltip {
  position: absolute;
  z-index: 100;
  max-width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.55;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  pointer-events: auto;
  white-space: pre-line;
}
.theme-light .tooltip, .theme-parchment .tooltip {
  box-shadow: 0 10px 24px rgba(0,0,0,.14);
}

/* Banner for transient errors / info */
.banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 64px;
  background: var(--danger, #f87171);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 200;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  animation: banner-in .2s ease-out;
}
.banner.info { background: var(--accent); }
@keyframes banner-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Settings: drag-over hint for blocks */
.block.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.block.dragging { opacity: .5; }

/* Inline editable bits (template name in settings) */
.inline-edit {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  flex: 1;
  min-width: 0;
}
.inline-edit:focus { border-color: var(--accent); }

/* Hidden file input */
.hidden-file { display: none; }

/* Empty-state placeholder in chat */
.empty-chat {
  margin: auto;
  text-align: center;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 40px 20px;
}

/* Width modifier for content readability (applied to chatscroll) */
.dxm.content-narrow .chatscroll { max-width: 640px; margin: 0 auto; width: 100%; }
.dxm.content-medium .chatscroll { max-width: 720px; margin: 0 auto; width: 100%; }
.dxm.content-narrow .settings { max-width: 640px; margin: 0 auto; width: 100%; }
.dxm.content-medium .settings { max-width: 720px; margin: 0 auto; width: 100%; }

/* Font-size modifier */
.dxm.fs-12 { font-size: 12px; }
.dxm.fs-12 .msg-user, .dxm.fs-12 .msg-assistant { font-size: 13px; }
.dxm.fs-14 { font-size: 13px; }
.dxm.fs-16 { font-size: 14px; }
.dxm.fs-16 .msg-user, .dxm.fs-16 .msg-assistant { font-size: 15px; }

/* No iOS safe-area padding when running in normal browser tab (only PWA standalone needs it). */
@media (display-mode: browser) {
  .dxm.ios-safe { padding-top: 0; padding-bottom: 0; }
}
