:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --paper-deep: #eeeae0;
  --surface: #fffdf8;
  --ink: #292722;
  --muted: #777168;
  --line: #ded9cf;
  --accent: #c76845;
  --accent-dark: #a94d2f;
  --user: #ebe7dd;
  --danger: #a63e32;
  --paper-rgb: 247, 244, 237;
  --surface-rgb: 255, 253, 248;
  --ink-rgb: 41, 39, 34;
  --panel-soft: rgba(var(--surface-rgb), 0.56);
  --panel: rgba(var(--surface-rgb), 0.72);
  --panel-strong: rgba(var(--surface-rgb), 0.96);
  --hover: rgba(var(--ink-rgb), 0.07);
  --field: #fbf9f4;
  --accent-soft: #f3e6df;
  --accent-selected: #f7eae3;
  --neutral-soft: #f1ece3;
  --neutral-muted: #eee8dd;
  --composer-border: #d8d2c7;
  --focus-border: #bcae9d;
  --placeholder: #9a948a;
  --subtle-text: #69645b;
  --success: #4f7650;
  --success-soft: #e8efe3;
  --danger-soft: #fff0eb;
  --switch-off: #d8d2c8;
  --highlight: #f2d9a9;
  --code-bg: #282722;
  --code-ink: #eeeae1;
  --scrim: rgba(39, 35, 30, 0.28);
  --composer-shadow: rgba(49, 43, 36, 0.06);
  --shadow: 0 18px 60px rgba(52, 44, 35, 0.12);
  --keyboard-offset: 0px;
  --messages-bottom-space: 70px;
  --ui-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --system-font: system-ui, sans-serif;
  font-family: var(--ui-font);
}

html[data-font-mode="system"] {
  --ui-font: var(--system-font);
}

html[data-theme="rose"] {
  color-scheme: light;
  --paper: #f3f3f1;
  --paper-deep: #e9e9e6;
  --surface: #fafaf8;
  --ink: #302c2e;
  --muted: #797476;
  --line: #dcd9da;
  --accent: #b77787;
  --accent-dark: #96596a;
  --user: #eadde2;
  --danger: #a64d5c;
  --paper-rgb: 243, 243, 241;
  --surface-rgb: 250, 250, 248;
  --ink-rgb: 48, 44, 46;
  --field: #f8f8f6;
  --accent-soft: #f0e1e6;
  --accent-selected: #ecdce2;
  --neutral-soft: #ececea;
  --neutral-muted: #e6e6e3;
  --composer-border: #d6d3d4;
  --focus-border: #bda5ad;
  --placeholder: #999496;
  --subtle-text: #6c6769;
  --success: #607c68;
  --success-soft: #e4ede6;
  --danger-soft: #f8e7ea;
  --switch-off: #d1cfce;
  --highlight: #ecd2da;
  --code-bg: #292528;
  --code-ink: #eee8eb;
  --scrim: rgba(42, 39, 40, 0.28);
  --composer-shadow: rgba(48, 44, 46, 0.06);
}

html[data-theme="mist"] {
  color-scheme: light;
  --paper: #f1f4f5;
  --paper-deep: #e4eaec;
  --surface: #fafcfc;
  --ink: #283135;
  --muted: #6f7a7e;
  --line: #d4dde0;
  --accent: #7893a1;
  --accent-dark: #577686;
  --user: #e1e8eb;
  --danger: #a4514b;
  --paper-rgb: 241, 244, 245;
  --surface-rgb: 250, 252, 252;
  --ink-rgb: 40, 49, 53;
  --field: #f7fafb;
  --accent-soft: #e2ebef;
  --accent-selected: #e4edf0;
  --neutral-soft: #e8edef;
  --neutral-muted: #e3e9eb;
  --composer-border: #ced8dc;
  --focus-border: #9eafb7;
  --placeholder: #8f9a9e;
  --subtle-text: #606b6f;
  --success: #58765f;
  --success-soft: #e2ece5;
  --danger-soft: #f7e8e6;
  --switch-off: #cbd4d7;
  --highlight: #d8e5ea;
  --code-bg: #252a2c;
  --code-ink: #e7ecee;
  --scrim: rgba(31, 42, 47, 0.28);
  --composer-shadow: rgba(38, 50, 55, 0.06);
}

html[data-theme="sage"] {
  color-scheme: light;
  --paper: #f2f4ef;
  --paper-deep: #e5e9e1;
  --surface: #fbfcf9;
  --ink: #29302a;
  --muted: #707970;
  --line: #d6ddd2;
  --accent: #778f79;
  --accent-dark: #58715c;
  --user: #e3e8df;
  --danger: #a45149;
  --paper-rgb: 242, 244, 239;
  --surface-rgb: 251, 252, 249;
  --ink-rgb: 41, 48, 42;
  --field: #f8faf6;
  --accent-soft: #e3ebe1;
  --accent-selected: #e5ece2;
  --neutral-soft: #e9ede6;
  --neutral-muted: #e4e9e0;
  --composer-border: #d0d8cc;
  --focus-border: #a2b09f;
  --placeholder: #929a91;
  --subtle-text: #626a62;
  --success: #55735b;
  --success-soft: #e1ebe2;
  --danger-soft: #f7e8e5;
  --switch-off: #ccd3c9;
  --highlight: #dce5cf;
  --code-bg: #272b27;
  --code-ink: #e8ece5;
  --scrim: rgba(34, 42, 35, 0.28);
  --composer-shadow: rgba(41, 49, 42, 0.06);
}

html[data-theme="night"] {
  color-scheme: dark;
  --paper: #1f2020;
  --paper-deep: #191a1a;
  --surface: #292a29;
  --ink: #e8e5df;
  --muted: #aaa59d;
  --line: #3d3e3c;
  --accent: #c98268;
  --accent-dark: #dfa087;
  --user: #343533;
  --danger: #df8b81;
  --paper-rgb: 31, 32, 32;
  --surface-rgb: 41, 42, 41;
  --ink-rgb: 232, 229, 223;
  --field: #252625;
  --accent-soft: #3c302c;
  --accent-selected: #42332f;
  --neutral-soft: #30312f;
  --neutral-muted: #353633;
  --composer-border: #454642;
  --focus-border: #76665e;
  --placeholder: #827f79;
  --subtle-text: #b6b1a9;
  --success: #9aba9d;
  --success-soft: #29372c;
  --danger-soft: #412d2d;
  --switch-off: #50514e;
  --highlight: #65543b;
  --code-bg: #151616;
  --code-ink: #e5e2dc;
  --scrim: rgba(0, 0, 0, 0.48);
  --composer-shadow: rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

html.app-booting .app-shell,
html.app-booting .settings-page,
html.app-booting .workspace-page,
html.app-booting .file-preview,
html.app-booting .usage-modal,
html.app-booting .choice-modal,
html.app-booting .app-modal {
  visibility: hidden;
}

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

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  cursor: pointer;
}

button:focus {
  outline: none;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 14px max(18px, env(safe-area-inset-bottom));
  background: var(--paper-deep);
  border-right: 1px solid var(--line);
}

.sidebar-top,
.brand,
.topbar,
.composer-bottom {
  display: flex;
  align-items: center;
}

.sidebar-top {
  justify-content: space-between;
}

.brand {
  gap: 10px;
  padding: 3px 8px 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 600;
}

.brand-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  border-radius: 50% 46% 48% 45%;
  color: var(--surface);
  background: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
}

.brand-mark {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.icon-button:hover {
  background: var(--hover);
}

.new-chat-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--surface-rgb), 0.55);
  font-weight: 600;
  text-align: left;
}

.new-chat-button svg {
  width: 18px;
}

.new-chat-button:hover {
  border-color: var(--focus-border);
  background: var(--surface);
}

.sidebar-library-actions {
  display: grid;
  margin-top: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.sidebar-library-actions button {
  display: flex;
  min-width: 0;
  padding: 9px 10px;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}

.sidebar-library-actions button:hover {
  border-color: var(--line);
  color: var(--ink);
  background: rgba(var(--surface-rgb), 0.55);
}

.sidebar-library-actions svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.conversation-label {
  padding: 24px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  margin: 2px 0;
  padding: 0 5px 0 11px;
  border-radius: 10px;
}

.conversation-item.active {
  background: rgba(var(--surface-rgb), 0.74);
}

.conversation-open {
  min-width: 0;
  padding: 10px 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-delete {
  visibility: hidden;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
}

.conversation-item:hover .conversation-delete,
.conversation-item.active .conversation-delete {
  visibility: visible;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-action {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.sidebar-action:hover {
  background: rgba(var(--surface-rgb), 0.6);
}

.key-state {
  color: var(--danger);
  font-size: 12px;
}

.key-state.ready {
  color: var(--success);
}

.privacy-note {
  margin: 7px 10px 0;
  color: var(--muted);
  font-size: 11px;
}

.main-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
  padding-bottom: var(--keyboard-offset);
}

.topbar {
  position: relative;
  z-index: 3;
  height: 70px;
  padding: max(10px, env(safe-area-inset-top)) 22px 12px;
  gap: 12px;
  background: rgba(var(--paper-rgb), 0.94);
  backdrop-filter: blur(12px);
}

.topbar::after {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 24px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(var(--paper-rgb), 0.94),
    rgba(var(--paper-rgb), 0)
  );
  content: "";
}

.conversation-heading {
  display: grid;
  min-width: 0;
  max-width: 520px;
  flex: 1;
  align-content: center;
}

.conversation-title {
  min-width: 0;
  max-width: 100%;
  padding: 2px 7px 1px;
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 600;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-token-summary {
  padding: 0 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-pill {
  margin-left: auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.62);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

.model-pill:active,
.model-pill[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--ink);
}

.model-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 16px;
  z-index: 8;
  width: min(292px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid rgba(221, 214, 202, 0.92);
  border-radius: 18px;
  background: rgba(var(--surface-rgb), 0.96);
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.model-menu[hidden] {
  display: none;
}

.model-menu-heading {
  padding: 7px 9px 8px;
  color: var(--muted);
  font-size: 11px;
}

.model-menu-item {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 10px 11px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.model-menu-item:active,
.model-menu-item.active {
  background: var(--accent-soft);
}

.model-menu-item strong,
.model-menu-item small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-menu-item small {
  color: var(--muted);
  font-size: 11px;
}

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  touch-action: pan-y;
}

.welcome {
  display: flex;
  min-height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 24px 100px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  font-size: 25px;
  box-shadow: none;
}

.welcome h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", "Times New Roman", serif;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.welcome > p {
  margin: 13px 0 34px;
  color: var(--muted);
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  gap: 10px;
}

.suggestion {
  min-height: 100px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-soft);
  line-height: 1.45;
  text-align: left;
}

.suggestion:hover {
  border-color: var(--focus-border);
  background: var(--surface);
  transform: translateY(-1px);
}

.suggestion span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-weight: 600;
}

.messages {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 34px 24px var(--messages-bottom-space);
}

.message {
  position: relative;
  margin: 0 0 30px;
}

.message:last-child {
  margin-bottom: 0;
}

.message.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-content {
  max-width: 100%;
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.message.user .message-content {
  max-width: min(82%, 620px);
  padding: 11px 15px;
  border-radius: 18px 18px 4px 18px;
  background: var(--user);
  cursor: pointer;
  line-height: 1.55;
  white-space: pre-wrap;
  -webkit-touch-callout: none;
}

.message-attachments {
  display: grid;
  margin: 0 0 9px;
  gap: 6px;
}

.message.assistant .message-attachments {
  margin-top: 12px;
}

.message-attachments.assistant-media {
  width: min(100%, 560px);
  margin: 8px 0 14px;
  justify-items: start;
}

.assistant-image-attachment {
  display: block;
  overflow: hidden;
  width: 100%;
  min-height: 120px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--neutral-muted);
  cursor: zoom-in;
}

.assistant-image-attachment img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.voice-bubble {
  display: inline-flex;
  width: auto;
  max-width: 78vw;
  justify-self: start;
  min-height: 48px;
  padding: 7px 10px 7px 8px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: none;
  text-align: left;
}

.voice-bubble:hover,
.voice-bubble:active {
  border-color: var(--focus-border);
  background: var(--hover);
}

.voice-bubble-play {
  display: grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.voice-bubble:hover .voice-bubble-play,
.voice-bubble:active .voice-bubble-play,
.voice-bubble.playing .voice-bubble-play {
  background: var(--accent-dark);
}

.voice-bubble-play svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  stroke: none;
}

.voice-bubble-sparkle {
  flex: 0 0 auto;
  color: var(--accent-dark);
  font-size: 14px;
}

.voice-bubble-waveform {
  display: flex;
  height: 24px;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.voice-bubble-waveform i {
  display: block;
  width: 2px;
  flex: 0 0 2px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.68;
  transition: background-color 120ms ease, opacity 120ms ease;
}

.voice-bubble-waveform i.played {
  background: var(--accent);
  opacity: 1;
}

.voice-bubble-duration {
  flex: 0 0 auto;
  min-width: 25px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.message-attachment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: min(270px, 72vw);
  padding: 8px 10px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(var(--surface-rgb), 0.58);
}

button.message-attachment {
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}

button.message-attachment:hover,
button.message-attachment:focus-visible {
  border-color: var(--focus-border);
  background: var(--hover);
}

.message-attachment-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.message-attachment-icon svg {
  width: 17px;
  height: 17px;
}

.message-attachment-icon img,
.composer-attachment-icon img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.message-attachment.image .message-attachment-icon,
.composer-attachment.image .composer-attachment-icon {
  overflow: hidden;
  background: var(--neutral-muted);
}

.message-attachment-copy {
  min-width: 0;
}

.message-attachment-copy strong,
.message-attachment-copy small {
  display: block;
}

.message-attachment-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.user-message-text {
  white-space: pre-wrap;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content p {
  margin: 0 0 14px;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 25px 0 10px;
  font-family: Georgia, "Songti SC", serif;
  line-height: 1.3;
}

.message-content h1 {
  font-size: 24px;
}

.message-content h2 {
  font-size: 20px;
}

.message-content h3 {
  font-size: 17px;
}

.message-content h4,
.message-content h5,
.message-content h6 {
  font-size: 15px;
}

.message-content ul,
.message-content ol {
  margin: 8px 0 16px;
  padding-left: 24px;
}

.message-content li {
  margin: 5px 0;
}

.message-content blockquote {
  margin: 12px 0 16px;
  padding: 1px 0 1px 13px;
  border-left: 3px solid var(--line);
  color: var(--subtle-text);
}

.message-content blockquote p,
.message-content blockquote:last-child {
  margin-bottom: 0;
}

.message-content hr {
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--line);
}

.markdown-table-wrap {
  max-width: 100%;
  margin: 14px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--surface-rgb), 0.68);
}

.message-content table {
  width: 100%;
  min-width: 260px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.message-content th,
.message-content td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  vertical-align: top;
}

.message-content th:first-child,
.message-content td:first-child {
  border-left: 0;
}

.message-content tbody tr:last-child td {
  border-bottom: 0;
}

.message-content th {
  background: var(--neutral-soft);
  font-weight: 650;
}

.message-content a {
  color: var(--accent-dark);
  text-underline-offset: 3px;
}

.message-content del {
  color: var(--muted);
  text-decoration-thickness: 1.5px;
}

.message-content code {
  padding: 0.15em 0.35em;
  border-radius: 5px;
  background: var(--neutral-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.code-block {
  position: relative;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--code-ink);
}

.code-label {
  display: flex;
  min-height: 36px;
  padding: 7px 11px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #bdb7ac;
  font-size: 11px;
}

.copy-code {
  padding: 3px 7px;
  border: 0;
  border-radius: 5px;
  color: var(--composer-border);
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
}

.code-block pre {
  margin: 0;
  padding: 15px;
  overflow-x: auto;
}

.code-block code {
  padding: 0;
  color: inherit;
  background: transparent;
  font-size: 13px;
  line-height: 1.6;
}

.generated-file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin: 15px 0;
  padding: 12px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.generated-file.incomplete {
  border-style: dashed;
}

.generated-file.incomplete .generated-file-copy small {
  color: var(--accent-dark);
}

.generated-file-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.generated-file-icon svg {
  width: 20px;
  height: 20px;
}

.generated-file-copy {
  min-width: 0;
}

.generated-file-copy strong,
.generated-file-copy small {
  display: block;
}

.generated-file-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generated-file-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.generated-file-actions {
  display: flex;
  gap: 6px;
}

.download-generated-file,
.preview-generated-file {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
  min-height: 28px;
  margin-top: 5px;
}

.message-action-group {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.export-menu {
  position: relative;
  color: var(--muted);
  font-size: 12px;
}

.export-menu > summary {
  padding: 4px 0;
  list-style: none;
  cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
  display: none;
}

.export-menu-list {
  position: absolute;
  z-index: 8;
  top: 27px;
  left: 0;
  width: 165px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: none;
}

.export-menu-list button {
  display: block;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  text-align: left;
}

.export-menu-list button:hover {
  background: var(--neutral-soft);
}

.message-action-button {
  display: grid;
  flex: 0 0 auto;
  width: 24px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
}

.message-action-button:hover,
.message-action-button:active {
  color: var(--ink);
  background: var(--hover);
}

.message-action-button svg {
  width: 18px;
  height: 18px;
}

.message-action-button.voice-loading {
  cursor: wait;
  opacity: 0.48;
}

.message.user .message-actions {
  display: none;
}

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

.voice-provider-panel {
  margin: 16px 0 0;
}

.voice-provider-panel h4 {
  margin: 0 2px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-interruption {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.token-usage {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: flex;
  flex: 1 1 auto;
  align-self: center;
  min-height: 27px;
  min-width: 0;
  padding: 1px 0 0;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
}

.token-usage:hover,
.token-usage:active {
  color: var(--ink);
}

.memory-recall-snapshot,
.memory-recall-failed {
  flex: 0 0 auto;
  min-height: 27px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.memory-recall-snapshot:hover,
.memory-recall-snapshot:active {
  filter: brightness(0.97);
}

.memory-recall-failed {
  color: var(--muted);
  background: var(--neutral-soft);
}

.usage-panel {
  width: 100%;
  max-width: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: none;
}

.usage-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.usage-total span {
  color: var(--muted);
}

.usage-total strong {
  font-size: 15px;
}

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

.usage-metric {
  display: flex;
  min-width: 0;
  padding: 8px 9px;
  flex-direction: column;
  gap: 3px;
  border-radius: 9px;
  background: var(--field);
}

.usage-metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-metric strong {
  font-size: 14px;
}

.usage-metric.cache-hit strong {
  color: var(--success);
}

.usage-cache {
  padding-top: 2px;
}

.usage-cache > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.usage-cache > div:first-child span {
  color: var(--muted);
}

.usage-cache-track {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--neutral-muted);
}

.usage-cache-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}

.usage-context,
.usage-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.usage-note {
  margin-top: 4px;
  color: var(--placeholder);
}

.reasoning {
  margin: 0 0 18px;
}

.assistant-segment-text {
  margin: 0 0 18px;
}

.assistant-segment-text:last-child,
.tool-events:last-child,
.reasoning:last-child {
  margin-bottom: 0;
}

.reasoning summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 4px 0;
  list-style: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.45;
}

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

.reasoning-icon,
.reasoning-chevron {
  display: grid;
  place-items: center;
}

.reasoning-icon svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.7;
}

.thinking-clock-icon .thinking-clock-dot {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.reasoning-title {
  min-width: 0;
}

.reasoning-chevron {
  transition: transform 160ms ease;
}

.reasoning-chevron svg {
  width: 18px;
  height: 18px;
}

.reasoning[open] .reasoning-chevron {
  transform: rotate(90deg);
}

.reasoning-text {
  margin: 9px 0 2px 10px;
  padding: 8px 0 3px 18px;
  border-left: 1px solid var(--line);
  color: var(--subtle-text);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.tool-events {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.tool-event {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--surface-rgb), 0.58);
}

.tool-event summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  list-style: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.tool-event summary::-webkit-details-marker {
  display: none;
}

.tool-event-icon {
  display: grid;
  place-items: center;
}

.tool-event-icon svg {
  width: 18px;
  height: 18px;
}

.tool-event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-event-status {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--neutral-muted);
  font-size: 11px;
  white-space: nowrap;
}

.tool-event.done .tool-event-status {
  color: var(--success);
  background: var(--success-soft);
}

.tool-event.error .tool-event-status,
.tool-event.rejected .tool-event-status {
  color: var(--danger);
  background: var(--danger-soft);
}

.tool-event.running .tool-event-icon svg {
  animation: toolPulse 1.2s ease-in-out infinite;
}

.tool-event-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px 39px;
}

.tool-event-body pre {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--subtle-text);
  font-size: 12px;
  line-height: 1.5;
}

.fishing-subsidy-card {
  display: grid;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.fishing-subsidy-header,
.fishing-subsidy-card p,
.fishing-subsidy-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fishing-subsidy-header {
  justify-content: space-between;
}

.fishing-subsidy-header strong {
  font-size: 14px;
}

.fishing-subsidy-header span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  white-space: nowrap;
}

.fishing-subsidy-card.approved .fishing-subsidy-header span {
  background: var(--success-soft);
  color: var(--success);
}

.fishing-subsidy-card.declined .fishing-subsidy-header span {
  background: var(--neutral-soft);
  color: var(--muted);
}

.fishing-subsidy-card p {
  margin: 0;
  align-items: baseline;
  color: var(--subtle-text);
  font-size: 13px;
}

.fishing-subsidy-card p span {
  flex: 0 0 64px;
  color: var(--muted);
  font-size: 12px;
}

.fishing-subsidy-card b,
.fishing-subsidy-card em {
  min-width: 0;
  color: var(--ink);
  font-style: normal;
  overflow-wrap: anywhere;
}

.fishing-subsidy-actions {
  flex-wrap: wrap;
  margin-top: 2px;
}

.fishing-subsidy-actions button {
  min-height: 36px;
}

@keyframes toolPulse {
  50% {
    opacity: 0.45;
  }
}

.typing-caret::after {
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 3px;
  background: var(--accent);
  content: "";
  vertical-align: -0.15em;
  animation: blink 0.8s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.composer-zone {
  z-index: 4;
  min-width: 0;
  padding: 10px 22px max(9px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 76%, rgba(var(--paper-rgb), 0));
}

.composer {
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: 0 auto;
  padding: 12px 12px 10px 16px;
  border: 1px solid var(--composer-border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 2px 9px var(--composer-shadow);
}

.composer-attachments {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 11px;
  padding-bottom: 2px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer-attachments::-webkit-scrollbar {
  display: none;
}

.composer-attachment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-width: min(260px, 78vw);
  max-width: 320px;
  padding: 9px 8px 9px 10px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--field);
}

.composer-attachment-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.composer-attachment-icon svg {
  width: 17px;
  height: 17px;
}

.composer-attachment-copy {
  min-width: 0;
}

.composer-attachment-copy strong,
.composer-attachment-copy small {
  display: block;
}

.composer-attachment-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.composer-attachment > button {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
}

.composer-attachment > button:hover {
  background: var(--neutral-muted);
}

.composer:focus-within {
  border-color: var(--focus-border);
  box-shadow: 0 2px 10px var(--composer-shadow);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  padding: 0 0 10px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--placeholder);
}

.composer-bottom {
  justify-content: space-between;
}

.composer-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
}

.thinking-control {
  position: relative;
}

.attach-button,
.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.attach-button svg,
.thinking-toggle svg {
  width: 17px;
}

.thinking-toggle .thinking-chevron {
  width: 12px;
  transition: transform 160ms ease;
}

.thinking-toggle[aria-expanded="true"] .thinking-chevron {
  transform: rotate(180deg);
}

.attach-button:hover {
  color: var(--ink);
  background: var(--neutral-soft);
}

.attach-button.processing {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.thinking-toggle[aria-pressed="true"] {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.thinking-menu {
  position: absolute;
  z-index: 30;
  bottom: calc(100% + 10px);
  left: 0;
  width: min(292px, calc(100vw - 42px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: none;
}

.thinking-menu-title {
  padding: 5px 9px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.thinking-menu > button {
  display: grid;
  width: 100%;
  padding: 9px 10px;
  grid-template-columns: 1fr;
  gap: 2px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.thinking-menu > button:hover,
.thinking-menu > button[aria-checked="true"] {
  background: var(--accent-soft);
}

.thinking-menu > button[aria-checked="true"] span {
  color: var(--accent-dark);
  font-weight: 650;
}

.thinking-menu > button small {
  color: var(--muted);
  font-size: 11px;
}

.thinking-menu-note {
  margin: 7px 4px 1px;
  padding: 9px 8px 3px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.send-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--accent);
}

.send-button:disabled {
  color: var(--placeholder);
  background: var(--neutral-muted);
  cursor: default;
}

.send-button:not(:disabled):hover {
  background: var(--accent-dark);
}

.send-button .stop-icon {
  display: none;
}

.send-button.generating .send-icon {
  display: none;
}

.send-button.generating .stop-icon {
  display: block;
}

.composer-hint {
  margin: 7px auto 0;
  color: var(--placeholder);
  font-size: 10px;
  text-align: center;
}

.error-banner {
  display: flex;
  width: min(760px, 100%);
  margin: 0 auto 8px;
  padding: 7px 7px 7px 12px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 13px;
}

.error-banner[hidden] {
  display: none;
}

.error-banner-message {
  min-width: 0;
  flex: 1;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-banner-close {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: currentColor;
  background: transparent;
}

.error-banner-close:hover,
.error-banner-close:active {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.error-banner-close svg {
  width: 17px;
  height: 17px;
}

.workspace-page {
  position: fixed;
  z-index: 45;
  inset: 0;
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}

.workspace-page[hidden],
.library-screen[hidden] {
  display: none;
}

.workspace-page,
.library-screen:not([hidden]) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

#library-page:not([hidden]) {
  grid-template-rows: minmax(0, 1fr);
}

.library-screen:not([hidden]) {
  min-height: 0;
  overflow: hidden;
}

.workspace-topbar {
  display: grid;
  min-height: calc(72px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--paper-rgb), 0.96);
  backdrop-filter: blur(12px);
}

.workspace-topbar > div {
  min-width: 0;
  text-align: center;
}

.workspace-topbar h2,
.workspace-topbar p {
  margin: 0;
}

.workspace-topbar h2 {
  font-size: 18px;
}

.workspace-topbar p {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-content {
  width: min(760px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 26px 24px max(42px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.workspace-search {
  position: sticky;
  z-index: 2;
  top: 0;
  margin-bottom: 16px;
  box-shadow: none;
}

.search-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.search-results,
.library-list {
  display: grid;
  gap: 10px;
}

.search-result,
.library-item {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.search-result:hover,
.library-item:hover {
  border-color: var(--focus-border);
  background: var(--surface);
}

.search-result-header,
.library-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result-header strong,
.library-item-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-header small,
.library-item-header small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.search-result p,
.library-item p {
  margin: 8px 0 0;
  color: var(--subtle-text);
  font-size: 12px;
  line-height: 1.55;
}

.library-heading {
  display: flex;
  margin: 2px 2px 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.library-item.disabled {
  opacity: 0.62;
}

.library-item-copy {
  min-width: 0;
}

.library-item-badge {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 10px;
}

.library-item.disabled .library-item-badge {
  color: var(--muted);
  background: var(--neutral-muted);
}

.library-empty {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.library-empty strong {
  color: var(--ink);
}

.library-empty p {
  margin: 8px auto 18px;
  max-width: 340px;
  font-size: 12px;
  line-height: 1.55;
}

.library-editor textarea {
  min-height: 55vh;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.6;
}

.library-editor-actions {
  justify-content: space-between;
}

.nest-page {
  z-index: 46;
}

.nest-layout {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 0%, var(--accent-soft), transparent 28%),
    var(--paper);
}

.nest-main,
.nest-room,
.study-screen {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
}

.nest-main {
  overflow: hidden;
}

.study-screen {
  height: 100%;
}

.nest-room[hidden],
.study-screen[hidden] {
  display: none;
}

.nest-room {
  height: 100%;
}

.nest-room.active {
  display: block;
}

.study-shelf-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  padding: 26px max(24px, env(safe-area-inset-right)) 46px max(24px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.study-recent {
  display: flex;
  width: min(920px, 100%);
  min-width: 0;
  max-width: 100%;
  margin: 0 auto 28px;
  padding: 22px;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(140deg, rgba(var(--surface-rgb), 0.92), var(--panel));
}

.study-recent[hidden] {
  display: none;
}

.study-recent-mark,
.nest-placeholder-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.study-recent-mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
}

.study-recent-mark svg {
  width: 24px;
  height: 24px;
}

.study-recent-copy {
  min-width: 0;
  flex: 1;
}

.study-recent-copy > span,
.study-recent h3,
.study-recent p {
  margin: 0;
}

.study-recent-copy > span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.study-recent h3 {
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-recent p {
  margin-top: 5px;
  overflow: hidden;
  color: var(--subtle-text);
  font-size: 12px;
  line-height: 1.7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-recent .secondary-button {
  flex: 0 0 auto;
}

.study-heading {
  display: flex;
  width: min(920px, 100%);
  min-width: 0;
  max-width: 100%;
  margin: 0 auto 14px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.study-heading strong,
.study-heading small {
  display: block;
}

.study-heading strong {
  font-size: 15px;
}

.study-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.study-import-status {
  width: min(920px, 100%);
  min-width: 0;
  max-width: 100%;
  margin: 0 auto 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--subtle-text);
  background: var(--panel-soft);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.study-import-status[hidden] {
  display: none;
}

.study-import-status[data-tone="success"] {
  color: var(--accent-dark);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
}

.study-import-status[data-tone="error"] {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, var(--panel));
}

.study-book-grid {
  display: grid;
  width: min(920px, 100%);
  min-width: 0;
  max-width: 100%;
  margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 16px;
}

.study-book-grid > * {
  min-width: 0;
}

.study-book-card {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.study-book-open {
  display: grid;
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.study-book-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(var(--surface-rgb), 0.88);
  font-size: 9px;
  opacity: 0;
  backdrop-filter: blur(8px);
}

.study-book-card:hover .study-book-delete,
.study-book-delete:focus-visible {
  opacity: 1;
}

.study-book-delete:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.study-book-cover {
  position: relative;
  display: flex;
  min-height: 210px;
  padding: 18px 16px;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 75%, var(--accent));
  border-radius: 8px 18px 18px 8px;
  color: var(--ink);
  background:
    linear-gradient(110deg, rgba(var(--ink-rgb), 0.1), transparent 12%),
    linear-gradient(155deg, var(--surface), var(--accent-soft));
}

.study-book-cover::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 9px;
  width: 1px;
  content: "";
  background: rgba(var(--ink-rgb), 0.13);
}

.study-book-cover strong {
  position: relative;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.study-book-cover small {
  position: relative;
  color: var(--subtle-text);
  font-size: 10px;
  text-transform: uppercase;
}

.study-book-copy {
  display: block;
  min-width: 0;
  padding: 10px 3px 0;
}

.study-book-copy strong,
.study-book-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-book-copy strong {
  font-size: 13px;
}

.study-book-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.study-book-open:hover .study-book-cover {
  border-color: var(--focus-border);
  transform: translateY(-2px);
}

.study-book-cover {
  transition: transform 150ms ease, border-color 150ms ease;
}

.study-empty {
  display: grid;
  width: min(520px, 100%);
  margin: 60px auto 0;
  padding: 34px 24px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-soft);
}

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

.study-empty > span {
  font-size: 11px;
}

.study-empty strong {
  margin-top: 8px;
  color: var(--ink);
  font-size: 16px;
}

.study-empty p {
  max-width: 360px;
  margin: 8px 0 20px;
  font-size: 12px;
  line-height: 1.65;
}

.study-reader {
  position: relative;
  display: grid;
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--paper);
}

.study-reader-toolbar {
  display: grid;
  min-height: 56px;
  padding: 7px max(18px, env(safe-area-inset-right)) 7px max(18px, env(safe-area-inset-left));
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr) minmax(72px, auto);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.study-reader-back,
.study-reader-leave,
.study-reader-companion,
.study-reader-directory {
  padding: 8px 9px;
  border: 0;
  border-radius: 9px;
  color: var(--accent-dark);
  background: transparent;
  font-weight: 600;
}

.study-reader-back {
  display: flex;
  align-items: center;
  gap: 4px;
}

.study-reader-back svg {
  width: 17px;
  height: 17px;
}

.study-reader-directory {
  justify-self: end;
}

.study-reader-actions {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 2px;
}

.study-reader-companion {
  color: var(--ink);
}

.study-reader-leave {
  color: var(--accent-dark);
}

.study-reader-leave[data-synced="true"] {
  color: var(--muted);
}

.study-reader-back:hover,
.study-reader-leave:hover,
.study-reader-companion:hover,
.study-reader-directory:hover {
  background: var(--accent-soft);
}

.study-reader-heading {
  min-width: 0;
  text-align: center;
}

.study-reader-heading strong,
.study-reader-heading small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-reader-heading strong {
  font-size: 13px;
}

.study-reader-heading small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.study-reading-status {
  display: grid;
  min-height: 34px;
  padding: 5px max(18px, env(safe-area-inset-right)) 5px max(18px, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  font-size: 9px;
}

.study-reading-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-reading-status button {
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 600;
}

.study-reader-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.study-reader-paper {
  width: min(760px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 52px 58px 80px;
  background: var(--surface);
}

.study-reader-paper > header {
  margin-bottom: 36px;
  text-align: center;
}

.study-reader-paper > header span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.study-reader-paper > header h3 {
  margin: 10px 0 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 25px;
  line-height: 1.45;
}

.study-reader-content {
  color: var(--ink);
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 17px;
  line-height: 2;
}

.study-reader-block {
  margin: 0 0 1.25em;
  scroll-margin-top: 22vh;
  text-align: justify;
  text-wrap: pretty;
  white-space: pre-line;
}

.study-annotation-mark {
  margin: 0;
  padding: 0 0.04em;
  border-radius: 0.16em;
  color: inherit;
  background: var(--highlight);
  box-decoration-break: clone;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
}

.study-annotation-mark.companion {
  background: var(--success-soft);
}

.study-annotation-mark.both {
  background:
    linear-gradient(
      to bottom,
      var(--highlight) 0 52%,
      var(--success-soft) 52% 100%
    );
}

.study-annotation-mark.has-note {
  border-bottom: 1.5px solid var(--accent-dark);
}

.study-annotation-mark.companion.has-note {
  border-bottom-color: var(--success);
}

.study-annotation-mark:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 2px;
}

.study-reader-chapter-nav {
  display: flex;
  margin-top: 54px;
  padding-top: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
}

.study-reader-chapter-nav button:disabled {
  opacity: 0.4;
}

.study-companion-panel {
  position: absolute;
  z-index: 5;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: grid;
  height: min(48vh, 470px);
  min-height: 280px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: 0 18px 60px rgba(38, 31, 24, 0.2);
  backdrop-filter: blur(18px);
}

.study-companion-panel[hidden] {
  display: none;
}

.study-companion-header {
  display: flex;
  min-width: 0;
  padding: 13px 15px 11px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.study-companion-header > div {
  min-width: 0;
}

.study-companion-header strong,
.study-companion-header small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-companion-header strong {
  font-size: 13px;
}

.study-companion-header small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.study-companion-header button {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 0;
  border-radius: 9px;
  color: var(--accent-dark);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
}

.study-companion-header button:hover {
  background: var(--accent-soft);
}

.study-companion-messages {
  min-height: 0;
  padding: 15px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.study-companion-empty {
  display: grid;
  min-height: 100%;
  padding: 24px;
  place-content: center;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
}

.study-companion-message {
  width: fit-content;
  max-width: min(86%, 620px);
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.7;
}

.study-companion-message.user {
  margin-left: auto;
  border-bottom-right-radius: 5px;
  background: var(--accent-soft);
}

.study-companion-message.assistant {
  margin-right: auto;
  border-bottom-left-radius: 5px;
}

.study-companion-message > :first-child {
  margin-top: 0;
}

.study-companion-message > :last-child {
  margin-bottom: 0;
}

.study-companion-message p {
  margin: 0 0 0.65em;
}

.study-companion-message.pending {
  color: var(--muted);
}

.study-companion-silence {
  margin: 8px auto 14px;
  color: var(--muted);
  text-align: center;
  font-size: 9px;
}

.study-companion-composer {
  display: grid;
  padding: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.study-companion-composer textarea {
  width: 100%;
  min-height: 38px;
  max-height: 96px;
  padding: 9px 11px;
  resize: none;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

.study-companion-composer button {
  min-height: 38px;
  padding: 8px 15px;
}

.study-selection-toolbar {
  position: absolute;
  z-index: 8;
  bottom: 16px;
  left: 50%;
  display: flex;
  width: min(520px, calc(100% - 28px));
  padding: 9px 10px 9px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.study-selection-toolbar[hidden] {
  display: none;
}

.study-selection-toolbar > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-selection-toolbar > div {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.study-selection-toolbar button {
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: var(--neutral-soft);
  font-size: 10px;
  font-weight: 600;
}

.study-selection-toolbar button:last-child {
  color: white;
  background: var(--accent);
}

.nest-placeholder {
  display: grid;
  width: min(520px, calc(100% - 36px));
  min-height: 100%;
  margin: 0 auto;
  padding: 44px 20px calc(44px + env(safe-area-inset-bottom));
  align-content: center;
  justify-items: center;
  text-align: center;
}

.nest-placeholder-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
}

.nest-placeholder-icon svg {
  width: 27px;
  height: 27px;
}

.nest-placeholder h3 {
  margin: 18px 0 0;
  font-size: 19px;
}

.nest-placeholder p {
  max-width: 380px;
  margin: 9px 0 15px;
  color: var(--subtle-text);
  font-size: 12px;
  line-height: 1.7;
}

.nest-placeholder > span:last-child {
  color: var(--muted);
  font-size: 10px;
}

.nest-more-scroll {
  width: 100%;
  height: 100%;
  padding: 28px max(24px, env(safe-area-inset-right)) 54px max(24px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.memory-recall-panel {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(var(--surface-rgb), 0.94), var(--panel));
}

.memory-recall-panel > header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 15px;
}

.memory-recall-panel > header > div {
  min-width: 0;
}

.memory-recall-panel > header small,
.memory-recall-panel > header h3,
.memory-recall-panel > header p {
  display: block;
  margin: 0;
}

.memory-recall-panel > header small {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.memory-recall-panel > header h3 {
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.4;
}

.memory-recall-panel > header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.memory-recall-badge {
  padding: 6px 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--muted);
  background: var(--neutral-soft);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.memory-recall-badge.ready {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.memory-recall-panel-stats {
  display: grid;
  margin-top: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.memory-recall-panel-stats span {
  min-width: 0;
  padding: 13px;
  border-radius: 13px;
  background: rgba(var(--paper-rgb), 0.72);
}

.memory-recall-panel-stats small,
.memory-recall-panel-stats strong {
  display: block;
}

.memory-recall-panel-stats small {
  color: var(--muted);
  font-size: 10px;
}

.memory-recall-panel-stats strong {
  margin-top: 5px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-recall-last-log {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 82%, var(--accent-soft));
  font-size: 12px;
  line-height: 1.5;
}

.memory-recall-test-field {
  margin-top: 20px;
  margin-bottom: 0;
}

.memory-recall-test-field textarea {
  min-height: 88px;
}

.memory-recall-test-result {
  max-height: 34vh;
  margin: 14px 0 0;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(var(--paper-rgb), 0.78);
  font: inherit;
  font-size: 11px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memory-recall-panel-actions {
  display: flex;
  margin-top: 16px;
  justify-content: flex-end;
  gap: 9px;
}

.vector-memory-toolbar {
  display: grid;
  margin-top: 18px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 10px;
}

.vector-memory-toolbar .search-field {
  min-width: 0;
}

.vector-memory-filters {
  display: grid;
  margin-top: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.vector-memory-filters label,
.vector-memory-filters .vector-memory-choice,
.vector-memory-transfer label,
.vector-memory-transfer .vector-memory-choice {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.vector-memory-filters input,
.vector-memory-filters .field-choice-button,
.vector-memory-transfer .field-choice-button {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--field);
  font: inherit;
  font-size: 11px;
}

.vector-memory-filters .field-choice-button,
.vector-memory-transfer .field-choice-button {
  min-height: 35px;
}

.vector-memory-list {
  display: grid;
  margin-top: 16px;
  gap: 11px;
}

.vector-memory-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(var(--paper-rgb), 0.76);
}

.vector-memory-card.status-archived,
.vector-memory-card.status-expired {
  opacity: 0.78;
}

.vector-memory-card.status-trash {
  border-style: dashed;
  opacity: 0.68;
}

.vector-memory-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vector-memory-category,
.vector-memory-status,
.vector-memory-card-meta span,
.vector-memory-card-tags span {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
}

.vector-memory-category {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.vector-memory-status {
  color: var(--muted);
  background: var(--neutral-soft);
}

.vector-memory-card-content {
  display: -webkit-box;
  width: 100%;
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.vector-memory-card-meta,
.vector-memory-card-tags {
  display: flex;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 6px;
}

.vector-memory-card-meta span {
  color: var(--muted);
  background: var(--neutral-soft);
}

.vector-memory-card-tags span {
  color: var(--subtle-text);
  background: rgba(var(--surface-rgb), 0.84);
}

.vector-memory-card-actions {
  display: flex;
  margin-top: 12px;
  padding-top: 10px;
  flex-wrap: wrap;
  gap: 14px;
  border-top: 1px solid var(--line);
}

.vector-memory-card-actions button {
  padding: 2px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.vector-memory-card-actions button.danger {
  color: var(--danger);
}

.vector-memory-empty {
  margin-top: 16px;
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.vector-memory-empty strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.vector-memory-empty p {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.6;
}

.vector-memory-transfer {
  display: grid;
  margin-top: 14px;
  padding-top: 14px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.nest-more-coming {
  width: min(760px, 100%);
  margin: 16px auto 0;
  padding: 18px 20px;
  border: 1px dashed var(--line);
  border-radius: 17px;
  color: var(--muted);
  background: var(--panel-soft);
}

.nest-more-coming strong {
  color: var(--ink);
  font-size: 13px;
}

.nest-more-coming p {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.6;
}

.nest-tabs {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  min-height: calc(64px + env(safe-area-inset-bottom));
  padding: 7px max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
  grid-template-columns: repeat(5, minmax(100px, 140px));
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
  backdrop-filter: blur(14px);
}

.nest-tabs button {
  display: grid;
  min-width: 0;
  padding: 5px 4px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
}

.nest-tabs button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.nest-tabs svg {
  width: 20px;
  height: 20px;
}

.message.search-target {
  animation: searchTargetFlash 1.8s ease;
}

@keyframes searchTargetFlash {
  0%,
  40% {
    background: color-mix(in srgb, var(--highlight) 50%, transparent);
  }
  100% {
    background: transparent;
  }
}

.settings-page {
  position: fixed;
  z-index: 40;
  inset: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}

.settings-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}

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

.settings-topbar,
.settings-detail-topbar {
  min-height: calc(72px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: rgba(var(--paper-rgb), 0.94);
  backdrop-filter: blur(12px);
}

.settings-topbar {
  display: flex;
  padding-right: max(22px, env(safe-area-inset-right));
  padding-left: max(22px, env(safe-area-inset-left));
  align-items: center;
  justify-content: space-between;
}

.settings-heading h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 27px;
  font-weight: 500;
}

.settings-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-detail-topbar {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  padding-right: max(14px, env(safe-area-inset-right));
  padding-left: max(14px, env(safe-area-inset-left));
  align-items: center;
}

.settings-detail-topbar h2 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-header-spacer {
  width: 42px;
}

.settings-content {
  width: min(760px, 100%);
  min-height: 0;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 30px 24px max(42px, env(safe-area-inset-bottom));
}

.settings-home {
  padding-top: 25px;
}

.settings-group {
  margin-bottom: 30px;
}

.settings-group h3 {
  margin: 0 10px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.settings-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  width: 100%;
  min-height: 72px;
  padding: 13px 14px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--surface-rgb), 0.64);
  text-align: left;
}

.settings-row:first-of-type {
  border-radius: 14px 14px 0 0;
}

.settings-row:last-of-type {
  border-bottom: 0;
  border-radius: 0 0 14px 14px;
}

.settings-row:only-of-type {
  border-radius: 14px;
}

.settings-row:hover {
  background: var(--surface);
}

.settings-row-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.settings-row-icon svg {
  width: 19px;
  height: 19px;
}

.settings-row-copy {
  min-width: 0;
}

.settings-row-copy strong,
.settings-row-copy small {
  display: block;
}

.settings-row-copy strong {
  font-size: 14px;
}

.settings-row-copy small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row-value {
  max-width: 145px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-row-value.attention {
  color: var(--danger);
}

.settings-row-chevron {
  width: 17px;
  height: 17px;
  color: var(--placeholder);
}

.settings-info {
  display: flex;
  padding: 17px;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(var(--surface-rgb), 0.5);
}

.settings-info > svg {
  flex: 0 0 auto;
  width: 21px;
  color: var(--success);
}

.settings-info strong {
  font-size: 13px;
}

.settings-info p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.privacy-settings-row {
  margin-top: 10px;
  border-radius: 14px;
}

.settings-detail {
  width: min(620px, 100%);
  padding-top: 36px;
}

.memory-recall-settings {
  display: grid;
  align-content: start;
  gap: 14px;
}

.memory-recall-settings .settings-detail-intro,
.memory-recall-settings .field {
  margin-bottom: 0;
}

.memory-recall-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.memory-recall-layers {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(var(--surface-rgb), 0.56);
}

.memory-recall-layers legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 650;
}

.memory-recall-layers > p {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

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

.memory-recall-layer-grid label {
  display: flex;
  min-width: 0;
  padding: 9px 10px;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  background: rgba(var(--paper-rgb), 0.72);
  font-size: 12px;
}

.memory-recall-layer-grid label.sensitive {
  color: var(--danger);
}

.memory-recall-layer-grid input {
  margin: 0;
}

.memory-recall-status {
  margin: 0;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.memory-recall-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.memory-recall-actions {
  margin-top: 2px;
}

@media (max-width: 560px) {
  .memory-recall-panel > header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .memory-recall-panel > header .memory-recall-badge {
    grid-column: 2;
    justify-self: start;
  }

  .memory-recall-panel-stats,
  .memory-recall-grid {
    grid-template-columns: 1fr;
  }

  .memory-recall-panel-actions,
  .memory-recall-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .memory-recall-panel-actions button,
  .memory-recall-actions button {
    width: 100%;
  }

  .vector-memory-toolbar,
  .vector-memory-transfer {
    grid-template-columns: 1fr;
  }

  .vector-memory-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.data-backup-settings {
  display: grid;
  align-content: start;
  gap: 12px;
}

.data-backup-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 17px;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(var(--surface-rgb), 0.56);
}

.data-backup-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.data-backup-icon svg {
  width: 20px;
  height: 20px;
}

.data-backup-card strong,
.data-backup-card p {
  display: block;
  margin: 0;
}

.data-backup-card strong {
  font-size: 14px;
}

.data-backup-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.data-backup-card button {
  white-space: nowrap;
}

.data-backup-warning,
.data-backup-status {
  margin: 2px 4px 0;
  padding: 12px 13px;
  border-radius: 11px;
  font-size: 11px;
  line-height: 1.55;
}

.data-backup-warning {
  color: var(--danger);
  background: var(--danger-soft);
}

.data-backup-status {
  color: var(--success);
  background: var(--success-soft);
}

.data-backup-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.context-compression-content {
  display: grid;
  align-content: start;
  gap: 14px;
}

.context-compression-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(var(--surface-rgb), 0.58);
}

.context-compression-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.context-compression-card-heading strong,
.context-compression-card-heading p {
  display: block;
  margin: 0;
}

.context-compression-card-heading strong {
  font-size: 15px;
}

.context-compression-card-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.context-summary-edit {
  min-height: 34px;
  padding: 7px 11px;
  flex: 0 0 auto;
  font-size: 11px;
}

.context-compression-badge {
  padding: 5px 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--muted);
  background: var(--neutral-soft);
  font-size: 10px;
  font-weight: 650;
}

.context-compression-badge.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.context-compression-stats {
  display: grid;
  margin-top: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.context-compression-stats span {
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(var(--paper-rgb), 0.72);
}

.context-compression-stats small,
.context-compression-stats strong {
  display: block;
}

.context-compression-stats small {
  color: var(--muted);
  font-size: 10px;
}

.context-compression-stats strong {
  margin-top: 5px;
  font-size: 13px;
}

.context-keep-field {
  margin: 0;
}

.context-keep-field input {
  max-width: 160px;
}

.context-compression-note,
.context-compression-privacy,
.context-compression-status {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.context-compression-actions {
  display: flex;
  margin-top: 18px;
  justify-content: flex-end;
  gap: 10px;
}

.context-compression-status {
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--success);
  background: var(--success-soft);
}

.context-compression-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.context-compression-preview pre {
  max-height: 42vh;
  margin: 16px 0 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(var(--paper-rgb), 0.72);
  font: inherit;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.context-compression-privacy {
  margin-top: 0;
  padding: 2px 4px;
}

@media (max-width: 560px) {
  .context-compression-stats {
    grid-template-columns: 1fr;
  }

  .context-compression-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .context-compression-actions button {
    width: 100%;
  }
}

.settings-detail-intro {
  margin-bottom: 27px;
}

.settings-detail-intro h3 {
  margin: 0 0 7px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 23px;
  font-weight: 500;
}

.settings-detail-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.field {
  display: block;
  margin: 0 0 20px;
}

.field > span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.field > label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.field-hint a {
  color: var(--accent-dark);
  text-underline-offset: 2px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
}

.field-choice-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.field-choice-button:hover,
.field-choice-button:focus-visible {
  border-color: var(--focus-border);
}

.field-choice-button:disabled {
  opacity: 0.52;
  cursor: default;
}

.field-choice-button .field-choice-value {
  min-width: 0;
  overflow: hidden;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-choice-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--focus-border);
}

.field input:disabled,
.field textarea:disabled,
.field select:disabled {
  opacity: 0.52;
  cursor: default;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.6;
}

.device-tools-privacy {
  margin-top: 8px;
}

.code-workspace-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.code-workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.code-workspace-heading strong,
.code-workspace-heading small {
  display: block;
}

.code-workspace-heading strong {
  font-size: 14px;
}

.code-workspace-heading small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.code-workspace-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.code-workspace-list {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.code-workspace-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.code-workspace-file strong,
.code-workspace-file small {
  display: block;
}

.code-workspace-file strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.code-workspace-file small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.code-workspace-file-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.code-workspace-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

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

.native-capability-status {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(var(--surface-rgb), 0.64);
  font-size: 12px;
  line-height: 1.55;
}

.native-capability-status.ready {
  color: var(--success);
  background: var(--success-soft);
}

.native-capability-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.wake-limit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
  gap: 0 14px;
}

.wake-keepalive-card {
  margin-top: 16px;
}

.wake-keepalive-grid {
  margin-top: 14px;
}

.wake-keepalive-instruction {
  margin-top: 14px;
}

.wake-manual-instruction {
  margin-top: 14px;
}

.field.wake-keepalive-instruction textarea {
  min-height: 108px;
}

.field.wake-manual-instruction textarea {
  min-height: 128px;
}

.wake-keepalive-bind-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.wake-keepalive-bind-row strong {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink);
}

.wake-task-heading {
  align-items: center;
}

.compact-button {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 11px;
}

.wake-task-list {
  display: grid;
  gap: 10px;
}

.wake-task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
  gap: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(var(--surface-rgb), 0.64);
}

.wake-task-card strong,
.wake-task-card small,
.wake-task-card p {
  display: block;
}

.wake-task-card strong {
  font-size: 13px;
}

.wake-task-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.wake-task-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
}

.wake-task-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
}

.wake-task-card button {
  align-self: start;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
}

.wake-task-card button:last-child {
  color: var(--danger);
}

.wake-task-empty {
  min-height: 150px;
}

.scheduled-wake-label {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 8px;
  align-items: center;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 600;
}

.scheduled-wake-label.manual {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.scheduled-wake-label.keepalive {
  color: #2f5f47;
  background: rgba(90, 167, 122, 0.18);
}

#web-tools-settings-form .setting-switch-row + .setting-switch-row {
  margin-top: 10px;
}

#web-tools-settings-form .setting-switch-row + .field {
  margin-top: 20px;
}

.secret-input {
  position: relative;
}

.secret-input input {
  padding-right: 58px;
}

#weather-api-host,
#weather-api-key {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  caret-color: var(--accent);
}

.secret-input button {
  position: absolute;
  top: 50%;
  right: 8px;
  padding: 5px 7px;
  transform: translateY(-50%);
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.setting-switch-row {
  display: flex;
  min-height: 68px;
  padding: 13px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(var(--surface-rgb), 0.64);
  cursor: pointer;
}

.setting-switch-row strong,
.setting-switch-row small {
  display: block;
}

.setting-switch-row strong {
  font-size: 14px;
}

.setting-switch-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.setting-switch-row input {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  outline: 0;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 150ms ease;
}

.setting-switch-row input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: none;
  content: "";
  transition: transform 150ms ease;
}

.setting-switch-row input:checked {
  background: var(--accent);
}

.setting-switch-row input:checked::after {
  transform: translateX(18px);
}

.display-section-heading {
  display: flex;
  margin: 0 2px 10px;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.display-section-heading strong {
  font-size: 14px;
}

.display-section-heading small {
  color: var(--muted);
  font-size: 11px;
}

.font-section-heading {
  margin-top: 28px;
}

.input-section-heading {
  margin-top: 28px;
}

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

.theme-option {
  display: grid;
  min-width: 0;
  min-height: 82px;
  padding: 13px;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  cursor: pointer;
}

.theme-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-selected);
}

.theme-option > input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.theme-option strong,
.theme-option small {
  display: block;
}

.theme-option strong {
  font-size: 14px;
}

.theme-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.theme-swatch {
  display: grid;
  width: 48px;
  height: 38px;
  padding: 6px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  border: 1px solid rgba(128, 120, 110, 0.22);
  border-radius: 10px;
  overflow: hidden;
}

.theme-swatch i {
  display: block;
  border-radius: 4px;
}

.theme-swatch i:first-child {
  grid-row: 1 / 3;
}

.theme-swatch-paper {
  background: #f7f4ed;
}

.theme-swatch-paper i:nth-child(1) {
  background: #eeeae0;
}

.theme-swatch-paper i:nth-child(2) {
  background: #ebe7dd;
}

.theme-swatch-paper i:nth-child(3) {
  background: #c76845;
}

.theme-swatch-rose {
  background: #f3f3f1;
}

.theme-swatch-rose i:nth-child(1) {
  background: #e9e9e6;
}

.theme-swatch-rose i:nth-child(2) {
  background: #eadde2;
}

.theme-swatch-rose i:nth-child(3) {
  background: #b77787;
}

.theme-swatch-mist {
  background: #f1f4f5;
}

.theme-swatch-mist i:nth-child(1) {
  background: #e4eaec;
}

.theme-swatch-mist i:nth-child(2) {
  background: #e1e8eb;
}

.theme-swatch-mist i:nth-child(3) {
  background: #7893a1;
}

.theme-swatch-sage {
  background: #f2f4ef;
}

.theme-swatch-sage i:nth-child(1) {
  background: #e5e9e1;
}

.theme-swatch-sage i:nth-child(2) {
  background: #e3e8df;
}

.theme-swatch-sage i:nth-child(3) {
  background: #778f79;
}

.theme-swatch-night {
  border-color: #4a4b48;
  background: #1f2020;
}

.theme-swatch-night i:nth-child(1) {
  background: #292a29;
}

.theme-swatch-night i:nth-child(2) {
  background: #343533;
}

.theme-swatch-night i:nth-child(3) {
  background: #c98268;
}

.theme-swatch-custom {
  background: #f7f4ed;
}

.theme-swatch-custom i:nth-child(1) {
  background: #fffdf8;
}

.theme-swatch-custom i:nth-child(2) {
  background: #ebe7dd;
}

.theme-swatch-custom i:nth-child(3) {
  background: #c76845;
}

.custom-theme-editor {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 92% 8%, rgba(var(--surface-rgb), 0.9), transparent 42%),
    linear-gradient(145deg, var(--panel-strong), var(--panel));
}

.custom-theme-editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.custom-theme-editor-heading strong,
.custom-theme-editor-heading small {
  display: block;
}

.custom-theme-editor-heading strong {
  font-size: 14px;
}

.custom-theme-editor-heading small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.custom-theme-color-grid {
  display: grid;
  margin-top: 15px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.custom-theme-color {
  display: flex;
  min-width: 0;
  padding: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--surface-rgb), 0.64);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.custom-theme-color-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.custom-theme-color-trigger {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 3px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  cursor: pointer;
  place-items: center;
}

.custom-theme-color-trigger i {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  border-radius: 6px;
  background: var(--picker-color, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(var(--surface-rgb), 0.3);
}

.custom-theme-color-trigger:hover,
.custom-theme-color-trigger:focus-visible {
  border-color: var(--focus-border);
  transform: translateY(-1px);
}

.custom-theme-color input[type="text"] {
  width: 88px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: var(--field);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.custom-theme-color input[type="text"]:focus {
  border-color: var(--focus-border);
}

.custom-theme-color input[type="text"].invalid {
  border-color: var(--danger);
}

.custom-theme-contrast {
  min-height: 18px;
  margin: 12px 2px 0;
  color: var(--success);
  font-size: 11px;
  line-height: 1.55;
}

.custom-theme-contrast.warning {
  color: var(--danger);
}

.color-picker-modal {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  padding: 18px;
  place-items: center;
}

.color-picker-modal[hidden] {
  display: none;
}

.color-picker-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(var(--ink-rgb), 0.2);
  backdrop-filter: blur(7px);
}

.color-picker-card {
  position: relative;
  width: min(372px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at 90% 0%, var(--accent-soft), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow);
  animation: color-picker-arrive 180ms ease-out both;
}

@keyframes color-picker-arrive {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.color-picker-header {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.color-picker-header span {
  display: block;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.color-picker-header h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 21px;
  line-height: 1.25;
}

.color-picker-saturation {
  position: relative;
  height: 190px;
  overflow: hidden;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  border-radius: 16px;
  outline: 0;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, transparent),
    var(--picker-hue, #c76845);
  box-shadow: inset 0 0 0 1px rgba(var(--surface-rgb), 0.16);
  cursor: crosshair;
  touch-action: none;
}

.color-picker-saturation:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.color-picker-saturation i {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.color-picker-hue-row {
  display: grid;
  margin-top: 16px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.color-picker-hue-row input {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  outline: 0;
  background: linear-gradient(
    90deg,
    #f05b5b,
    #e6cf57,
    #62c77b,
    #5ac5cc,
    #6687db,
    #b56bd1,
    #f05b5b
  );
}

.color-picker-hue-row input::-webkit-slider-thumb {
  width: 21px;
  height: 21px;
  appearance: none;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: hsl(var(--picker-hue-value, 0), 82%, 55%);
  box-shadow: 0 1px 5px rgba(var(--ink-rgb), 0.3);
}

.color-picker-hue-row input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: hsl(var(--picker-hue-value, 0), 82%, 55%);
  box-shadow: 0 1px 5px rgba(var(--ink-rgb), 0.3);
}

.color-picker-value-row {
  display: grid;
  margin-top: 16px;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
}

.color-picker-preview {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--picker-color, var(--accent));
  box-shadow: inset 0 0 0 4px rgba(var(--surface-rgb), 0.36);
}

.color-picker-value-row label {
  display: grid;
  padding: 7px 11px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--field);
}

.color-picker-value-row label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.color-picker-value-row input {
  width: 100%;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.color-picker-value-row input.invalid {
  color: var(--danger);
}

.color-picker-done {
  width: 100%;
  margin-top: 16px;
}

.model-options {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.model-option {
  display: flex;
  min-height: 78px;
  padding: 15px;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--surface-rgb), 0.64);
  cursor: pointer;
}

.model-option:last-child {
  border-bottom: 0;
}

.model-option:has(input:checked) {
  background: var(--accent-selected);
}

.model-option > input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.model-option strong,
.model-option small {
  display: block;
}

.model-option strong {
  font-size: 14px;
}

.model-option small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.font-preview {
  display: block;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(var(--surface-rgb), 0.58);
  font-size: 16px;
  line-height: 1.45;
}

.font-preview-default {
  font-family: Georgia, "Songti SC", serif;
}

.font-preview-system {
  font-family: var(--system-font);
}

html[data-font-mode="system"] .brand,
html[data-font-mode="system"] .brand-mark,
html[data-font-mode="system"] .welcome-mark,
html[data-font-mode="system"] .welcome h1,
html[data-font-mode="system"] .message-content h1,
html[data-font-mode="system"] .message-content h2,
html[data-font-mode="system"] .message-content h3,
html[data-font-mode="system"] .message-content h4,
html[data-font-mode="system"] .message-content h5,
html[data-font-mode="system"] .message-content h6,
html[data-font-mode="system"] .settings-heading h2,
html[data-font-mode="system"] .settings-detail-intro h3,
html[data-font-mode="system"] .usage-modal-header h2,
html[data-font-mode="system"] .choice-modal-header h2,
html[data-font-mode="system"] .app-modal-card h2,
html[data-font-mode="system"] .study-book-cover strong,
html[data-font-mode="system"] .study-reader-paper > header h3,
html[data-font-mode="system"] .study-reader-content {
  font-family: var(--system-font);
}

.custom-model-option > span {
  min-width: 0;
  flex: 1;
}

.custom-model-input {
  width: 100%;
  margin-top: 11px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: var(--field);
  font: inherit;
  font-size: 12px;
}

.custom-model-input:focus {
  border-color: var(--focus-border);
  box-shadow: none;
}

.model-preset-list {
  display: flex;
  padding: 10px 12px 12px 42px;
  flex-wrap: wrap;
  gap: 7px;
}

.model-preset-list button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--field);
  font-size: 10px;
}

.model-preset-list button:hover,
.model-preset-list button:focus-visible {
  border-color: var(--focus-border);
  color: var(--ink);
}

.field-model-presets {
  margin-top: 8px;
  padding: 0;
  border-top: 0;
}

.settings-inline-note {
  margin: -2px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.model-fetch-box {
  display: grid;
  margin-top: 14px;
  gap: 9px;
}

.model-fetch-box small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.settings-detail-actions {
  display: flex;
  margin-top: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-detail-actions.end {
  justify-content: flex-end;
}

.mcp-settings .setting-switch-row {
  margin-bottom: 20px;
}

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

.mcp-source-card {
  display: grid;
  gap: 14px;
  margin: 10px 0 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 92% 8%, var(--success-soft), transparent 38%),
    var(--panel);
}

.mcp-source-card.secondary {
  background: var(--panel);
}

.mcp-source-heading {
  display: grid;
  gap: 4px;
}

.mcp-source-heading strong {
  font-size: 15px;
}

.mcp-source-heading small,
.mcp-source-card .field-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.mcp-add-direct {
  justify-self: end;
}

.mcp-server-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mcp-server-actions button {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel);
  font: inherit;
  font-size: 11px;
}

.mcp-server-actions button.delete {
  color: var(--danger);
}

.mcp-server-list {
  display: grid;
  gap: 10px;
}

.mcp-server-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.mcp-server-item.disabled {
  opacity: 0.62;
}

.mcp-server-main {
  min-width: 0;
}

.mcp-server-main strong,
.mcp-server-main small {
  display: block;
}

.mcp-server-main strong {
  font-size: 14px;
}

.mcp-server-url {
  margin-top: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.mcp-server-tools {
  margin-top: 8px;
  color: var(--success);
  font-size: 11px;
  line-height: 1.45;
}

.mcp-server-status {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--neutral-muted);
  font-size: 11px;
  white-space: nowrap;
}

.mcp-server-controls {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.mcp-server-toggle {
  justify-self: end;
}

.mcp-server-status.ready {
  color: var(--success);
  background: var(--success-soft);
}

.mcp-server-status.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.mcp-empty {
  min-height: 220px;
  margin-top: 10px;
}

.memory-settings .setting-switch-row {
  margin-bottom: 29px;
}

.memory-section-heading {
  display: flex;
  margin: 0 4px 9px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.memory-section-heading small {
  font-size: 11px;
  font-weight: 400;
}

.memory-list {
  display: grid;
  gap: 10px;
}

.search-field {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.search-field svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--muted);
}

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

.search-field input::placeholder {
  color: var(--placeholder);
}

.memory-settings .search-field {
  margin-bottom: 12px;
}

.search-highlight {
  padding: 0 0.12em;
  border-radius: 3px;
  color: inherit;
  background: var(--highlight);
}

.memory-card {
  display: flex;
  min-height: 184px;
  padding: 15px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.memory-card.disabled {
  opacity: 0.62;
}

.memory-card-main {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.memory-card-preview {
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.memory-card-preview:focus-visible {
  border-radius: 7px;
  box-shadow: 0 0 0 2px var(--focus-border);
}

.memory-card-text {
  display: -webkit-box;
  min-height: calc(1.62em * 3);
  margin: 0;
  line-height: 1.62;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.memory-card-meta {
  display: flex;
  margin-top: 10px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.memory-source {
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.memory-card-actions {
  display: flex;
  margin-top: 11px;
  padding-top: 10px;
  flex-shrink: 0;
  align-items: center;
  gap: 15px;
  border-top: 1px solid var(--line);
}

.memory-card-actions button {
  padding: 3px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.memory-card-actions button:hover {
  color: var(--ink);
}

.memory-card-actions .delete-memory {
  color: var(--danger);
}

.memory-toggle {
  position: relative;
  width: 40px;
  height: 24px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  outline: 0;
  background: var(--switch-off);
  cursor: pointer;
}

.memory-toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: none;
  content: "";
  transition: transform 150ms ease;
}

.memory-toggle:checked {
  background: var(--accent);
}

.memory-toggle:checked::after {
  transform: translateX(16px);
}

.memory-empty {
  display: flex;
  min-height: 270px;
  padding: 35px 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 15px;
  color: var(--muted);
  text-align: center;
}

.memory-empty-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 13px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.memory-empty-icon svg {
  width: 23px;
  height: 23px;
}

.memory-empty strong {
  color: var(--ink);
  font-size: 15px;
}

.memory-empty p {
  max-width: 310px;
  margin: 7px 0 18px;
  font-size: 12px;
  line-height: 1.55;
}

.secondary-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-weight: 600;
}

.memory-saved {
  padding: 4px 0;
  border: 0;
  color: var(--success);
  background: transparent;
  font-size: 12px;
}

.text-danger {
  padding: 9px 0;
  border: 0;
  color: var(--danger);
  background: transparent;
  font-size: 13px;
}

.primary-button {
  padding: 10px 17px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  font-weight: 600;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.app-modal,
.usage-modal,
.choice-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  padding: 18px;
  place-items: center;
}

.file-preview {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  background: var(--paper);
}

.file-preview[hidden] {
  display: none;
}

.file-preview-topbar {
  display: flex;
  min-height: calc(68px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--paper-rgb), 0.96);
}

.file-preview-topbar > div:first-child {
  min-width: 0;
}

.file-preview-topbar strong,
.file-preview-topbar small {
  display: block;
}

.file-preview-topbar strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-topbar small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.file-preview-actions,
.file-preview-download {
  display: flex;
  align-items: center;
}

.file-preview-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.file-preview-download {
  min-height: 38px;
  padding: 0 11px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
}

.file-preview-download[hidden] {
  display: none;
}

.file-preview-download svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-preview-download:hover,
.file-preview-download:focus-visible {
  border-color: var(--focus-border);
  background: var(--hover);
}

.file-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.file-preview-image-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  place-items: center;
  overscroll-behavior: contain;
  background:
    linear-gradient(45deg, rgba(var(--ink-rgb), 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(var(--ink-rgb), 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(var(--ink-rgb), 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(var(--ink-rgb), 0.035) 75%),
    var(--paper);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  touch-action: pan-x pan-y pinch-zoom;
}

.file-preview-image-stage[hidden] {
  display: none;
}

.file-preview-image-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 32px rgba(var(--ink-rgb), 0.16);
}

.app-modal[hidden],
.usage-modal[hidden],
.choice-modal[hidden] {
  display: none;
}

.app-modal-backdrop,
.usage-modal-backdrop,
.choice-modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
}

.choice-modal-card {
  position: relative;
  width: min(420px, 100%);
  max-height: min(680px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: none;
}

.choice-modal-header {
  display: flex;
  padding: 18px 18px 14px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.choice-modal-header h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 21px;
  font-weight: 500;
}

.choice-modal-options {
  display: grid;
  max-height: min(520px, calc(100dvh - 130px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.choice-modal-option {
  display: grid;
  width: 100%;
  min-height: 64px;
  padding: 15px 20px;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.choice-modal-option:last-child {
  border-bottom: 0;
}

.choice-modal-option:hover,
.choice-modal-option:focus-visible,
.choice-modal-option.selected {
  background: var(--panel);
}

.choice-modal-option-label {
  min-width: 0;
  line-height: 1.45;
}

.choice-modal-radio {
  display: grid;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  place-items: center;
}

.choice-modal-option.selected .choice-modal-radio {
  border-color: var(--accent);
}

.choice-modal-option.selected .choice-modal-radio::after {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.usage-modal-card {
  position: relative;
  display: grid;
  width: min(440px, 100%);
  max-height: min(780px, calc(100dvh - 36px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: none;
}

.usage-modal-header {
  display: flex;
  padding: 19px 20px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.usage-modal-header > div {
  min-width: 0;
}

.usage-modal-header h2,
.usage-modal-header p {
  margin: 0;
}

.usage-modal-header h2 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 500;
}

.usage-modal-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.usage-modal-body {
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.usage-modal-body .usage-panel {
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.recalled-memories-card {
  width: min(620px, 100%);
}

.recalled-memories-body {
  display: grid;
  gap: 11px;
}

.recalled-memory-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
}

.recalled-memory-item span {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 650;
}

.recalled-memory-item p {
  margin: 7px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.vector-memory-editor-card {
  width: min(720px, 100%);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.vector-memory-editor-body {
  display: grid;
  gap: 14px;
}

.vector-memory-content-field {
  margin: 0;
}

.vector-memory-content-field textarea {
  min-height: 190px;
}

.vector-memory-advanced {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
}

.vector-memory-advanced > summary {
  padding: 12px 14px;
  color: var(--subtle-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.vector-memory-editor-grid {
  display: grid;
  padding: 0 14px 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.vector-memory-editor-grid .field {
  min-width: 0;
  margin: 0;
}

.vector-memory-editor-actions {
  display: flex;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line);
}

@media (max-width: 560px) {
  .vector-memory-editor-card {
    width: 100%;
    max-height: calc(100dvh - 16px);
  }

  .vector-memory-editor-grid {
    grid-template-columns: 1fr;
  }

  .vector-memory-editor-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .vector-memory-editor-actions button {
    width: 100%;
  }
}

.app-modal-card {
  position: relative;
  width: min(420px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: none;
}

.app-modal-card h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 500;
}

.app-modal-card > p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.app-modal-field {
  display: block;
  margin-top: 19px;
}

.app-modal-field span {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
}

.app-modal-field input,
.app-modal-field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: var(--field);
  resize: vertical;
}

.app-modal-field textarea {
  min-height: 145px;
  line-height: 1.55;
}

.app-modal-field input:focus,
.app-modal-field textarea:focus {
  border-color: var(--focus-border);
}

.app-modal-attachment-editor {
  margin-top: 17px;
}

.app-modal-attachment-heading {
  display: flex;
  margin-bottom: 8px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
}

.app-modal-attachment-heading button {
  display: inline-flex;
  padding: 6px 8px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
  font-size: 11px;
}

.app-modal-attachment-heading button:disabled {
  opacity: 0.55;
}

.app-modal-attachment-heading svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-modal-attachment-list {
  display: grid;
  gap: 7px;
}

.app-modal-attachment-list .composer-attachment {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.app-modal-attachment-empty {
  margin: 0;
  padding: 13px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.app-modal-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.app-modal-actions {
  display: flex;
  margin-top: 23px;
  justify-content: flex-end;
  gap: 9px;
}

.app-modal-actions button {
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 600;
}

.modal-cancel {
  border: 1px solid var(--line);
  background: transparent;
}

.modal-confirm {
  border: 1px solid var(--accent);
  color: white;
  background: var(--accent);
}

.modal-confirm.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.mobile-only {
  display: none;
}

@media (max-width: 760px) {
  .wake-limit-grid {
    grid-template-columns: 1fr;
  }

  .wake-keepalive-bind-row {
    grid-template-columns: 1fr;
  }

  :root {
    --messages-bottom-space: 55px;
  }

  .workspace-topbar {
    min-height: calc(62px + env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .workspace-topbar h2 {
    font-size: 17px;
  }

  .workspace-content {
    padding: 18px 14px max(32px, env(safe-area-inset-bottom));
  }

  .library-item {
    padding: 13px;
  }

  .library-item-header {
    display: grid;
    justify-content: stretch;
    gap: 4px;
  }

  .library-item-header small {
    white-space: normal;
  }

  .library-editor textarea {
    min-height: 52vh;
  }

  .nest-topbar {
    min-height: calc(58px + env(safe-area-inset-top));
  }

  .study-shelf-scroll {
    padding: 16px 14px 30px;
  }

  .study-recent {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    margin-bottom: 22px;
    padding: 17px;
    border-radius: 18px;
  }

  .study-recent-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .study-recent h3 {
    font-size: 16px;
  }

  .study-recent p {
    font-size: 11px;
  }

  .study-recent .secondary-button {
    width: 100%;
    padding: 8px 10px;
    grid-column: 1 / -1;
    font-size: 11px;
  }

  .study-heading {
    align-items: flex-end;
  }

  .study-heading .secondary-button {
    padding: 8px 10px;
    font-size: 11px;
  }

  .study-book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
  }

  .study-book-cover {
    min-height: 196px;
  }

  .study-book-delete {
    opacity: 1;
  }

  .study-reader-toolbar {
    min-height: 52px;
    padding-right: 9px;
    padding-left: 9px;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 4px;
  }

  .study-reader-back,
  .study-reader-leave,
  .study-reader-companion,
  .study-reader-directory {
    padding: 7px 4px;
    font-size: 10px;
  }

  .study-reader-actions {
    gap: 0;
  }

  .study-reading-status {
    min-height: 31px;
    padding-right: 10px;
    padding-left: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 6px;
    font-size: 8px;
  }

  .study-reading-status button {
    padding: 5px 7px;
    font-size: 8px;
  }

  .study-reader-paper {
    width: 100%;
    padding: 38px 22px 64px;
  }

  .study-reader-paper > header {
    margin-bottom: 28px;
  }

  .study-reader-paper > header h3 {
    font-size: 22px;
  }

  .study-reader-content {
    font-size: 16.5px;
    line-height: 2.05;
  }

  .study-reader-block {
    margin-bottom: 1.15em;
    text-align: left;
  }

  .study-companion-panel {
    right: 7px;
    bottom: 7px;
    left: 7px;
    height: min(52vh, 430px);
    min-height: 260px;
    border-radius: 16px;
  }

  .study-companion-messages {
    padding: 12px;
  }

  .study-companion-message {
    max-width: 90%;
  }

  .study-selection-toolbar {
    bottom: 8px;
    width: calc(100% - 14px);
    padding: 8px 8px 8px 10px;
    border-radius: 13px;
  }

  .study-selection-toolbar > span {
    font-size: 9px;
  }

  .study-selection-toolbar button {
    padding: 7px 9px;
    font-size: 9px;
  }

  .nest-tabs {
    width: 100%;
    min-height: calc(61px + env(safe-area-inset-bottom));
    padding-top: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
  }

  .nest-tabs button {
    font-size: 9px;
  }

  .nest-tabs svg {
    width: 19px;
    height: 19px;
  }

  .app-shell {
    display: block;
  }

  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: none;
  }

  .scrim {
    position: fixed;
    z-index: 19;
    inset: 0;
    display: block;
    background: var(--scrim);
  }

  .topbar {
    height: calc(66px + env(safe-area-inset-top));
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: 12px;
    padding-right: 14px;
    padding-left: 10px;
  }

  .conversation-heading {
    flex: 1;
  }

  .conversation-title {
    text-align: left;
  }

  .conversation-token-summary {
    font-size: 9.5px;
  }

  .welcome {
    padding: 46px 17px 75px;
    justify-content: flex-start;
  }

  .welcome-mark {
    margin-top: min(9vh, 70px);
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }

  .suggestion {
    min-height: 72px;
  }

  .messages {
    padding: 25px 15px var(--messages-bottom-space);
  }

  .message {
    margin-bottom: 25px;
  }

  .message.user .message-content {
    max-width: 88%;
  }

  .composer-zone {
    padding-right: 10px;
    padding-left: 10px;
  }

  .composer {
    border-radius: 17px;
  }

  .settings-topbar {
    min-height: calc(64px + env(safe-area-inset-top));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .settings-heading h2 {
    font-size: 24px;
  }

  .settings-detail-topbar {
    min-height: calc(58px + env(safe-area-inset-top));
  }

  .settings-content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .settings-home {
    padding-top: 20px;
  }

  .settings-group {
    margin-bottom: 25px;
  }

  .settings-row {
    min-height: 68px;
    padding: 11px 12px;
    gap: 10px;
  }

  .settings-row-value {
    max-width: 92px;
  }

  .data-backup-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .data-backup-card button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .settings-detail {
    padding-top: 27px;
  }

  .settings-detail-intro {
    margin-bottom: 23px;
  }

  .theme-options {
    grid-template-columns: 1fr;
  }

  .custom-theme-color-grid {
    grid-template-columns: 1fr;
  }

  .custom-theme-editor-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .custom-theme-editor-heading .compact-button {
    align-self: flex-start;
  }

  .color-picker-modal {
    padding: 12px;
    align-items: end;
  }

  .color-picker-card {
    width: 100%;
    margin-bottom: max(0px, env(safe-area-inset-bottom));
    padding: 17px;
    border-radius: 22px;
  }

  .color-picker-saturation {
    height: min(205px, 27dvh);
  }

  .mcp-server-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .mcp-server-status {
    justify-self: start;
  }

  .mcp-server-controls {
    justify-items: start;
  }

  .field textarea {
    min-height: 250px;
  }

  .app-modal,
  .usage-modal,
  .choice-modal {
    padding: 14px;
  }

  .app-modal,
  .choice-modal {
    align-items: end;
  }

  .app-modal-card {
    margin-bottom: max(0px, env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .usage-modal-card {
    max-height: min(82dvh, 760px);
    border-radius: 18px;
  }

  .choice-modal-card {
    width: 100%;
    margin-bottom: max(0px, env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .model-preset-list {
    padding-left: 38px;
  }

  .field-model-presets {
    padding-left: 0;
  }

  .voice-setting-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
