:root {
  color-scheme: dark;
  --bg: #090b10;
  --surface: #10141c;
  --surface-2: #151b25;
  --border: #252d3a;
  --border-live: #3a785f;
  --text: #edf2f7;
  --muted: #a8b3c3;
  --dock-clearance: 104px;
  --green: #6cf1b5;
  --green-dim: #163d31;
  --amber: #f1c56c;
  --red: #ff8e8e;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -20%, rgba(65, 150, 115, .12), transparent 45%),
    var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button, summary, label { touch-action: manipulation; }
button, input, select, textarea { min-width: 0; }
button { min-height: 44px; }
button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }
::selection { color: #f5fff9; background: #315f4e; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(37, 45, 58, .8);
  background: rgba(9, 11, 16, .86);
  backdrop-filter: blur(18px) saturate(130%);
}

.brand-row, .state-row {
  display: flex;
  align-items: center;
}

.brand-row { gap: 11px; min-width: 0; }
.state-row { justify-content: flex-end; gap: 7px; flex-wrap: wrap; }

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #3d715e;
  border-radius: 11px;
  color: var(--green);
  background: linear-gradient(145deg, #17382e, #0e211b);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 8px 30px rgba(0, 0, 0, .25);
  font: 700 19px/1 var(--mono);
}

h1, h2, p { margin: 0; }

.brand-row h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.brand-row p {
  overflow: hidden;
  max-width: 42vw;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A blocked screen capture has to stay fully readable, not ellipsized away. */
.brand-row p.warning {
  max-width: 62vw;
  color: var(--amber);
  white-space: normal;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  background: rgba(16, 20, 28, .85);
  font: 650 12px/1.2 var(--sans);
  letter-spacing: .03em;
}

.pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.connected, .pill.mode.on {
  border-color: #315f4e;
  color: var(--green);
  background: rgba(22, 61, 49, .6);
}

.pill.waiting { color: var(--amber); }

/* audio pill: pulse while the capture is actually hearing sound */
.pill.mode.hearing i { animation: hearing 1s ease-in-out infinite; }
@keyframes hearing {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.8); opacity: .45; }
}
.pill.error { color: var(--red); }

#feed {
  width: min(100%, 860px);
  min-height: calc(100dvh - 76px);
  margin: 0 auto;
  padding: 24px max(18px, env(safe-area-inset-right)) calc(var(--dock-clearance) + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.empty-state {
  display: grid;
  min-height: 55vh;
  place-items: center;
  align-content: center;
  padding: 32px 22px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] { display: none; }

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 17px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--green);
  background: var(--surface);
  font: 28px/1 var(--mono);
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
  letter-spacing: -.02em;
}

.empty-state p {
  max-width: 380px;
  margin: 9px auto 17px;
  font-size: 15px;
  line-height: 1.65;
}

kbd {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-bottom-color: #3d4757;
  border-radius: 8px;
  color: #bdc6d2;
  background: var(--surface);
  box-shadow: 0 2px 0 #050608;
  font: 11px/1 var(--mono);
}

.caption {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #26364a;
  border-radius: 12px;
  color: #b8c5d6;
  background: rgba(19, 27, 38, .82);
  font-size: 15px;
  line-height: 1.6;
}

.caption[hidden] { display: none; }
.caption span { color: #79b8ff; }

.response-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(16, 20, 28, .9);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .17);
}

.response-card.live {
  border-color: var(--border-live);
  box-shadow: 0 0 0 1px rgba(108, 241, 181, .04), 0 18px 42px rgba(0, 0, 0, .24);
}

.response-card.live::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  animation: scan 1.8s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { opacity: .2; transform: translateX(-35%); }
  50% { opacity: 1; transform: translateX(35%); }
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 0;
  color: var(--muted);
  font: 650 11px/1.4 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.live-label { color: var(--green); }

.markdown {
  overflow-wrap: anywhere;
  padding: 16px 18px 19px;
  color: #e6ebf2;
  font-size: 16px;
  line-height: 1.7;
}


pre {
  overflow-x: auto;
  margin: 0;
  padding: 13px;
  color: #dce6f1;
  -webkit-overflow-scrolling: touch;
}

pre code {
  font: 13px/1.6 var(--mono);
  white-space: pre;
}

.jump-latest {
  position: fixed;
  z-index: 8;
  right: max(17px, env(safe-area-inset-right));
  bottom: calc(var(--dock-clearance) + env(safe-area-inset-bottom));
  padding: 10px 13px;
  border: 1px solid #467963;
  border-radius: 99px;
  color: #dffcef;
  background: rgba(22, 61, 49, .96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.control-dock {
  position: fixed;
  z-index: 15;
  right: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) repeat(3, minmax(54px, .7fr));
  gap: 8px;
  width: min(calc(100% - 24px), 840px);
  padding: 8px;
  border: 1px solid rgba(61, 73, 91, .9);
  border-radius: 16px;
  background: rgba(14, 18, 25, .94);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .46);
  backdrop-filter: blur(18px);
  transform: translateX(50%);
}

.control-dock[hidden] { display: none; }

.control-dock button {
  min-height: 44px;
  border: 1px solid #315f4e;
  border-radius: 11px;
  color: #eafff5;
  background: #173a2f;
  cursor: pointer;
  min-width: 0;
  padding: 7px 8px;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
}

.control-dock button:disabled { opacity: .52; cursor: not-allowed; }
.control-dock button:active { transform: translateY(1px); }
.control-dock .control-context { border-color: #5a5134; color: #fff1c8; background: #302918; }
.control-dock .control-codebase { border-color: #485b92; color: #dbe4ff; background: #1b2541; }
.control-dock .control-icon { border-color: var(--border); color: #bdc7d4; background: #171d27; font-size: 18px; }

.custom-prompt-panel {
  position: fixed;
  z-index: 20;
  right: 50%;
  bottom: calc(var(--dock-clearance) + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 700px);
  padding: 14px;
  border: 1px solid #3a4657;
  border-radius: 15px;
  background: rgba(16, 21, 29, .98);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .55);
  transform: translateX(50%);
}

.custom-prompt-panel[hidden] { display: none; }
.custom-prompt-panel > header { display: flex; align-items: center; justify-content: space-between; }
.custom-prompt-panel h2 { margin-top: 2px; font-size: 17px; }
.close-custom { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px; color: #bec8d5; background: #171d27; cursor: pointer; font-size: 19px; }
.custom-prompt-panel textarea {
  display: block;
  resize: vertical;
  width: 100%;
  min-height: 86px;
  max-height: 34dvh;
  margin-top: 11px;
  padding: 10px 11px;
  border: 1px solid #344052;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #090d13;
  font-size: 16px;
  line-height: 1.5;
}
.custom-prompt-panel textarea:focus { border-color: #4e9a7b; box-shadow: 0 0 0 3px rgba(108, 241, 181, .08); }
.custom-prompt-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.custom-prompt-actions span { color: var(--muted); font: 10px/1 var(--mono); }
.custom-prompt-actions button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 9px; color: #07150f; background: var(--green); cursor: pointer; font-weight: 800; }
.custom-prompt-actions .secondary-action { margin-right: auto; border: 1px solid #485b92; color: #dbe4ff; background: #1b2541; }
.setup-return { width: 100%; min-height: 44px; margin: 0 0 16px; padding: 12px 16px; border: 1px solid #485b92; border-radius: 10px; color: #dbe4ff; background: #1b2541; font: inherit; text-align: left; cursor: pointer; }
.setup-return span { float: right; }
.custom-prompt-actions button:disabled { opacity: .42; cursor: not-allowed; }
.custom-prompt-status { margin-top: 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.custom-prompt-status.error { color: var(--red); }
.context-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; color: #c1cad6; font-size: 14px; line-height: 1.45; }
.context-choice input { flex: 0 0 20px; width: 20px; height: 20px; accent-color: var(--green); }

.settings-backdrop {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: grid;
  align-items: end;
  background: rgba(4, 6, 9, .72);
  backdrop-filter: blur(9px);
}

.settings-backdrop[hidden] { display: none; }

.settings-sheet {
  overflow: auto;
  width: min(100%, 620px);
  max-height: min(calc(100dvh - 24px - env(safe-area-inset-top)), 900px);
  margin: 0 auto;
  padding: 20px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border: 1px solid #303947;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: #10151d;
  box-shadow: 0 -24px 70px rgba(0, 0, 0, .45);
}

.settings-sheet > header { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; }
.sheet-kicker { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.settings-sheet h2 { margin-top: 3px; font-size: 21px; }
.close-settings { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; color: #bec8d5; background: #171d27; cursor: pointer; font-size: 22px; }

.command-status {
  margin: 16px 0 12px;
  padding: 9px 11px;
  border: 1px solid #2a3442;
  border-radius: 9px;
  color: #9eabba;
  background: #0b0f15;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.command-status.success { border-color: #315f4e; color: var(--green); }
.command-status.error { border-color: #663c44; color: var(--red); }

.mode-controls { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px 12px; background: #141a23; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-row > span { flex: 1; min-width: 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 15px; }
.switch-row small { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; flex: 0 0 40px; width: 40px; height: 23px; border-radius: 20px; background: #303947; transition: .15s ease; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #929dac; transition: .15s ease; }
.switch-row input:checked + i { background: #236a50; }
.switch-row input:checked + i::after { left: 20px; background: var(--green); }
.switch-row input:disabled + i { opacity: .45; }
.switch-row input:focus-visible + i { outline: 3px solid var(--green); outline-offset: 4px; }

#settings-form { margin-top: 16px; }
.target-setting {
  position: relative;
  display: block;
  margin-bottom: 14px;
  color: #c5ced9;
}
.target-setting > span { display: block; }
.target-setting strong, .target-setting small { display: block; }
.target-setting strong { font-size: 15px; }
.target-setting small { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.target-setting textarea {
  display: block;
  width: 100%;
  min-height: 84px;
  margin-top: 8px;
  padding: 10px 11px 22px;
  resize: vertical;
  border: 1px solid #344052;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #090d13;
  font-size: 16px;
  line-height: 1.55;
}
.target-setting textarea:focus { border-color: #4e9a7b; box-shadow: 0 0 0 3px rgba(108, 241, 181, .08); }
.target-setting em {
  position: absolute;
  right: 9px;
  bottom: 8px;
  color: var(--muted);
  font: 11px/1 var(--mono);
  font-style: normal;
  pointer-events: none;
}
.session-settings { margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #0d1219; }
.session-settings[hidden] { display: none; }
.session-settings h3 { margin: 0 0 16px; color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.session-settings .option-list { margin: 10px 2px 0; }
.context-files { margin-bottom: 14px; color: #c5ced9; }
.context-files-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.context-files-head strong, .context-files-head small { display: block; }
.context-files-head strong { font-size: 15px; }
.context-files-head small { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.context-enabled { display: flex; flex: none; align-items: center; gap: 8px; min-height: 44px; color: #c1cad6; font-size: 13px; }
.context-enabled input { flex: 0 0 20px; width: 20px; height: 20px; accent-color: #54d89e; }
.context-file-list { display: grid; gap: 6px; margin: 9px 0 0; padding: 0; list-style: none; }
.context-file-list:empty { display: none; }
.context-file-list li { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 5px 6px 5px 10px; border: 1px solid #2a3442; border-radius: 9px; background: #090d13; }
.context-file-list li.failed { border-color: #663c44; }
.context-file-list .file-kind { flex: none; min-width: 34px; color: var(--green); font: 700 10px/1 var(--mono); text-transform: uppercase; }
.context-file-list li.failed .file-kind { color: var(--red); }
.context-file-list .file-name { overflow: hidden; flex: 1; min-width: 0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.context-file-list .file-meta { flex: none; color: var(--muted); font: 11px/1.4 var(--mono); text-align: right; }
.context-file-list button { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid #59353b; border-radius: 7px; color: #ffb7b7; background: #251419; cursor: pointer; font-size: 15px; }
.session-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.session-actions button { flex: 1 1 96px; min-height: 44px; padding: 9px 12px; border: 1px solid #344052; border-radius: 9px; color: #dbe4ff; background: #171d27; cursor: pointer; font-size: 14px; font-weight: 650; }
.session-actions button.primary { border: 0; color: #07150f; background: var(--green); }
.session-actions button:disabled, .context-file-list button:disabled { opacity: .42; cursor: not-allowed; }
.context-note-editor { display: grid; gap: 8px; margin-top: 9px; }
.context-note-editor[hidden] { display: none; }
.context-note-editor input, .context-note-editor textarea { width: 100%; padding: 10px 11px; border: 1px solid #344052; border-radius: 9px; outline: none; color: var(--text); background: #090d13; font-size: 16px; line-height: 1.5; }
.context-note-editor textarea { resize: vertical; }
#session-prompt-text { min-height: 180px; font: 16px/1.55 var(--mono); }
#session-prompt-status.warning { color: var(--amber); }
#session-prompt-status.error { color: var(--red); }
#session-prompt-status.working { color: var(--green); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.settings-grid[hidden] { display: none; }
.answer-budget-settings { margin-top: 12px; }
.settings-grid label { min-width: 0; color: #c5ced9; font-size: 13px; line-height: 1.45; font-weight: 650; }
.settings-grid input, .settings-grid select {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #344052;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #090d13;
}
.settings-grid input:focus, .settings-grid select:focus { border-color: #4e9a7b; box-shadow: 0 0 0 3px rgba(108, 241, 181, .08); }

.option-list { display: grid; gap: 4px; margin: 16px 2px; }
.option-list label { display: flex; align-items: center; gap: 10px; min-height: 44px; color: #c1cad6; font-size: 14px; line-height: 1.45; cursor: pointer; }
.option-list input { flex: 0 0 20px; width: 20px; height: 20px; accent-color: #54d89e; }

.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.settings-actions button { flex: 1 1 130px; min-height: 44px; padding: 10px 12px; border: 1px solid #3b485b; border-radius: 10px; color: #e0e8f2; background: #1a2330; cursor: pointer; font-size: 14px; line-height: 1.35; font-weight: 650; }
.settings-actions .danger-button { border: 1px solid #70424c; color: #ffb7b7; background: #251419; }
.settings-actions .context-button { border: 1px solid #75633a; color: #ffe7a5; background: #282313; }
.settings-actions button:disabled { opacity: .42; cursor: not-allowed; }
.settings-actions .save-button { border-color: var(--green); color: #07150f; background: var(--green); font-weight: 750; }
.settings-note { margin-top: 12px; color: var(--muted); text-align: left; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }

.code-browser-sheet {
  width: min(100%, 920px);
  max-height: 92dvh;
}

.code-file-picker {
  display: block;
  margin-top: 12px;
  color: #aab5c3;
  font-size: 13px;
  font-weight: 650;
}

.code-file-picker select {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #344052;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #090d13;
}

.code-browser-pre {
  overflow: auto;
  max-height: 62dvh;
  margin-top: 12px;
  border: 1px solid #29313e;
  border-radius: 11px;
  background: #080b10;
}

.code-browser-pre code {
  display: block;
  min-width: max-content;
  white-space: pre;
}

.auth-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  padding: 22px;
  place-items: center;
  background: rgba(5, 7, 10, .88);
  backdrop-filter: blur(14px);
}

.auth-backdrop[hidden] { display: none; }

.auth-card {
  width: min(100%, 380px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
}

.auth-card h2 { margin-top: 18px; font-size: 20px; }
.auth-card > p { margin: 8px 0 18px; color: var(--muted); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.auth-card label { display: block; margin-bottom: 8px; color: #c5ced9; font-size: 14px; font-weight: 650; }
#session-field { margin-bottom: 12px; }

.auth-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid #354052;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #090c11;
  font: 16px/1.5 var(--mono);
}

.auth-card input:focus { border-color: #4e9a7b; box-shadow: 0 0 0 3px rgba(108, 241, 181, .1); }

.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  color: #07130e;
  background: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.auth-card .auth-error { margin: 9px 0 0; color: var(--red); }

/* Sheets keep the navigation and save action visible while the fields scroll. */
.settings-sheet:not(.code-browser-sheet) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}
.settings-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  margin-right: -8px;
  padding: 0 8px 16px 0;
  -webkit-overflow-scrolling: touch;
}
.settings-content > .command-status { margin-top: 0; }
.settings-footer {
  flex: none;
  margin: 0 -20px;
  padding: 12px max(20px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-top: 1px solid #303b4b;
  background: #141b25;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .16);
}
.settings-footer .settings-actions { margin-top: 0; }
.settings-footer .settings-note { margin: 0 0 10px; font-size: 12px; text-align: center; }
.settings-subtitle { margin: 24px 0 12px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text); font-size: 15px; }
.settings-section {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0d1219;
}
.settings-section > summary {
  min-height: 52px;
  padding: 15px 14px;
  color: #dce6f1;
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.45;
}
.settings-section[open] > summary { margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.settings-section > :not(summary) { margin-right: 14px; margin-left: 14px; }
.settings-section > :last-child { margin-bottom: 14px; }
.settings-section .session-settings { padding: 0; border: 0; background: transparent; }
.control-dock .control-icon { display: flex; align-items: center; justify-content: center; gap: 4px; }
.control-label { font: 650 11px/1.2 var(--sans); }
.custom-prompt-panel { max-height: calc(100dvh - var(--dock-clearance) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.custom-prompt-panel > header { gap: 12px; }
.custom-prompt-actions { flex-wrap: wrap; }
.custom-prompt-actions span { font-size: 12px; }
.custom-prompt-panel .sheet-kicker { line-height: 1.5; }
.caption p { min-width: 0; overflow-wrap: anywhere; }
.card-meta { gap: 12px; }
.card-meta > * { min-width: 0; }
.settings-grid input[type="range"] { padding: 8px 0; border: 0; accent-color: var(--green); background: transparent; }
.auth-backdrop { overflow-y: auto; overscroll-behavior: contain; padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: max(22px, env(safe-area-inset-bottom)); }
.auth-card { margin: auto; }
.code-browser-sheet { overscroll-behavior: contain; }
.connection-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #75633a;
  border-radius: 12px;
  color: #f7deab;
  background: #252116;
  font-size: 14px;
  line-height: 1.5;
}
.connection-notice p { flex: 1 1 220px; overflow-wrap: anywhere; }
.connection-notice button { flex: 0 0 auto; padding: 10px 12px; border: 1px solid #8a7441; border-radius: 8px; color: #fff0d0; background: #37301e; font-size: 13px; font-weight: 650; cursor: pointer; }
.action-feedback {
  position: fixed;
  z-index: 22;
  right: 50%;
  bottom: calc(var(--dock-clearance) + env(safe-area-inset-bottom));
  overflow-y: auto;
  width: min(calc(100% - 32px), 600px);
  max-height: 25dvh;
  padding: 14px 16px;
  border: 1px solid #4b655a;
  border-radius: 12px;
  color: #e1f6eb;
  background: #1a2b23;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transform: translateX(50%);
}
.action-feedback.error { border-color: #87505c; color: #ffced3; background: #351e25; }
body:has(.action-feedback:not([hidden])) .jump-latest { bottom: calc(var(--dock-clearance) + 25dvh + 12px + env(safe-area-inset-bottom)); }

@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(1.13); }
  .settings-section > summary:hover { color: var(--green); }
}

@media (max-width: 760px) {
  :root { --dock-clearance: 150px; }
  .topbar { gap: 12px; min-height: 72px; }
  .brand-row p { max-width: 46vw; }
  #feed { padding-top: 18px; }
  .control-dock {
    bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 6px;
    width: calc(100% - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right)));
    padding: 8px;
    border-radius: 16px;
  }
  .control-dock button {
    grid-column: span 2;
    min-height: 46px;
    padding: 6px 3px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .control-dock .control-primary { grid-column: span 5; font-size: 14px; }
  .control-dock .control-codebase { font-size: 11px; overflow-wrap: normal; }
  .control-dock:has(#stop-speech[hidden]) { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .control-dock:has(#stop-speech[hidden]) .control-primary { grid-column: span 4; }
  .control-dock .control-icon { flex-direction: column; gap: 3px; font-size: 17px; }
  .control-label { font-size: 10px; }
  .custom-prompt-panel { width: calc(100% - 24px); padding: 16px; }
  .jump-latest { font-size: 13px; }
}

@media (max-width: 480px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 10px; }
  .brand-row { width: 100%; }
  .brand-mark { flex-basis: 32px; width: 32px; height: 32px; border-radius: 9px; font-size: 17px; }
  .brand-row h1 { font-size: 16px; }
  .brand-row p, .brand-row p.warning { max-width: none; white-space: normal; font-size: 12px; line-height: 1.4; }
  .state-row { width: 100%; justify-content: flex-start; gap: 6px; }
  .pill { min-height: 28px; padding: 5px 8px; font-size: 11px; letter-spacing: 0; }
  #feed { padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  .empty-state { min-height: 43dvh; padding: 24px 12px; }
  .empty-state p { font-size: 15px; }
  .response-card { margin-bottom: 14px; border-radius: 14px; }
  .markdown { padding: 14px 15px 17px; font-size: 16px; line-height: 1.65; }
  .card-meta { padding: 12px 15px 0; font-size: 10px; }
  .caption { padding: 12px; font-size: 14px; }
  .settings-sheet { padding: 16px 16px 0; border-radius: 20px 20px 0 0; }
  .settings-sheet > header { padding-bottom: 14px; }
  .settings-sheet h2 { font-size: 22px; }
  .settings-content { margin-right: -6px; padding-right: 6px; }
  .settings-footer { margin: 0 -16px; padding-right: 16px; padding-left: 16px; }
  .settings-footer .settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .settings-footer .save-button { grid-column: 1 / -1; grid-row: 1; }
  .settings-footer .settings-actions button { padding: 9px 8px; font-size: 13px; }
  .settings-footer .settings-note { font-size: 11px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .session-settings { padding: 14px 12px; }
  .context-files-head { flex-wrap: wrap; gap: 2px; }
  .context-file-list { margin-top: 4px; }
  .context-file-list li { flex-wrap: wrap; }
  .context-file-list .file-meta { font-size: 10px; }
  .custom-prompt-actions { gap: 8px; }
  .custom-prompt-actions button { padding: 10px 12px; font-size: 14px; }
  .auth-backdrop { padding-right: 16px; padding-left: 16px; }
  .auth-card { padding: 22px 18px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .topbar { position: relative; min-height: 60px; }
  .brand-row { width: auto; }
  .state-row { width: auto; }
  .settings-sheet { max-height: calc(100dvh - 8px - env(safe-area-inset-top)); }
  .settings-sheet > header { padding-bottom: 10px; }
  .sheet-kicker { display: none; }
  .settings-footer .settings-actions { display: flex; }
  .settings-footer .save-button { flex: 1 1 130px; }
  .settings-footer .settings-note { display: none; }
  .custom-prompt-panel { bottom: max(8px, env(safe-area-inset-bottom)); max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
