:root {
  color-scheme: dark;
  --bg: #101210;
  --sidebar: #141714;
  --surface: #191d19;
  --surface2: #222722;
  --surface3: #333b32;
  --border: #2c332b;
  --accent: #ccf59a;
  --accent-fg: #1c2b11;
  --text: #eef1e9;
  --text-dim: #b3bcae;
  --text-faint: #899482;
  --purple: #ccf59a;
  --success: #a9dc83;
  --danger: #f28d8b;
  --warn: #e8c77e;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button, a, input, .switch span { transition: background-color .16s, border-color .16s, color .16s, box-shadow .16s; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { opacity: .38; cursor: default; }
.icon { flex: 0 0 auto; width: 19px; height: 19px; vertical-align: middle; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #dfefc9; border-radius: 12px; background: var(--accent); color: #213117; font-size: 24px; font-weight: 750; line-height: 1; }

/* Navigation and connection status */
.panel { display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 30px 18px 22px; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 12px 48px; }
.brand-text { font-size: 21px; font-weight: 650; letter-spacing: -.8px; line-height: 1.25; }
.brand-text .sub { color: var(--text-faint); font-size: 9px; font-weight: 550; letter-spacing: 1.65px; margin-top: 4px; }
.menu-label { margin: 0 14px 12px; color: var(--text-faint); font-size: 10px; font-weight: 600; letter-spacing: 1.7px; }
.nav { display: flex; flex-direction: column; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 12px 14px; border: 1px solid transparent; border-radius: 9px; color: var(--text-dim); text-decoration: none; font-weight: 500; }
.nav-item .icon { opacity: .8; }
.nav-index { margin-left: auto; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); border-color: #465638; background: #283321; }
.nav-item.active .icon { opacity: 1; }
.nav-item.active .nav-index { color: #9eb785; }
.footer { margin-top: auto; padding: 24px 12px 0; border-top: 1px solid var(--border); }
.footer .menu-label { margin: 0 0 15px; }
.badge { display: flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.badge.small { margin-top: 10px; color: var(--text-faint); font-size: 11px; }
.dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px #a9dc8310; }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }
.dot.run { background: var(--accent); box-shadow: 0 0 0 3px #ccf59a15; }

/* Workspace */
.content { width: 100%; max-width: 1520px; min-width: 0; padding: 0 44px 132px; margin: 0 auto; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); }
.breadcrumb { color: var(--text-faint); font-size: 12px; }
.breadcrumb span { margin: 0 12px; color: #53604d; }
.breadcrumb strong { font-weight: 500; color: var(--text-dim); }
.live-note { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-faint); }
.live-note .icon { width: 14px; height: 14px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 34px 0 28px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 600; letter-spacing: 1.9px; line-height: 1.5; }
.page-header h2 { font-size: clamp(27px, 2.5vw, 36px); font-weight: 550; line-height: 1.2; letter-spacing: -1.2px; margin: 10px 0; }
.page-header .sub { margin: 0; color: var(--text-faint); font-size: 13px; line-height: 1.7; }
.page-symbol { display: grid; place-items: center; width: 60px; height: 60px; flex: 0 0 auto; border: 1px solid #394331; border-radius: 18px; background: #1e261a; color: var(--accent); }
.page-symbol .icon { width: 28px; height: 28px; stroke-width: 1.25; }
.page.hidden, .toast.hidden { display: none; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.card { min-width: 0; padding: 0 24px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 4px 16px #0000000a; }
.card.full-width { grid-column: 1 / -1; }
.card-heading { padding: 22px 0 19px; border-bottom: 1px solid var(--border); }
.card-heading h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.card-heading p { margin: 0; color: var(--text-faint); font-size: 11px; line-height: 1.6; }
.row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 1fr); align-items: center; gap: 15px; min-height: 62px; padding: 15px 0; border-bottom: 1px solid #ffffff06; }
.row:last-child { border-bottom: 0; }
.row .label { font-size: 12px; color: var(--text-dim); }
.row .val { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.row.slider-row { grid-template-columns: minmax(92px, .95fr) minmax(60px, 1fr) 65px; gap: 12px; }
.row.range-row { grid-template-columns: minmax(82px, .9fr) minmax(30px, .6fr) minmax(30px, .6fr) 76px; gap: 10px; }
.num { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 11px; font-variant-numeric: tabular-nums; color: #d9e6cc; text-align: right; white-space: nowrap; }
.card.full-width .row { grid-template-columns: 180px 1fr; }
.card.full-width .slider-row { grid-template-columns: 180px 1fr 65px; }

/* Existing controls */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--surface3); border-radius: 8px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--surface3); border-radius: 8px; }
input[type="range"]::-moz-range-progress { height: 4px; background: #768d60; border-radius: 8px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px #91ab73; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px #91ab73; }
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 4px #ccf59a18; }
.chip-input { width: 112px; max-width: 100%; padding: 8px 11px; border: 1px solid #3c4537; border-radius: 7px; background: #141813; color: var(--text); font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.chip-input::placeholder { color: var(--text-faint); }
.chip-input:hover { border-color: #5b6c4c; }
.chip-input:focus { outline: 2px solid #ccf59a45; outline-offset: 1px; border-color: var(--accent); }
.chips { display: inline-flex; max-width: 100%; padding: 3px; gap: 2px; border: 1px solid #30392c; border-radius: 8px; background: #121710; }
.chips button { padding: 6px 11px; border: 0; border-radius: 5px; background: transparent; color: var(--text-faint); font-size: 11px; }
.chips button:hover { color: var(--text); background: var(--surface2); }
.chips button.active { background: #36472b; color: #d7efc2; box-shadow: 0 1px 3px #0003; }
.switch { position: relative; display: inline-block; width: 36px; height: 22px; }
.switch input { position: absolute; opacity: 0; width: 36px; height: 22px; margin: 0; }
.switch span { position: absolute; inset: 0; border: 1px solid #45513d; border-radius: 50px; background: #30392a; cursor: pointer; }
.switch span::before { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #a3af99; transition: transform .16s, background-color .16s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(14px); background: #25341a; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Session actions */
.bar { position: fixed; z-index: 20; bottom: 20px; left: 274px; right: 44px; display: flex; align-items: center; gap: 8px; max-width: 1432px; padding: 14px 16px; border: 1px solid #3b4534; border-radius: 12px; background: #20261ff5; backdrop-filter: blur(12px); box-shadow: 0 10px 40px #0005; }
.bar-caption { display: flex; align-items: center; gap: 10px; margin-right: 20px; }
.bar-caption > .icon { width: 30px; height: 30px; padding: 6px; border: 1px solid #414c37; border-radius: 8px; color: var(--accent); }
.bar-caption strong { display: block; font-size: 12px; font-weight: 550; }
.bar-caption span { display: block; margin-top: 3px; font-size: 10px; color: var(--text-faint); }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 8px 17px; border: 1px solid #45513e; border-radius: 7px; background: #34422a; color: #dcedcf; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill:hover:enabled { background: #465c36; border-color: #73885c; }
.pill.accent { border-color: var(--accent); background: var(--accent); color: var(--accent-fg); font-weight: 650; }
.pill.accent:hover:enabled { background: #dfffaf; }
.pill.danger { border-color: #62433d; color: #efb0a6; background: #3c2c27; }
.pill.danger:hover:enabled { background: #593833; border-color: #a56a60; }
.pill.ghost { background: transparent; color: var(--text-dim); border-color: #414c3a; }
.pill.ghost:hover:enabled { color: var(--text); background: #333e2c; }
.pill .icon { width: 14px; height: 14px; }
.pill.sm { min-height: 30px; padding: 6px 12px; font-size: 11px; }
.toast { position: fixed; top: 20px; left: 50%; z-index: 100; max-width: calc(100vw - 32px); transform: translateX(-50%); padding: 12px 20px; border: 1px solid #546448; border-radius: 9px; background: #2c3824; color: var(--text); box-shadow: 0 8px 24px #0005; font-size: 13px; }
.toast.err { border-color: #97544d; background: #4c2b29; color: #ffd1c9; }
.toast.ok { border-color: #6b8b4d; }

/* Profiles and activity */
.profile-list { display: flex; flex-direction: column; }
.profile-list:empty::before { content: "Your saved profiles will appear here."; padding: 30px 0; color: var(--text-faint); font-size: 12px; text-align: center; }
.profile-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; min-height: 65px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.pname { font-size: 13px; overflow-wrap: anywhere; }
.profile-row.active .pname::before { content: "●"; margin-right: 10px; color: var(--accent); font-size: 9px; }
#active-name { font-size: 12px; color: var(--accent); font-weight: 500; overflow-wrap: anywhere; }
#log-view { min-height: 300px; max-height: 60vh; margin: 14px 0; padding: 18px; overflow: auto; border: 1px solid #2b3426; border-radius: 8px; background: #121610; color: #b6c8a5; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.85 "Cascadia Code", Consolas, monospace; }
#log-view:empty::before { content: "Waiting for engine output…"; color: var(--text-faint); }

/* Entry and approval screens */
.landing, .waiting { display: grid; place-items: center; padding: 36px 20px; background: radial-gradient(ellipse at 50% 0%, #26351c80, transparent 65%), var(--bg); }
.entry-card { width: 100%; max-width: 500px; padding: 38px; border: 1px solid #394330; border-radius: 20px; background: var(--surface); box-shadow: 0 24px 80px #0004; }
.entry-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 44px; font-size: 22px; font-weight: 650; letter-spacing: -.7px; }
.entry-card h1 { margin: 14px 0 16px; font-size: 42px; font-weight: 550; line-height: 1.13; letter-spacing: -1.6px; }
.entry-card h1 span { color: var(--accent); }
.entry-card > p { margin: 0 0 30px; color: var(--text-dim); font-size: 14px; line-height: 1.8; }
.entry-instructions { display: flex; align-items: flex-start; gap: 14px; margin: 22px 0; }
.step-number { display: grid; place-items: center; width: 27px; height: 27px; flex: 0 0 auto; border: 1px solid #47553b; border-radius: 7px; background: #293322; color: var(--accent); font-size: 10px; }
.entry-instructions strong { font-size: 12px; font-weight: 550; }
.entry-instructions p { margin: 5px 0 0; color: var(--text-faint); font-size: 12px; line-height: 1.7; }
.entry-instructions b { color: var(--text-dim); font-weight: 500; }
.entry-link { display: flex; align-items: center; gap: 10px; padding: 14px; margin-top: 30px; border: 1px solid var(--border); border-radius: 9px; background: #121610; color: var(--text-faint); }
.entry-link .icon { width: 15px; height: 15px; }
.entry-link code { font: 12px "Cascadia Code", Consolas, monospace; color: var(--text-dim); overflow-wrap: anywhere; }
.entry-link em { color: var(--accent); font-style: normal; }
.entry-card .hint { margin: 13px 0 0; color: var(--text-faint); font-size: 11px; text-align: center; }
.wait h1 { font-size: 31px; letter-spacing: -1px; }
.wait .status { min-height: 1.6em; margin: 24px 0; font-size: 13px; text-align: center; color: var(--text-dim); }
.wait .status.err { color: var(--danger); }
.wait .status.ok { color: var(--success); }
.spinner { width: 38px; height: 38px; margin: 32px auto 0; border: 2px solid var(--surface3); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner.done { animation: none; border-color: var(--success); }
.spinner.err { animation: none; border-color: var(--danger); }
.wait .meta { margin-top: 30px; color: var(--text-faint); text-align: center; font: 10px "Cascadia Code", Consolas, monospace; }
.wait .retry { display: none; margin: 0 auto; }
.wait.failed .spinner { display: none; }
.wait.failed .retry { display: flex; width: fit-content; }

@media (min-width: 1750px) { .bar { left: calc(50% - 601px); right: auto; width: 1432px; } }
@media (max-width: 1200px) {
  .panel { grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { padding-right: 12px; padding-left: 12px; }
  .brand { margin-left: 8px; margin-right: 0; }
  .content { padding-right: 28px; padding-left: 28px; }
  .bar { left: 228px; right: 28px; }
  .card { padding-right: 18px; padding-left: 18px; }
  .row.slider-row { grid-template-columns: 1fr 1fr 58px; gap: 9px; }
  .settings-grid { gap: 16px; }
  .chips button { padding-right: 8px; padding-left: 8px; }
}
@media (max-width: 1050px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .card.full-width { grid-column: auto; }
  .row.slider-row { grid-template-columns: 145px minmax(60px, 1fr) 75px; }
  .row.range-row { grid-template-columns: 140px 1fr 1fr 90px; }
  .card.full-width .row { grid-template-columns: 145px 1fr; }
  .card.full-width .slider-row { grid-template-columns: 145px 1fr 75px; }
  .bar-caption { margin-right: 5px; }
  .bar-caption > .icon, .bar-caption span { display: none; }
}
@media (max-width: 720px) {
  .panel { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 20px 20px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { margin: 0 0 22px; }
  .brand .logo { width: 32px; height: 32px; font-size: 21px; border-radius: 10px; }
  .brand-text { font-size: 19px; }
  .brand-text .sub { font-size: 8px; margin-top: 2px; }
  .sidebar > .menu-label, .nav-index, .footer .menu-label { display: none; }
  .nav { flex-direction: row; gap: 2px; width: 100%; }
  .nav-item { flex: 1; justify-content: center; gap: 7px; min-width: 0; min-height: 44px; padding: 10px 5px; border-radius: 7px 7px 0 0; font-size: 12px; border-bottom: 2px solid transparent; }
  .nav-item .icon { width: 16px; height: 16px; }
  .nav-item.active { background: #25311e; border-color: transparent; border-bottom-color: var(--accent); }
  .footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 1px; border: 0; margin: 0; }
  .badge { font-size: 10px; }
  .badge.small { margin: 0; font-size: 10px; }
  .content { padding: 0 20px 112px; }
  .topbar { min-height: 55px; }
  .breadcrumb { font-size: 10px; }
  .breadcrumb span { margin: 0 7px; }
  .live-note { font-size: 9px; gap: 4px; }
  .live-note .icon { width: 12px; height: 12px; }
  .page-header { margin: 27px 0 23px; gap: 14px; }
  .page-header h2 { font-size: 29px; }
  .page-header .sub { font-size: 12px; }
  .page-symbol { width: 48px; height: 48px; border-radius: 14px; }
  .page-symbol .icon { width: 24px; height: 24px; }
  .eyebrow { font-size: 9px; }
  .row.slider-row, .card.full-width .slider-row { grid-template-columns: 120px minmax(40px, 1fr) 62px; gap: 10px; }
  .row.range-row { grid-template-columns: 110px minmax(20px, 1fr) minmax(20px, 1fr) 76px; gap: 8px; }
  .card.full-width .row:not(.slider-row) { grid-template-columns: 120px 1fr; }
  .bar { left: 16px; right: 16px; bottom: 14px; padding: 11px; gap: 7px; border-radius: 10px; }
  .bar-caption { display: none; }
  .bar .pill { padding-right: 14px; padding-left: 14px; }
  .profile-row { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; }
  .profile-row .pill { padding-right: 8px; padding-left: 8px; }
  .entry-card { padding: 30px; }
}
@media (max-width: 420px) {
  .sidebar { padding-right: 14px; padding-left: 14px; }
  .footer { right: 14px; }
  .nav-item { gap: 5px; font-size: 11px; }
  .nav-item .icon { width: 14px; height: 14px; }
  .content { padding-right: 14px; padding-left: 14px; }
  .live-note { display: none; }
  .card { padding-right: 16px; padding-left: 16px; }
  .row.slider-row, .card.full-width .slider-row { grid-template-columns: 100px minmax(32px, 1fr) 57px; gap: 8px; }
  .row.range-row { grid-template-columns: 1fr 1fr 76px; }
  .row.range-row .label { grid-column: 1 / -1; }
  .row .label { font-size: 11px; }
  .row .val { flex-wrap: wrap; }
  .profile-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .pname { grid-column: 1 / -1; }
  .entry-card { padding: 26px; }
  .entry-card h1 { font-size: 36px; }
  .wait h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 3s !important; }
}
