:root {
  --bg: #0c0b0a;
  --bg-2: #161412;
  --ink: #f4efe6;
  --muted: #a89f91;
  --line: rgba(244, 239, 230, 0.1);
  --bronze: #c4a574;
  --bronze-2: #8c6d3f;
  --good: #b7c7a3;
  --wait: #e2c07a;
  --bad: #c9897a;
  --radius: 18px;
  font-family: "Segoe UI", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body {
  margin: 0;
  height: 100%;
  max-width: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; color-scheme: dark; }
button { cursor: pointer; }

.titlebar {
  display: none;
  height: 40px;
  flex-shrink: 0;
  align-items: stretch;
  background: #100e0c;
  border-bottom: 1px solid var(--line);
  font-family: "Segoe UI", sans-serif;
  user-select: none;
  z-index: 20;
}
html.penterra-desktop .titlebar { display: flex; }
html.penterra-desktop,
html.penterra-desktop body {
  overflow: hidden;
}
html.penterra-desktop body {
  display: flex;
  flex-direction: column;
}
html.penterra-desktop .login-shell {
  min-height: 0;
  flex: 1;
}
html.penterra-desktop #app-view {
  height: auto;
  flex: 1;
  min-height: 0;
}
.titlebar-drag {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-width: 0;
}
.titlebar-kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bronze);
}
.titlebar strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.titlebar-controls { display: flex; }
.titlebar-controls button {
  width: 46px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: #c9b89a;
  border-radius: 0;
  padding: 0;
}
.titlebar-controls button:hover,
.titlebar-controls button:focus-visible {
  background: rgba(196, 165, 116, 0.12);
  color: var(--ink);
  outline: none;
}
#win-close:hover,
#win-close:focus-visible {
  background: #6e3d36;
  color: #f4efe6;
}

.pe-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 165, 116, 0.35) transparent;
  overflow-x: hidden;
}
.pe-scroll:hover,
.pe-scroll:focus,
.pe-scroll:focus-within {
  scrollbar-color: rgba(196, 165, 116, 0.55) transparent;
}
.pe-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.pe-scroll::-webkit-scrollbar-track {
  background: transparent;
  margin: 6px 0;
}
.pe-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(196, 165, 116, 0.32);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 999px;
}
.pe-scroll:hover::-webkit-scrollbar-thumb,
.pe-scroll:focus::-webkit-scrollbar-thumb,
.pe-scroll:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(196, 165, 116, 0.5);
}
.pe-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(196, 165, 116, 0.55);
}
.pe-scroll::-webkit-scrollbar-corner { background: transparent; }
.pe-scroll::-webkit-scrollbar:horizontal {
  height: 0;
  display: none;
}

.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(196, 165, 116, 0.18), transparent 50%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 32px;
}
.eyebrow { letter-spacing: 0.18em; text-transform: uppercase; font-size: 11px; color: var(--bronze); margin: 0 0 8px; font-family: "Segoe UI", sans-serif; }
h1 { font-weight: 500; font-size: 42px; margin: 0 0 12px; }
.lede, .hint, .muted { color: var(--muted); line-height: 1.5; }
.login-card label { display: block; margin: 16px 0; font-size: 14px; color: var(--muted); font-family: "Segoe UI", sans-serif; }
input, textarea {
  width: 100%;
  margin-top: 6px;
  background: #0c0b0a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.login-card button, .go-actions button:not(.no) {
  background: var(--bronze);
  color: #1a140c;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
}
.err { color: var(--bad); }
.hint { font-size: 13px; }

#app-view {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) minmax(0, auto);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}
#app-view.ctx-open { grid-template-columns: 268px minmax(0, 1fr) minmax(0, 232px); }
#app-view[hidden], [hidden] { display: none !important; }
.app-chrome,
.nav-backdrop {
  display: none;
}
.rail, main, .context { min-width: 0; max-width: 100%; }

.rail {
  border-right: 1px solid var(--line);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  overflow-x: hidden;
  background: #100e0c;
  font-family: "Segoe UI", sans-serif;
}
.rail-head {
  flex: 0 0 auto;
  padding: 16px 12px 8px;
}
.rail-mid {
  flex: 1 1 0;
  min-height: 0;
  padding: 0 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rail-mid::-webkit-scrollbar:horizontal { height: 0; display: none; }
.rail-foot {
  flex: 0 0 auto;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--line);
  background: #100e0c;
}
.brand {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 4px 10px 10px;
  border-radius: 10px;
}
.brand:hover { background: rgba(196,165,116,0.08); }
.brand-kicker { display: block; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bronze); }
.brand strong { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 8px;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(196,165,116,0.35);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.new-chat:hover { background: rgba(196,165,116,0.12); border-color: var(--bronze); }
.rail-block { min-height: 0; }
.rail-block.recents { flex: 0 0 auto; }
.rail-block.workspaces {
  margin-top: 4px;
  padding-top: 4px;
}
.nav-label {
  margin: 10px 10px 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bronze);
}
.ws-nav, .recent-chats, .rail-tools { display: flex; flex-direction: column; gap: 2px; }
.ws-nav button, .recent-chats button, .rail-tools button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 7px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.3;
}
.ws-nav button svg, .rail-tools button svg { flex: 0 0 16px; opacity: 0.85; margin-top: 2px; }
.ws-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.ws-name { line-height: 1.3; }
.ws-knowledge {
  display: none;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
}
.ws-knowledge:not(:empty) { display: block; }
.ws-nav button { align-items: flex-start; }
.ws-nav button.active, .ws-nav button:hover,
.rail-tools button.active, .rail-tools button:hover,
.recent-chats button.active, .recent-chats button:hover {
  background: rgba(196,165,116,0.12);
  color: var(--ink);
}
.ws-nav button.active { box-shadow: inset 2px 0 0 var(--bronze); }
.recent-chats button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  white-space: nowrap;
  overflow: hidden;
}
.recent-chats button span:first-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-chats .ws { display: block; font-size: 11px; color: var(--bronze); }
.recent-empty { margin: 0 10px; font-size: 12px; color: var(--muted); }
.ws-nav, .rail-tools, .account { flex-shrink: 0; }
.rail-tools { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }

.account {
  margin-top: 0;
  padding: 8px 10px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(12, 11, 10, 0.28);
}
.account-name {
  display: block;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.account-meta,
.account-badge {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
}
.account-badge.is-founder {
  color: var(--bronze);
}
.account-version {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}
.account-actions { display: flex; gap: 4px; margin-top: 6px; }
.account-actions button {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 0;
  text-align: left;
  font-family: "Segoe UI", sans-serif;
}
.account-actions button:hover { color: var(--ink); }

.run-menu {
  position: fixed;
  z-index: 40;
  min-width: 208px;
  padding: 6px;
  background: #161412;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.run-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: "Segoe UI", sans-serif;
}
.run-menu button:hover { background: rgba(196, 165, 116, 0.12); }
.run-menu button[data-act="purge"] { color: var(--bad); }

.james-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(8, 7, 6, 0.62);
}
.james-dialog-card {
  width: min(420px, calc(100vw - 32px));
  background: #161412;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 16px;
}
.james-dialog-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.james-dialog-body {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}
.james-dialog-input {
  width: 100%;
  margin: 0 0 14px;
  background: #0c0b0a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
}
.james-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.james-dialog-actions button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.james-dialog-actions #dlg-ok {
  background: var(--bronze);
  color: #1a140c;
}
.james-dialog-actions #dlg-ok.danger {
  background: #6e3d36;
  color: #f4efe6;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 28px 0;
  padding: 10px 14px;
  border: 1px solid rgba(196,165,116,0.35);
  border-radius: 12px;
  background: #1a1612;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
}
.update-banner p { margin: 0; }
.update-banner-actions { display: flex; gap: 8px; }
.update-banner-actions button {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 600;
}
#update-later { background: transparent; color: var(--muted); }
#update-install { background: var(--bronze); color: #1a140c; }
.update-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.update-actions button {
  background: var(--bronze);
  color: #1a140c;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.update-actions button:disabled { opacity: 0.45; cursor: default; }
#upd-check { background: transparent; color: var(--ink); border: 1px solid rgba(196,165,116,0.4); }

main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  overflow-x: hidden;
}
.panel {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane-body {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 32px;
}
.thread {
  flex: 1 1 0%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px 36px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.thread.welcome { justify-content: center; }
.welcome-block { max-width: 560px; }
.welcome-block h2 { font-weight: 500; font-size: 30px; margin: 0 0 10px; }
.welcome-block p { color: var(--muted); font-size: 18px; margin: 0; }
.bubble {
  max-width: 72%;
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.bubble.user { align-self: flex-end; background: #2a241c; }
.bubble.james { align-self: flex-start; background: transparent; padding-left: 0; }
.err-bubble { color: var(--bad); }
.bubble .meta { display: block; font-size: 11px; color: var(--bronze); margin-bottom: 4px; font-family: "Segoe UI", sans-serif; }

#inline-go { padding: 0 36px 8px; }
.go-card {
  background: var(--bg-2);
  border: 1px solid rgba(196,165,116,0.35);
  border-radius: var(--radius);
  padding: 18px 20px;
  max-width: 520px;
}
.go-card h3 { margin: 0 0 8px; font-weight: 500; }
.go-card .subject { margin: 0 0 6px; }
.go-actions { display: flex; gap: 10px; margin-top: 14px; }
.go-actions .no {
  background: transparent;
  color: var(--bad);
  border: 1px solid var(--bad);
  border-radius: 999px;
  padding: 12px 20px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
}

#view-chat.drop-on #composer {
  border-color: rgba(196, 165, 116, 0.55);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(196, 165, 116, 0.16);
}

.composer-dock {
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 28px calc(24px + env(safe-area-inset-bottom, 0px));
}

#composer {
  --composer-lh: 24px;
  --composer-pad-y: 22px;
  --composer-max-lines: 6;
  --composer-max: calc(var(--composer-lh) * var(--composer-max-lines) + var(--composer-pad-y));
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px 10px 8px;
  background: #1e1a16;
  border: 1px solid rgba(196, 165, 116, 0.22);
  border-radius: 28px;
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(244, 239, 230, 0.06) inset;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
#composer:focus-within {
  border-color: rgba(196, 165, 116, 0.4);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.42),
    0 0 0 3px rgba(196, 165, 116, 0.12);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.composer-grow {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  max-height: var(--composer-max);
}
#composer-field {
  max-height: var(--composer-max);
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
  scrollbar-gutter: auto;
  scrollbar-color: transparent transparent;
}
#composer-field.is-overflowing {
  overflow-y: auto;
}
#composer-field::-webkit-scrollbar,
#composer-field::-webkit-scrollbar-thumb,
#composer-field::-webkit-scrollbar-track,
#composer-field::-webkit-scrollbar-corner {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}
.composer-sb {
  display: none;
  position: absolute;
  top: 8px;
  right: 3px;
  bottom: 8px;
  width: 5px;
  pointer-events: none;
  z-index: 2;
}
.composer-grow.is-overflowing .composer-sb { display: block; }
.composer-sb i {
  position: absolute;
  left: 0;
  width: 5px;
  min-height: 22px;
  border-radius: 999px;
  background: rgba(196, 165, 116, 0.62);
}

#composer textarea {
  display: block;
  width: 100%;
  min-width: 0;
  resize: none;
  font-size: 16px;
  line-height: var(--composer-lh);
  min-height: calc(var(--composer-lh) + var(--composer-pad-y));
  max-height: none;
  margin: 0;
  padding: 11px 14px 11px 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  overflow: hidden;
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
  scrollbar-gutter: auto;
}
#composer textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
#composer textarea::placeholder { color: var(--muted); }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 2px;
}

.composer-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: #c9b89a;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.composer-icon:hover,
.composer-icon:focus-visible {
  color: var(--bronze);
  background: rgba(196, 165, 116, 0.12);
  outline: none;
}
.composer-icon:active { transform: scale(0.96); }
#dictate-btn[aria-pressed="true"] {
  color: #1a140c;
  background: var(--wait);
}
#dictate-btn[aria-pressed="true"]:hover {
  color: #1a140c;
  background: var(--wait);
}

.composer-talk,
.composer-send {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  margin: 3px 4px 3px 2px;
  display: grid;
  place-items: center;
  background: var(--bronze);
  color: #1a140c;
  border: 0;
  border-radius: 50%;
  padding: 0;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}
.composer-talk:hover,
.composer-talk:focus-visible,
.composer-send:hover,
.composer-send:focus-visible {
  filter: brightness(1.08);
  outline: none;
}
.composer-talk:active,
.composer-send:active { transform: scale(0.96); }
.composer-talk[hidden],
.composer-send[hidden] {
  display: none !important;
}
.composer-talk[aria-pressed="true"] {
  animation: talk-pulse 1.15s ease-in-out infinite;
}
@keyframes talk-pulse {
  50% { filter: brightness(1.16); }
}
.composer-send:disabled {
  opacity: 0.38;
  cursor: default;
  filter: none;
  background: #3a342c;
  color: #8a8074;
}

.icon-btn {
  background: transparent;
  color: var(--bronze);
  border: 1px solid var(--bronze);
  border-radius: 999px;
  min-width: 52px;
  display: grid;
  place-items: center;
  padding: 0 14px;
}
.icon-btn:hover { background: rgba(196,165,116,0.12); }
.pending-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px 2px 12px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2a241c;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px 6px 6px;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
}
.file-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 8px; }
.file-chip .kind {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bronze);
}
.file-chip button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0 4px;
}
.bubble .atts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.bubble .atts img {
  max-width: 220px;
  max-height: 160px;
  border-radius: 12px;
  display: block;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(196,165,116,0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
}
.voice-status {
  margin: 8px 8px 0;
  padding: 0;
  font-size: 13px;
}

.context {
  border-left: 1px solid var(--line);
  padding: 18px 16px 24px;
  width: auto;
  height: 100%;
  min-height: 0;
  background: #100e0c;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: "Segoe UI", sans-serif;
}
.ctx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 14px;
}
.ctx-head .nav-label { margin: 0; }
#ctx-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
#ctx-close:hover,
#ctx-close:focus-visible {
  background: rgba(196, 165, 116, 0.12);
  color: var(--ink);
  outline: none;
}
.context h3 { font-weight: 500; margin: 0 0 8px; font-family: "Iowan Old Style", Georgia, serif; }
.context .item { margin-bottom: 18px; }
.ctx-work {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ctx-work li { color: var(--ink); font-size: 14px; }
.ctx-work .st { color: var(--muted); font-size: 12px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 24px 36px 0;
}
.card h3 { margin: 0 0 8px; font-weight: 500; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-family: "Segoe UI", sans-serif; font-size: 14px; }
.kv dt { color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-family: "Segoe UI", sans-serif; }
.check + .check { margin-top: 12px; }
.check input {
  accent-color: #c4a574;
  width: auto;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  flex: 0 0 auto;
}
details { margin-top: 12px; color: var(--muted); }
details summary { cursor: pointer; font-family: "Segoe UI", sans-serif; }

.sett {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.sett-head {
  flex: 0 0 auto;
  padding: 28px 36px 10px;
}
.sett-head h2 {
  margin: 0 0 6px;
  font-weight: 500;
  font-size: 30px;
}
.sett-head .lede { margin: 0; }
.sett-layout {
  flex: 1 1 0%;
  min-height: 0;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
}
.sett-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px 24px 22px;
  border-right: 1px solid var(--line);
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "Segoe UI", sans-serif;
}
.sett-nav button {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.sett-nav button:hover,
.sett-nav button:focus-visible {
  background: rgba(196, 165, 116, 0.1);
  color: var(--ink);
  outline: none;
}
.sett-nav button.active {
  background: rgba(196, 165, 116, 0.16);
  color: var(--ink);
  font-weight: 600;
}
.sett .pane-body {
  padding: 4px 28px 40px 20px;
}
.sett .pane-body .card {
  margin: 12px 0 0;
  max-width: min(640px, 100%);
  width: 100%;
  box-sizing: border-box;
}
}
.sett-row { margin: 16px 0 0; }
.sett-k {
  display: block;
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sett-select {
  width: 100%;
  max-width: min(420px, 100%);
  margin-top: 6px;
  background: #0c0b0a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  box-sizing: border-box;
}
.sett-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.sett-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(196, 165, 116, 0.4);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.sett-ghost:hover,
.sett-ghost:focus-visible {
  background: rgba(196, 165, 116, 0.12);
  outline: none;
}
.sett-toggle { align-items: flex-start; margin-top: 16px; width: 100%; box-sizing: border-box; }
.sett-toggle input { margin-top: 3px; flex: 0 0 auto; }
.sett-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 0%;
  overflow-wrap: anywhere;
}
.sett-toggle-copy .muted { margin: 0; }
.sett .pane-body p,
.sett .lede {
  overflow-wrap: anywhere;
}
.sett-toggle-copy .muted { margin: 0; }
#audio-perm { margin-top: 12px; }
html.ui-large .thread,
html.ui-large .composer-field,
html.ui-large .sett .pane-body,
html.ui-large .sett-head h2 {
  font-size: 1.08em;
}

@media (max-width: 1180px) and (min-width: 961px) {
  #app-view.ctx-open {
    grid-template-columns: 268px minmax(0, 1fr);
  }
  .context {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(232px, 34vw);
    z-index: 8;
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 960px) {
  html, body { height: 100%; overflow: hidden; overflow-x: hidden; }
  #app-view, #app-view.ctx-open {
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "chrome"
      "main"
      "ctx";
    overflow: hidden;
    overflow-x: hidden;
  }
  .rail {
    grid-area: chrome;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 31;
    width: min(320px, 86vw);
    height: 100dvh;
    max-height: 100dvh;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    pointer-events: none;
    box-shadow: none;
    padding-left: env(safe-area-inset-left, 0px);
  }
  #app-view.nav-open .rail {
    transform: translateX(0);
    pointer-events: auto;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45);
  }
  .app-chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-area: chrome;
    min-height: 48px;
    height: calc(48px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0 8px;
    background: #100e0c;
    border-bottom: 1px solid var(--line);
    z-index: 12;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--ink);
  }
  .nav-toggle:hover,
  .nav-toggle:focus-visible {
    background: rgba(196, 165, 116, 0.12);
  }
  .app-chrome-title {
    font-family: "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .nav-backdrop {
    grid-area: chrome;
    position: fixed;
    inset: 0;
    z-index: 30;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(8, 7, 6, 0.55);
    cursor: pointer;
  }
  #app-view.nav-open .nav-backdrop:not([hidden]) {
    display: block;
  }
  main { grid-area: main; min-height: 0; }
  .rail-head { padding: 12px 12px 8px; }
  .rail-mid {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .rail-foot { padding: 8px 12px; }
  .context {
    grid-area: ctx;
    position: static;
    width: auto;
    box-shadow: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .thread { padding: 22px 16px 12px; }
  .composer-dock { padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .card { margin: 16px 16px 0; }
  .sett-head { padding: 18px 16px 8px; }
  .sett-head h2 { font-size: 26px; }
  .sett-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .sett-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 4px 12px 10px;
  }
  .sett-nav button { flex: 0 0 auto; }
  .sett .pane-body { padding: 4px 16px 32px; }
  .update-banner { margin: 10px 16px 0; flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .welcome-block h2 { font-size: 28px; }
  .welcome-block p { font-size: 17px; }
  .composer-icon { flex-basis: 42px; width: 42px; height: 42px; }
  .composer-talk,
  .composer-send { width: 34px; height: 34px; flex-basis: 34px; }
  #composer { border-radius: 24px; }
}
