:root {
  color-scheme: dark;
  --bg: #1f1f1d;
  --bg-deep: #171716;
  --sidebar: #1b1b1a;
  --sidebar-soft: #20201f;
  --surface: #2b2b29;
  --surface-2: #333230;
  --surface-3: #111110;
  --line: #3b3a37;
  --line-strong: #54514c;
  --text: #eeeeea;
  --text-strong: #faf9f5;
  --muted: #aaa7a0;
  --muted-2: #7f7b73;
  --accent: #d79a52;
  --accent-strong: #f0b35f;
  --accent-soft: rgba(215, 154, 82, 0.16);
  --teal: #8fcfc2;
  --violet: #b7a7ef;
  --green: #a7d88d;
  --danger: #d87070;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Times New Roman", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  letter-spacing: 0;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.app-shell {
  background: var(--bg);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100vh;
  min-height: 620px;
}

.sidebar {
  background: linear-gradient(180deg, #1b1b1a 0%, #171716 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 20px 14px 14px;
}

.inspector {
  display: none;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 38px;
  padding: 0 2px 12px;
}

.brand-mark {
  display: none;
}

.brand-title {
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}

.brand-subtitle {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

.icon-button,
.icon-only {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
  height: 38px;
  justify-content: center;
  padding: 0 11px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.icon-only:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-strong);
}

.icon-button:active,
.icon-only:active {
  transform: translateY(1px);
}

.icon-button.primary {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 560;
  justify-content: flex-start;
}

.icon-button.primary span:first-child {
  align-items: center;
  background: #34332f;
  border-radius: 999px;
  display: inline-grid;
  font-size: 21px;
  height: 28px;
  justify-items: center;
  line-height: 1;
  width: 28px;
}

.icon-button.primary:hover {
  background: #242422;
}

.search-box {
  align-items: center;
  background: #151514;
  border: 1px solid #2e2d2a;
  border-radius: 10px;
  display: flex;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
}

.search-box:focus-within {
  border-color: #76634a;
  box-shadow: 0 0 0 3px rgba(215, 154, 82, 0.12);
}

.search-box span {
  color: var(--muted-2);
  font-size: 18px;
}

.search-box input {
  background: transparent;
  border: 0;
  color: var(--text);
  min-width: 0;
  outline: 0;
  width: 100%;
}

.search-box input::placeholder {
  color: #77736b;
}

.segmented-control {
  background: #151514;
  border: 1px solid #2b2a28;
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 3px;
}

.segment {
  background: transparent;
  border-radius: 8px;
  color: var(--muted-2);
  height: 30px;
  transition: background 140ms ease, color 140ms ease;
}

.segment.active {
  background: #2a2926;
  color: var(--text-strong);
  font-weight: 650;
}

.conversation-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: scroll;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.conversation-card {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: inherit;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.conversation-card:hover {
  background: #252523;
}

.conversation-card.active {
  background: #111110;
  border-color: #24231f;
}

.conversation-card.empty {
  opacity: 0.55;
}

.conversation-card-title {
  color: #d9d7cf;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-card.active .conversation-card-title {
  color: var(--text-strong);
}

.conversation-card-meta,
.conversation-card-snippet {
  color: #8d897f;
  font-size: 12px;
  line-height: 1.45;
}

.conversation-card-snippet {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.reader {
  background: var(--bg);
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.reader-header {
  align-items: center;
  background: rgba(31, 31, 29, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid #2d2c29;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 0 30px 0 34px;
}

.reader-title-block {
  min-width: 0;
}

.kicker {
  display: none;
}

.reader h1 {
  color: var(--text-strong);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
  max-width: 820px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader h1::after {
  color: #bdb8ad;
  content: "⌄";
  font-size: 15px;
  margin-left: 10px;
}

.reader-header p {
  display: none;
}

.reader-tools {
  display: flex;
  gap: 8px;
}

.icon-only {
  background: #232321;
  border-color: #35332f;
  border-radius: 12px;
  color: #d8d5cc;
  font-family: var(--mono);
  font-size: 16px;
  height: 42px;
  padding: 0;
  width: 42px;
}

.thread {
  min-height: 0;
  overflow-y: scroll;
  padding: 30px 44px 92px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.thread-inner {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: 0 auto;
  max-width: 940px;
}

.message {
  color: var(--text);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.avatar {
  display: none;
}

.message-body {
  min-width: 0;
}

.message-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.sender {
  color: #d5d2c9;
  font-size: 13px;
  font-weight: 720;
}

.timestamp,
.message-id {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
}

.message.human {
  display: flex;
  justify-content: flex-end;
}

.message.human .message-body {
  max-width: min(880px, 74%);
}

.message.human .message-head {
  display: none;
}

.message.human .content-block {
  background: #111110;
  border: 1px solid #282722;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  color: var(--text-strong);
  padding: 17px 22px;
}

.message.assistant .message-body {
  max-width: 100%;
}

.message.assistant .sender {
  color: #cfcabe;
}

.content-block {
  background: transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.8;
  max-width: 100%;
}

.content-block + .content-block {
  margin-top: 14px;
}

.rich-text p {
  margin: 0 0 16px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.rich-text p:last-child {
  margin-bottom: 0;
}

.rich-text strong {
  color: var(--text-strong);
  font-weight: 800;
}

.rich-text a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.rich-text code {
  background: #2d2c29;
  border: 1px solid #42403b;
  border-radius: 6px;
  color: #f0dcc2;
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 0.12em 0.34em;
}

.rich-text h2,
.rich-text h3,
.rich-text h4,
.rich-text h5 {
  color: var(--text-strong);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  margin: 28px 0 12px;
}

.rich-text h2:first-child,
.rich-text h3:first-child,
.rich-text h4:first-child,
.rich-text h5:first-child {
  margin-top: 0;
}

.rich-text ul,
.rich-text ol {
  margin: 10px 0 18px 24px;
  padding: 0;
}

.rich-text li {
  margin: 7px 0;
  overflow-wrap: anywhere;
}

.rich-text blockquote {
  border-left: 3px solid var(--line-strong);
  color: #c4bfb4;
  margin: 12px 0 18px;
  padding: 5px 0 5px 14px;
}

.code-block {
  background: #111110;
  border: 1px solid #36342f;
  border-radius: 10px;
  color: #f2eee5;
  margin: 12px 0 18px;
  overflow: auto;
  padding: 16px;
}

.code-block code {
  background: transparent;
  border: 0;
  color: inherit;
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 0;
  white-space: pre;
}

.overview-card {
  background: rgba(42, 41, 38, 0.86);
  border: 1px solid #3b3832;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin: 4px 0 6px;
  overflow: hidden;
}

.overview-card summary {
  align-items: center;
  color: var(--text-strong);
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
  padding: 15px 18px;
}

.overview-card summary::-webkit-details-marker {
  display: none;
}

.overview-card summary span:first-child {
  font-size: 14px;
  font-weight: 780;
}

.overview-card summary span:last-child {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}

.overview-card summary::before {
  color: var(--accent);
  content: "+";
  font-family: var(--mono);
  font-weight: 800;
}

.overview-card[open] summary::before {
  content: "-";
}

.overview-body {
  border-top: 1px solid #393731;
  padding: 18px;
}

.overview-body .rich-text {
  color: #cfcbc0;
  font-size: 15px;
  line-height: 1.75;
}

.thinking-block {
  background: rgba(94, 82, 142, 0.16);
  border: 1px solid rgba(183, 167, 239, 0.18);
  border-radius: 12px;
  margin: 0 0 14px;
  overflow: hidden;
}

.thinking-block summary {
  color: var(--violet);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
  list-style: none;
  padding: 11px 13px;
}

.thinking-block summary::-webkit-details-marker {
  display: none;
}

.thinking-block summary::before {
  content: "+";
  display: inline-block;
  font-family: var(--mono);
  margin-right: 8px;
}

.thinking-block[open] summary::before {
  content: "-";
}

.thinking-content {
  border-top: 1px solid rgba(183, 167, 239, 0.15);
  color: #c8bff0;
  font-size: 13px;
  line-height: 1.7;
  padding: 13px;
}

.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file-chip {
  align-items: center;
  background: rgba(143, 207, 194, 0.12);
  border: 1px solid rgba(143, 207, 194, 0.22);
  border-radius: 999px;
  color: var(--teal);
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  max-width: 100%;
  padding: 5px 9px;
}

.file-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  align-items: center;
  border: 1px dashed #4a4740;
  border-radius: 14px;
  color: var(--muted);
  display: grid;
  justify-items: center;
  margin: 10vh auto 0;
  max-width: 520px;
  min-height: 220px;
  padding: 28px;
  text-align: center;
}

.empty-state strong {
  color: var(--text-strong);
  display: block;
  font-size: 18px;
  margin-bottom: 8px;
}

.panel,
.stat-grid,
.small-text,
.memory-text {
  color: var(--muted);
}

.drop-zone {
  align-items: center;
  background: rgba(0, 0, 0, 0.58);
  display: none;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 20;
}

.drop-zone.visible {
  display: flex;
}

.drop-card {
  align-items: center;
  background: #252522;
  border: 1px solid #3c3932;
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--text-strong);
  display: grid;
  font-weight: 700;
  gap: 10px;
  justify-items: center;
  min-width: 260px;
  padding: 28px;
}

.drop-icon {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(215, 154, 82, 0.28);
  border-radius: 10px;
  color: var(--accent-strong);
  display: grid;
  font-family: var(--mono);
  font-size: 24px;
  height: 44px;
  justify-items: center;
  width: 44px;
}

.toast {
  background: #111110;
  border: 1px solid #33312c;
  border-radius: 12px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: var(--text-strong);
  font-size: 13px;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  opacity: 0;
  padding: 11px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 30;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

::-webkit-scrollbar {
  height: 13px;
  width: 13px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  background: #6b675f;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #8a857a;
  border: 3px solid transparent;
  background-clip: content-box;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .thread {
    padding-left: 30px;
    padding-right: 30px;
  }

  .message.human .message-body {
    max-width: 84%;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: 44vh;
  }

  .reader {
    min-height: 56vh;
  }

  .reader-header {
    padding: 0 18px;
  }

  .reader h1 {
    font-size: 16px;
  }

  .thread {
    padding: 22px 18px 50px;
  }

  .content-block {
    font-size: 16px;
  }

  .message.human .message-body {
    max-width: 92%;
  }
}

.theme-button {
  align-items: center;
  background: #232321;
  border: 1px solid #35332f;
  border-radius: 12px;
  color: #d8d5cc;
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  height: 42px;
  justify-content: center;
  min-width: 106px;
  padding: 0 14px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

.theme-button:hover {
  background: #2d2c29;
  border-color: #5a554b;
  color: var(--text-strong);
}

.theme-button:active {
  transform: translateY(1px);
}

:root[data-theme="paper"] {
  color-scheme: light;
  --bg: #f4efe5;
  --bg-deep: #e7ddcd;
  --sidebar: #eee6d8;
  --surface: #fffaf1;
  --surface-2: #f0e5d5;
  --surface-3: #efe3d1;
  --line: #d8cbbb;
  --line-strong: #bbaa95;
  --text: #2b251f;
  --text-strong: #1f1a16;
  --muted: #756b5f;
  --muted-2: #918678;
  --accent: #b85f35;
  --accent-strong: #944725;
  --accent-soft: rgba(184, 95, 53, 0.14);
  --teal: #287f74;
  --violet: #6d5ca8;
  --shadow: 0 20px 54px rgba(71, 53, 33, 0.12);
}

:root[data-theme="paper"] body,
:root[data-theme="paper"] .app-shell,
:root[data-theme="paper"] .reader {
  background: var(--bg);
  color: var(--text);
}

:root[data-theme="paper"] .sidebar {
  background: linear-gradient(180deg, #f1eadf 0%, #e8dece 100%);
  border-right-color: var(--line);
}

:root[data-theme="paper"] .brand-title,
:root[data-theme="paper"] .reader h1,
:root[data-theme="paper"] .rich-text strong,
:root[data-theme="paper"] .rich-text h2,
:root[data-theme="paper"] .rich-text h3,
:root[data-theme="paper"] .rich-text h4,
:root[data-theme="paper"] .rich-text h5,
:root[data-theme="paper"] .empty-state strong {
  color: var(--text-strong);
}

:root[data-theme="paper"] .reader-header {
  background: rgba(244, 239, 229, 0.9);
  border-bottom-color: var(--line);
}

:root[data-theme="paper"] .search-box,
:root[data-theme="paper"] .segmented-control {
  background: #fbf5ec;
  border-color: var(--line);
}

:root[data-theme="paper"] .search-box input {
  color: var(--text);
}

:root[data-theme="paper"] .segment.active,
:root[data-theme="paper"] .conversation-card:hover,
:root[data-theme="paper"] .icon-button:hover {
  background: #fffaf1;
  color: var(--text-strong);
}

:root[data-theme="paper"] .conversation-card.active {
  background: #fff9ee;
  border-color: #dfc2a4;
}

:root[data-theme="paper"] .conversation-card-title {
  color: #4b4036;
}

:root[data-theme="paper"] .conversation-card.active .conversation-card-title {
  color: var(--text-strong);
}

:root[data-theme="paper"] .conversation-card-meta,
:root[data-theme="paper"] .conversation-card-snippet,
:root[data-theme="paper"] .timestamp,
:root[data-theme="paper"] .message-id {
  color: var(--muted-2);
}

:root[data-theme="paper"] .message.human .content-block {
  background: #fffaf1;
  border-color: #dac8b5;
  color: var(--text-strong);
  box-shadow: 0 16px 38px rgba(72, 50, 28, 0.1);
}

:root[data-theme="paper"] .content-block,
:root[data-theme="paper"] .overview-body .rich-text,
:root[data-theme="paper"] .sender {
  color: var(--text);
}

:root[data-theme="paper"] .overview-card,
:root[data-theme="paper"] .drop-card,
:root[data-theme="paper"] .toast {
  background: #fffaf1;
  border-color: var(--line);
  color: var(--text-strong);
}

:root[data-theme="paper"] .overview-body,
:root[data-theme="paper"] .thinking-content {
  border-top-color: var(--line);
}

:root[data-theme="paper"] .thinking-block {
  background: rgba(109, 92, 168, 0.08);
  border-color: rgba(109, 92, 168, 0.18);
}

:root[data-theme="paper"] .thinking-content {
  color: #514976;
}

:root[data-theme="paper"] .rich-text code {
  background: #eee4d5;
  border-color: #d9c8b3;
  color: #5b3929;
}

:root[data-theme="paper"] .code-block {
  background: #24211d;
  border-color: #3f352c;
  color: #f8f2e9;
}

:root[data-theme="paper"] .theme-button,
:root[data-theme="paper"] .icon-only {
  background: #fffaf1;
  border-color: #d8cbbb;
  color: #4b4036;
}

:root[data-theme="paper"] ::-webkit-scrollbar-track {
  background: rgba(94, 74, 51, 0.08);
}

:root[data-theme="paper"] ::-webkit-scrollbar-thumb {
  background: #b7aa98;
  border: 3px solid transparent;
  background-clip: content-box;
}

:root[data-theme="terminal"] {
  color-scheme: dark;
  --bg: #090b0a;
  --bg-deep: #050605;
  --sidebar: #080908;
  --surface: #111512;
  --surface-2: #171d19;
  --surface-3: #050605;
  --line: #263129;
  --line-strong: #3d5446;
  --text: #d8f6df;
  --text-strong: #f1fff4;
  --muted: #8dab95;
  --muted-2: #617b69;
  --accent: #67d98d;
  --accent-strong: #91f2ae;
  --accent-soft: rgba(103, 217, 141, 0.14);
  --teal: #7ee7d1;
  --violet: #bca8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

:root[data-theme="terminal"] body,
:root[data-theme="terminal"] .app-shell,
:root[data-theme="terminal"] .reader {
  background: var(--bg);
}

:root[data-theme="terminal"] .sidebar {
  background: linear-gradient(180deg, #0a0c0b 0%, #050605 100%);
  border-right-color: var(--line);
}

:root[data-theme="terminal"] .reader-header {
  background: rgba(9, 11, 10, 0.92);
  border-bottom-color: var(--line);
}

:root[data-theme="terminal"] .brand-title,
:root[data-theme="terminal"] .reader h1,
:root[data-theme="terminal"] .conversation-card.active .conversation-card-title,
:root[data-theme="terminal"] .rich-text strong,
:root[data-theme="terminal"] .rich-text h2,
:root[data-theme="terminal"] .rich-text h3,
:root[data-theme="terminal"] .rich-text h4,
:root[data-theme="terminal"] .rich-text h5 {
  color: var(--text-strong);
}

:root[data-theme="terminal"] .brand-title,
:root[data-theme="terminal"] .reader h1,
:root[data-theme="terminal"] .content-block {
  font-family: var(--mono);
}

:root[data-theme="terminal"] .search-box,
:root[data-theme="terminal"] .segmented-control,
:root[data-theme="terminal"] .conversation-card.active,
:root[data-theme="terminal"] .message.human .content-block,
:root[data-theme="terminal"] .overview-card,
:root[data-theme="terminal"] .theme-button,
:root[data-theme="terminal"] .icon-only,
:root[data-theme="terminal"] .toast {
  background: #070907;
  border-color: var(--line-strong);
}

:root[data-theme="terminal"] .conversation-card:hover,
:root[data-theme="terminal"] .segment.active,
:root[data-theme="terminal"] .icon-button:hover,
:root[data-theme="terminal"] .theme-button:hover,
:root[data-theme="terminal"] .icon-only:hover {
  background: #121713;
  border-color: var(--line-strong);
}

:root[data-theme="terminal"] .message.human .content-block {
  color: var(--text-strong);
  box-shadow: 0 0 0 1px rgba(103, 217, 141, 0.08), 0 18px 50px rgba(0, 0, 0, 0.45);
}

:root[data-theme="terminal"] .overview-body,
:root[data-theme="terminal"] .thinking-content {
  border-top-color: var(--line);
}

:root[data-theme="terminal"] .thinking-block {
  background: rgba(103, 217, 141, 0.08);
  border-color: rgba(103, 217, 141, 0.18);
}

:root[data-theme="terminal"] .thinking-block summary,
:root[data-theme="terminal"] .overview-card summary::before,
:root[data-theme="terminal"] .file-chip {
  color: var(--accent-strong);
}

:root[data-theme="terminal"] .rich-text code,
:root[data-theme="terminal"] .code-block {
  background: #050605;
  border-color: var(--line-strong);
  color: var(--accent-strong);
}

:root[data-theme="terminal"] ::-webkit-scrollbar-track {
  background: rgba(103, 217, 141, 0.05);
}

:root[data-theme="terminal"] ::-webkit-scrollbar-thumb {
  background: #3d5446;
  border: 3px solid transparent;
  background-clip: content-box;
}

@media (max-width: 760px) {
  .theme-button {
    min-width: 88px;
    padding: 0 10px;
  }
}

/* Account-aware overview rail */
.app-shell {
  grid-template-columns: 300px minmax(0, 1fr) 300px;
}

.inspector {
  background: rgba(23, 23, 22, 0.96);
  border-left: 1px solid var(--line);
  display: block;
  min-width: 0;
  overflow-y: scroll;
  padding: 18px 14px;
  scrollbar-gutter: stable;
}

.panel {
  background: rgba(43, 43, 41, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 14px;
}

.panel-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-item {
  background: rgba(17, 17, 16, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 11px;
}

.stat-value {
  color: var(--text-strong);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.account-switch {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.account-switch span {
  color: var(--muted-2);
  font-size: 12px;
}

.account-switch select {
  appearance: none;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text-strong);
  font: inherit;
  height: 38px;
  outline: 0;
  padding: 0 34px 0 11px;
  width: 100%;
}

.account-switch::after {
  align-self: end;
  color: var(--muted);
  content: "⌄";
  justify-self: end;
  margin: 0 12px 10px 0;
  pointer-events: none;
}

.small-text,
.memory-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.small-text strong {
  color: var(--text-strong);
  display: block;
  font-size: 15px;
  margin-bottom: 5px;
}

.memory-text {
  max-height: 460px;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  white-space: pre-wrap;
}

:root[data-theme="paper"] .inspector {
  background: rgba(244, 239, 229, 0.96);
  border-left-color: var(--line);
}

:root[data-theme="paper"] .panel {
  background: #fffaf1;
  border-color: var(--line);
}

:root[data-theme="paper"] .stat-item {
  background: #f2eadf;
  border-color: #e5d7c5;
}

:root[data-theme="paper"] .account-switch select {
  background: #fbf5ec;
  border-color: var(--line);
  color: var(--text-strong);
}

:root[data-theme="terminal"] .inspector {
  background: rgba(5, 6, 5, 0.96);
  border-left-color: var(--line);
}

:root[data-theme="terminal"] .panel,
:root[data-theme="terminal"] .stat-item {
  background: rgba(7, 9, 7, 0.86);
  border-color: var(--line-strong);
}

:root[data-theme="terminal"] .account-switch select {
  background: #050605;
  border-color: var(--line-strong);
  color: var(--text-strong);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 270px minmax(0, 1fr) 280px;
  }

  .thread {
    padding-left: 26px;
    padding-right: 26px;
  }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: 42vh;
  }

  .reader {
    min-height: 58vh;
  }

  .inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
    display: block;
  }
}

/* Scroll reliability fixes */
html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  overflow: hidden;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar,
.reader,
.inspector {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
}

.sidebar {
  overflow: hidden;
}

.reader {
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
}

.conversation-list,
.thread,
.inspector,
.memory-text {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.conversation-list,
.thread,
.inspector {
  overflow-y: auto;
}

.thread {
  height: 100%;
}

.memory-text {
  overflow-y: auto;
}

@media (max-width: 920px) {
  body {
    overflow-y: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    height: 42dvh;
    max-height: 42dvh;
    min-height: 280px;
    overflow: hidden;
  }

  .reader {
    height: 58dvh;
    max-height: 58dvh;
    min-height: 420px;
    overflow: hidden;
  }

  .inspector {
    height: auto;
    max-height: none;
    min-height: auto;
    overflow: visible;
  }

  .memory-text {
    max-height: 360px;
  }
}

.knowledge-panel {
  display: grid;
  gap: 12px;
}

.knowledge-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-button,
.save-note-button {
  align-items: center;
  background: rgba(17, 17, 16, 0.72);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 680;
  height: 36px;
  justify-content: center;
  line-height: 1;
  min-width: 0;
  padding: 0 10px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
  white-space: nowrap;
  word-break: keep-all;
}

.mini-button:hover,
.save-note-button:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.mini-button:active,
.save-note-button:active {
  transform: translateY(1px);
}

.mini-button.active {
  background: var(--accent-soft);
  border-color: rgba(215, 154, 82, 0.44);
  color: var(--accent-strong);
}
.mini-button.danger {
  color: var(--danger);
}

.mini-button.danger:hover {
  border-color: rgba(216, 112, 112, 0.44);
  color: #ef9a9a;
}

.knowledge-field {
  display: grid;
  gap: 7px;
}

.knowledge-field span {
  color: var(--muted-2);
  font-size: 12px;
}

.knowledge-field input,
.knowledge-field textarea {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  outline: 0;
  padding: 10px 11px;
  width: 100%;
}

.knowledge-field input {
  height: 38px;
}

.knowledge-field textarea {
  line-height: 1.55;
  max-height: 260px;
  min-height: 150px;
  resize: vertical;
}

.knowledge-field input:focus,
.knowledge-field textarea:focus {
  border-color: #76634a;
  box-shadow: 0 0 0 3px rgba(215, 154, 82, 0.12);
}

.knowledge-field input::placeholder,
.knowledge-field textarea::placeholder {
  color: var(--muted-2);
}

.save-note-button {
  background: var(--accent-soft);
  border-color: rgba(215, 154, 82, 0.34);
  color: var(--accent-strong);
  font-weight: 720;
  width: 100%;
}

.kb-status {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  min-height: 16px;
  overflow-wrap: anywhere;
}

:root[data-theme="paper"] .mini-button,
:root[data-theme="paper"] .save-note-button,
:root[data-theme="paper"] .knowledge-field input,
:root[data-theme="paper"] .knowledge-field textarea {
  background: #fbf5ec;
  border-color: var(--line);
  color: var(--text-strong);
}

:root[data-theme="paper"] .mini-button.active,
:root[data-theme="paper"] .save-note-button {
  background: #f5eadc;
  border-color: #d8b483;
  color: #8a5a21;
}

:root[data-theme="terminal"] .mini-button,
:root[data-theme="terminal"] .save-note-button,
:root[data-theme="terminal"] .knowledge-field input,
:root[data-theme="terminal"] .knowledge-field textarea {
  background: #050605;
  border-color: var(--line-strong);
  color: var(--text-strong);
}

:root[data-theme="terminal"] .mini-button.active,
:root[data-theme="terminal"] .save-note-button {
  background: rgba(103, 217, 141, 0.08);
  border-color: rgba(103, 217, 141, 0.38);
  color: var(--accent-strong);
}
.conversation-card.pinned {
  border-color: rgba(215, 154, 82, 0.26);
}

.conversation-card-title {
  align-items: center;
  display: flex;
  gap: 7px;
}

.pin-mark {
  background: var(--accent-soft);
  border: 1px solid rgba(215, 154, 82, 0.36);
  border-radius: 6px;
  color: var(--accent-strong);
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 760;
  line-height: 1;
  padding: 3px 4px;
}
.conversation-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-chip {
  align-items: center;
  background: #232321;
  border: 1px solid #35332f;
  border-radius: 12px;
  color: #d8d5cc;
  display: inline-flex;
  font-size: 13px;
  font-weight: 720;
  height: 42px;
  justify-content: center;
  min-width: 58px;
  padding: 0 13px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.action-chip:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.action-chip.active {
  background: var(--accent-soft);
  border-color: rgba(215, 154, 82, 0.48);
  color: var(--accent-strong);
}
.action-chip.danger {
  color: var(--danger);
  min-width: 52px;
}

.action-chip.danger:hover {
  border-color: rgba(216, 112, 112, 0.44);
  color: #ef9a9a;
}

.conversation-card {
  cursor: pointer;
}

.conversation-card:focus-visible {
  border-color: var(--accent);
  outline: 0;
}

.conversation-card.favorited {
  border-color: rgba(143, 207, 194, 0.28);
}

.conversation-card.pinned.favorited {
  border-color: rgba(215, 154, 82, 0.36);
}

.conversation-card-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.card-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.card-action {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  height: 24px;
  line-height: 1;
  padding: 0 7px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.card-action:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.card-action.active,
.card-action.pin.active {
  background: var(--accent-soft);
  border-color: rgba(215, 154, 82, 0.48);
  color: var(--accent-strong);
}

.card-action.favorite.active {
  background: rgba(143, 207, 194, 0.14);
  border-color: rgba(143, 207, 194, 0.42);
  color: var(--teal);
}
.card-action.delete {
  color: var(--danger);
}

.card-action.delete:hover {
  border-color: rgba(216, 112, 112, 0.42);
  color: #ef9a9a;
}

.fav-mark {
  background: rgba(143, 207, 194, 0.12);
  border: 1px solid rgba(143, 207, 194, 0.36);
  border-radius: 6px;
  color: var(--teal);
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 760;
  line-height: 1;
  padding: 3px 4px;
}

.knowledge-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

:root[data-theme="paper"] .action-chip,
:root[data-theme="paper"] .card-action {
  background: #fbf5ec;
  border-color: var(--line);
  color: var(--muted);
}

:root[data-theme="paper"] .action-chip.active,
:root[data-theme="paper"] .card-action.active,
:root[data-theme="paper"] .card-action.pin.active {
  background: #f5eadc;
  border-color: #d8b483;
  color: #8a5a21;
}

:root[data-theme="terminal"] .action-chip,
:root[data-theme="terminal"] .card-action {
  background: #050605;
  border-color: var(--line-strong);
  color: var(--muted);
}

:root[data-theme="terminal"] .action-chip.active,
:root[data-theme="terminal"] .card-action.active,
:root[data-theme="terminal"] .card-action.pin.active {
  background: rgba(103, 217, 141, 0.08);
  border-color: rgba(103, 217, 141, 0.38);
  color: var(--accent-strong);
}

@media (max-width: 760px) {
  .reader-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .action-chip {
    height: 36px;
    min-width: 50px;
    padding: 0 10px;
  }

  .card-actions {
    margin-top: 4px;
  }

  .conversation-card-row {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
  }
}
/* Filter layout polish */
.segmented-control {
  display: flex;
  gap: 3px;
  grid-template-columns: none;
  overflow: hidden;
}

.segment {
  align-items: center;
  display: inline-flex;
  flex: 1 1 0;
  font-size: 13px;
  font-weight: 680;
  justify-content: center;
  line-height: 1;
  min-width: 0;
  padding: 0 5px;
  white-space: nowrap;
  word-break: keep-all;
}

.conversation-card {
  gap: 7px;
  padding: 12px 12px;
}

.conversation-card-row {
  align-items: start;
  gap: 10px;
}

.conversation-card-title {
  min-width: 0;
}

.card-actions {
  opacity: 0.74;
  transition: opacity 140ms ease;
}

.conversation-card:hover .card-actions,
.conversation-card.active .card-actions {
  opacity: 1;
}

@media (max-width: 1180px) {
  .segment {
    font-size: 12px;
    padding: 0 4px;
  }

  .card-actions {
    margin-top: 2px;
  }

  .conversation-card-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* Confirm dialog polish */
.confirm-layer {
  align-items: center;
  background: rgba(8, 8, 7, 0.58);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 28;
}

.confirm-layer.visible {
  display: flex;
}

.confirm-card {
  background: #1f1f1d;
  border: 1px solid #3e3c37;
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.54);
  color: var(--text);
  display: grid;
  gap: 14px;
  grid-template-columns: 38px minmax(0, 1fr);
  max-width: min(520px, calc(100vw - 32px));
  padding: 20px;
  width: 100%;
}

.confirm-mark {
  align-items: center;
  background: rgba(216, 112, 112, 0.12);
  border: 1px solid rgba(216, 112, 112, 0.34);
  border-radius: 12px;
  color: #ef9a9a;
  display: grid;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  height: 38px;
  justify-items: center;
  width: 38px;
}

.confirm-copy {
  min-width: 0;
}

.confirm-title {
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 780;
  line-height: 1.25;
  margin-bottom: 7px;
}

.confirm-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 2px;
}

.confirm-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  font-size: 14px;
  font-weight: 760;
  height: 40px;
  justify-content: center;
  min-width: 86px;
  padding: 0 16px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

.confirm-button:active {
  transform: translateY(1px);
}

.confirm-button.ghost {
  background: transparent;
  color: var(--muted);
}

.confirm-button.ghost:hover,
.confirm-button.ghost:focus-visible {
  background: var(--surface-2);
  color: var(--text-strong);
}

.confirm-button.danger {
  background: rgba(216, 112, 112, 0.14);
  border-color: rgba(216, 112, 112, 0.42);
  color: #ef9a9a;
}

.confirm-button.danger:hover,
.confirm-button.danger:focus-visible {
  background: rgba(216, 112, 112, 0.22);
  border-color: rgba(216, 112, 112, 0.58);
  color: #ffd2d2;
}

.confirm-button:focus-visible {
  outline: 2px solid rgba(215, 154, 82, 0.55);
  outline-offset: 2px;
}

:root[data-theme="paper"] .confirm-layer {
  background: rgba(61, 48, 32, 0.38);
}

:root[data-theme="paper"] .confirm-card {
  background: #fffaf1;
  border-color: #dfcdb7;
  box-shadow: 0 24px 70px rgba(72, 50, 28, 0.2);
}

:root[data-theme="paper"] .confirm-button.ghost {
  background: #fbf5ec;
  color: var(--muted);
}

:root[data-theme="paper"] .confirm-button.ghost:hover,
:root[data-theme="paper"] .confirm-button.ghost:focus-visible {
  background: #f2eadf;
  color: var(--text-strong);
}

:root[data-theme="terminal"] .confirm-layer {
  background: rgba(0, 0, 0, 0.68);
}

:root[data-theme="terminal"] .confirm-card {
  background: #050605;
  border-color: var(--line-strong);
}

:root[data-theme="terminal"] .confirm-button.ghost {
  background: #050605;
  border-color: var(--line-strong);
}

@media (max-width: 560px) {
  .confirm-card {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .confirm-button {
    min-width: 0;
    width: 100%;
  }
}

/* Login gate */
body.auth-loading .app-shell,
body.auth-locked .app-shell {
  display: none;
}

.login-screen {
  align-items: center;
  background: radial-gradient(circle at 50% 20%, rgba(215, 154, 82, 0.08), transparent 34%), var(--bg);
  display: none;
  min-height: 100dvh;
  padding: 24px;
  justify-content: center;
}

body.auth-loading .login-screen,
body.auth-locked .login-screen {
  display: flex;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-brand {
  color: var(--accent-strong);
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 760;
  line-height: 1;
}

.login-card h1 {
  color: var(--text-strong);
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
}

.login-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 4px;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field span,
.remember-row,
.login-status {
  color: var(--muted-2);
  font-size: 13px;
}

.login-field input {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  height: 42px;
  outline: 0;
  padding: 0 12px;
}

.login-field input:focus {
  border-color: #76634a;
  box-shadow: 0 0 0 3px rgba(215, 154, 82, 0.12);
}

.remember-row {
  align-items: center;
  display: flex;
  gap: 9px;
}

.login-button {
  background: var(--accent-soft);
  border: 1px solid rgba(215, 154, 82, 0.42);
  border-radius: 11px;
  color: var(--accent-strong);
  font-weight: 780;
  height: 42px;
}

.login-button:hover {
  background: rgba(215, 154, 82, 0.22);
}

.login-status {
  min-height: 18px;
}

:root[data-theme="paper"] .login-screen {
  background: #f7efe4;
}

:root[data-theme="paper"] .login-card {
  background: #fffaf1;
  border-color: var(--line);
}

:root[data-theme="paper"] .login-field input {
  background: #fbf5ec;
  color: var(--text-strong);
}

:root[data-theme="terminal"] .login-screen {
  background: #050605;
}

:root[data-theme="terminal"] .login-card,
:root[data-theme="terminal"] .login-field input {
  background: #070907;
  border-color: var(--line-strong);
}
/* UI polish pass */
.reader-tools {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-chip.session {
  background: transparent;
  border-color: transparent;
  color: var(--muted-2);
  min-width: 44px;
  padding: 0 8px;
}

.action-chip.session:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.login-screen {
  background: var(--bg-deep);
  padding: 28px;
}

.login-card {
  background: #20201e;
  border-color: #34322e;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  gap: 13px;
  max-width: 430px;
  padding: 30px;
}

.login-brand {
  color: var(--text-strong);
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: 0;
}

.login-meta {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  margin-top: -8px;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: 22px;
  margin-top: 6px;
}

.login-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 6px;
}

.login-field span {
  color: var(--muted);
  font-weight: 650;
}

.login-field input {
  background: #151514;
  border-color: #37342f;
  border-radius: 10px;
  height: 44px;
}

.login-field input:focus {
  border-color: rgba(215, 154, 82, 0.72);
  box-shadow: 0 0 0 3px rgba(215, 154, 82, 0.13);
}

.remember-row {
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

.remember-row input {
  accent-color: var(--accent);
  height: 16px;
  width: 16px;
}

.login-button {
  background: #d79a52;
  border-color: #d79a52;
  border-radius: 10px;
  color: #1b1208;
  margin-top: 2px;
}

.login-button:hover {
  background: #efb162;
  border-color: #efb162;
}

.login-button:disabled {
  opacity: 0.58;
}

.login-status {
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.45;
}

.confirm-layer {
  background: rgba(9, 9, 8, 0.54);
  backdrop-filter: blur(2px);
}

.confirm-card {
  border-radius: 14px;
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.42);
  gap: 12px;
  max-width: min(480px, calc(100vw - 32px));
  padding: 18px;
}

.confirm-mark {
  border-radius: 10px;
  height: 34px;
  width: 34px;
}

.confirm-title {
  font-size: 17px;
  margin-bottom: 5px;
}

.confirm-body {
  font-size: 13px;
  line-height: 1.65;
}

.confirm-actions {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 14px;
}

.confirm-button {
  border-radius: 9px;
  height: 38px;
  min-width: 78px;
}

.confirm-button.ghost {
  background: var(--surface-3);
  border-color: var(--line);
}

.confirm-button.danger {
  background: #c95f5f;
  border-color: #c95f5f;
  color: #fff6f6;
}

.confirm-button.danger:hover,
.confirm-button.danger:focus-visible {
  background: #dd7373;
  border-color: #dd7373;
  color: #fff;
}

:root[data-theme="paper"] .login-screen {
  background: #f4eddf;
}

:root[data-theme="paper"] .login-card {
  background: #fffaf1;
  border-color: #ddcbb6;
  box-shadow: 0 24px 64px rgba(89, 62, 31, 0.16);
}

:root[data-theme="paper"] .login-brand,
:root[data-theme="paper"] .login-card h1 {
  color: #29231d;
}

:root[data-theme="paper"] .login-field input {
  background: #fbf5ec;
  border-color: #dccab5;
}

:root[data-theme="paper"] .confirm-card {
  border-radius: 14px;
}

:root[data-theme="paper"] .confirm-actions {
  border-top-color: #e3d3c0;
}

:root[data-theme="terminal"] .login-screen {
  background: #050605;
}

:root[data-theme="terminal"] .login-card {
  background: #070907;
  border-color: var(--line-strong);
}

:root[data-theme="terminal"] .login-button {
  background: rgba(103, 217, 141, 0.18);
  border-color: rgba(103, 217, 141, 0.48);
  color: var(--accent-strong);
}

@media (max-width: 760px) {
  .login-screen {
    padding: 16px;
  }

  .login-card {
    padding: 22px;
  }

  .login-brand {
    font-size: 26px;
  }

  .reader-tools {
    gap: 6px;
  }
}
/* Selection visibility polish */
.conversation-card {
  position: relative;
}

.conversation-card.active {
  background: linear-gradient(90deg, rgba(215, 154, 82, 0.18) 0, rgba(34, 33, 31, 0.98) 22%, #22211f 100%);
  border-color: rgba(215, 154, 82, 0.68);
  box-shadow: inset 4px 0 0 var(--accent), 0 0 0 1px rgba(215, 154, 82, 0.14), 0 10px 28px rgba(0, 0, 0, 0.24);
}

.conversation-card.active:hover {
  background: linear-gradient(90deg, rgba(215, 154, 82, 0.22) 0, rgba(38, 36, 33, 0.98) 22%, #262421 100%);
  border-color: rgba(240, 179, 95, 0.78);
}

.conversation-card.active .conversation-card-title,
.conversation-card.active .conversation-title-text {
  color: var(--text-strong);
}

.conversation-card.active .conversation-card-meta {
  color: #c9c2b5;
}

.conversation-card.active .conversation-card-snippet {
  color: #aba397;
}

.conversation-card.active .card-actions {
  opacity: 1;
}

:root[data-theme="paper"] .conversation-card.active {
  background: linear-gradient(90deg, rgba(190, 121, 45, 0.18) 0, #fff7eb 24%, #fffaf1 100%);
  border-color: #c8914e;
  box-shadow: inset 4px 0 0 #b8732f, 0 0 0 1px rgba(184, 115, 47, 0.12), 0 10px 24px rgba(91, 62, 29, 0.12);
}

:root[data-theme="paper"] .conversation-card.active .conversation-card-meta,
:root[data-theme="paper"] .conversation-card.active .conversation-card-snippet {
  color: #7d7163;
}

:root[data-theme="terminal"] .conversation-card.active {
  background: linear-gradient(90deg, rgba(103, 217, 141, 0.14) 0, #0d130f 24%, #090b0a 100%);
  border-color: rgba(103, 217, 141, 0.56);
  box-shadow: inset 4px 0 0 var(--accent-strong), 0 0 0 1px rgba(103, 217, 141, 0.12), 0 10px 28px rgba(0, 0, 0, 0.32);
}

:root[data-theme="terminal"] .conversation-card.active .conversation-card-meta,
:root[data-theme="terminal"] .conversation-card.active .conversation-card-snippet {
  color: #9da89f;
}
/* Header overlap fix */
.reader-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.reader-title-block {
  min-width: 0;
  overflow: hidden;
}

.reader h1 {
  max-width: none;
  min-width: 0;
}

.reader-tools {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
  max-width: min(760px, 52vw);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: none;
  white-space: nowrap;
}

.reader-tools::-webkit-scrollbar {
  display: none;
}

.reader-tools > * {
  flex: 0 0 auto;
}

@media (max-width: 1280px) {
  .reader-header {
    grid-template-columns: minmax(160px, 1fr) auto;
    padding-left: 26px;
    padding-right: 18px;
  }

  .reader-tools {
    max-width: 48vw;
  }

  .theme-button {
    min-width: 92px;
    padding: 0 10px;
  }

  .action-chip {
    min-width: 50px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (max-width: 960px) {
  .reader {
    grid-template-rows: 104px minmax(0, 1fr);
  }

  .reader-header {
    align-content: center;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
    padding-bottom: 10px;
    padding-top: 10px;
  }

  .reader-tools {
    justify-content: flex-start;
    max-width: 100%;
    width: 100%;
  }
}
/* Global pinned filter polish */
.segmented-control {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.segmented-control::-webkit-scrollbar {
  display: none;
}

.segment[data-filter="globalPinned"] {
  flex: 1.25 0 auto;
  min-width: 68px;
}

.segment[data-filter="globalPinned"].active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

:root[data-theme="paper"] .segment[data-filter="globalPinned"].active {
  background: #f5eadc;
  color: #8a5a21;
}

:root[data-theme="terminal"] .segment[data-filter="globalPinned"].active {
  background: rgba(103, 217, 141, 0.1);
  color: var(--accent-strong);
}

/* Chat composer */
.thread-inner .thread-notice {
  margin-top: 4vh;
  width: 100%;
}

.chat-composer {
  background: #171715;
  border: 1px solid #34322e;
  border-radius: 24px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 14px;
  padding: 15px;
  position: relative;
}

.chat-composer:focus-within {
  border-color: rgba(215, 154, 82, 0.58);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(215, 154, 82, 0.12);
}

.composer-input {
  background: transparent;
  border: 0;
  color: var(--text-strong);
  font: inherit;
  font-size: 16px;
  line-height: 1.65;
  max-height: 190px;
  min-height: 58px;
  outline: 0;
  overflow-y: auto;
  resize: none;
  width: 100%;
}

.composer-input::placeholder {
  color: var(--muted-2);
}

.composer-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.composer-model {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 720;
  gap: 8px;
  min-width: 0;
}

.model-dot {
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(215, 154, 82, 0.12);
  height: 8px;
  width: 8px;
}

.composer-send {
  align-items: center;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #17120b;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 42px;
}

.composer-send:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.chat-composer.busy .model-dot {
  animation: composerPulse 1s ease-in-out infinite;
}

.chat-composer textarea:disabled,
.chat-composer button:disabled {
  cursor: wait;
  opacity: 0.68;
}

@keyframes composerPulse {
  0%, 100% { opacity: 0.48; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1.08); }
}

:root[data-theme="paper"] .chat-composer {
  background: #fffaf1;
  border-color: #dfcdb8;
  box-shadow: 0 18px 42px rgba(95, 68, 34, 0.12);
}

:root[data-theme="paper"] .chat-composer:focus-within {
  border-color: #c8914e;
  box-shadow: 0 18px 42px rgba(95, 68, 34, 0.14), 0 0 0 1px rgba(184, 115, 47, 0.12);
}

:root[data-theme="paper"] .composer-send {
  color: #fffaf1;
}

:root[data-theme="terminal"] .chat-composer {
  background: #050605;
  border-color: var(--line-strong);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.42);
}

:root[data-theme="terminal"] .chat-composer:focus-within {
  border-color: rgba(103, 217, 141, 0.56);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.46), 0 0 0 1px rgba(103, 217, 141, 0.14);
}

:root[data-theme="terminal"] .composer-send {
  color: #061009;
}

@media (max-width: 720px) {
  .chat-composer {
    border-radius: 18px;
    margin-bottom: 4px;
    padding: 12px;
  }

  .composer-input {
    font-size: 15px;
    min-height: 52px;
  }
}