:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-alt: #fbfbf8;
  --control: #ffffff;
  --ink: #1b2424;
  --muted: #687170;
  --line: #dfe2dc;
  --accent: #256f6c;
  --accent-hover: #1f5e5b;
  --on-accent: #ffffff;
  --accent-2: #9a5b22;
  --soft: #edf4f1;
  --danger: #a64040;
  --danger-line: #e3b9b9;
  --user-message: #e9e0d7;
  --working-bg: #fff8ef;
  --working-line: #d9bf9f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111716;
  --panel: #18211f;
  --panel-alt: #141c1a;
  --control: #101615;
  --ink: #edf3ef;
  --muted: #9fb0ac;
  --line: #2b3936;
  --accent: #62b9b1;
  --accent-hover: #79cbc4;
  --on-accent: #071211;
  --accent-2: #d69a5f;
  --soft: #203430;
  --danger: #e37d7d;
  --danger-line: #704243;
  --user-message: #342a22;
  --working-bg: #2b241b;
  --working-line: #6d5638;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgb(0 0 0 / 12%);
}

.auth-card h1 {
  margin: 0;
  font-size: 1.4rem;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 4px;
  justify-self: start;
}

.stack-form {
  display: grid;
  gap: 12px;
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 74px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel-alt);
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-account {
  position: relative;
  flex: 0 0 auto;
}

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

.sidebar-toggle {
  margin-left: auto;
  flex: 0 0 auto;
}

.app-shell.sidebar-collapsed .sidebar {
  padding-left: 16px;
  padding-right: 16px;
}

.app-shell.sidebar-collapsed .brand {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .panel {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}

.mark {
  border: 0;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  font-weight: 800;
}

.mark:hover {
  border: 0;
  background: var(--accent-hover);
}

.account-mark {
  border-radius: 999px;
}

.account-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 180px;
  padding: 8px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
}

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

.account-menu-item {
  width: 100%;
  text-align: left;
  min-height: 40px;
}

.brand h1,
.brand p,
.panel h2,
.topbar h2,
.section-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1rem;
}

.brand p,
.muted,
.section-head p,
.big-action small {
  color: var(--muted);
}

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel.is-collapsed {
  gap: 0;
}

.panel.is-collapsed > :not(.panel-head),
.panel.is-collapsed .panel-head > :not(h2) {
  display: none;
}

.panel-head,
.topbar,
.section-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-head {
  margin: 14px 0 8px;
}

.compact-head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.push-enrollment {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.is-disabled {
  opacity: 0.65;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title-button {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.panel-title-button:hover {
  border: 0;
  color: var(--accent);
}

.panel-title-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1.4rem;
}

.wiki-list,
.file-list,
.cost-rows {
  display: grid;
  gap: 8px;
}

.sidebar-action {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  text-align: left;
  align-content: center;
}

.sidebar-action span {
  font-weight: 750;
  color: var(--accent);
}

.sidebar-action small {
  color: var(--muted);
}

.sidebar-action.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.chat-hub-sidebar-panel .chat-hub-launcher {
  position: relative;
  min-height: 64px;
  border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
  background: var(--control);
}

.chat-hub-sidebar-panel .chat-hub-launcher span {
  color: var(--accent);
}

.chat-hub-sidebar-panel .chat-hub-launcher.has-pending,
.chat-hub-sidebar-panel .chat-hub-launcher.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.notes-sidebar-panel {
  gap: 10px;
  min-height: auto;
}

.notes-sidebar-panel .panel-head {
  align-items: start;
}

.notes-sidebar-panel .panel-actions .mini-button {
  min-height: 30px;
  padding: 2px 8px;
}

.notes-sidebar-tree-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: auto;
  min-width: 0;
}

.notes-sidebar-tree-panel input {
  width: 100%;
}

.tasks-sidebar-panel {
  gap: 10px;
  min-height: auto;
}

.tasks-sidebar-panel .panel-head {
  align-items: start;
}

.tasks-sidebar-panel .panel-actions .mini-button {
  min-height: 30px;
  padding: 2px 8px;
}

.tasks-sidebar-list-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: auto;
  min-width: 0;
}

.wiki-secondary-action {
  margin-top: 8px;
}

.wiki-item,
.cost-row {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
}

.wiki-item {
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  padding: 6px;
}

.wiki-open-button {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 38px;
  padding: 4px;
  border: 0;
  text-align: left;
}

.wiki-open-button:hover {
  border: 0;
  color: var(--accent);
}

.wiki-open-button strong,
.wiki-open-button small {
  overflow-wrap: anywhere;
}

.wiki-menu {
  position: relative;
  width: 30px;
}

.wiki-menu summary {
  width: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

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

.wiki-menu[open] summary,
.wiki-menu summary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wiki-menu-popover {
  position: absolute;
  z-index: 10;
  top: 36px;
  right: 0;
  width: 150px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgb(0 0 0 / 12%);
}

.wiki-menu-popover button {
  min-height: 34px;
  justify-content: start;
  text-align: left;
}

.wiki-delete-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: var(--danger-line);
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
}

.wiki-delete-button:hover {
  border-color: var(--danger);
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
}

.file-row.has-checkbox {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-open-button {
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.source-open-button:hover {
  border: 0;
  color: var(--accent);
}

.file-row span,
.source-open-button {
  min-width: 0;
  overflow-wrap: anywhere;
}

.danger-button {
  color: var(--danger);
  border-color: var(--danger-line);
  min-height: 34px;
  padding: 0 10px;
}

.danger-button:hover {
  border-color: var(--danger);
}

.wiki-item.is-active,
.tree-file.is-active,
.file-row.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

#pageList,
.tree-root,
.tree-children {
  display: grid;
  gap: 6px;
}

.tree-children {
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.page-nav-toggle {
  width: 100%;
  min-height: 38px;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
}

.page-nav-toggle:hover,
.page-nav-toggle:focus-visible {
  border: 0;
  color: var(--accent);
}

.page-nav-toggle span {
  font-size: 1.05rem;
  font-weight: 760;
  color: var(--ink);
}

.page-nav-toggle small {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-nav-toggle::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.78rem;
}

.page-nav.is-collapsed #pageList {
  display: none;
}

.page-nav.is-collapsed .page-nav-toggle::after {
  content: "▸";
}

.tree-folder,
.tree-file {
  width: 100%;
  min-height: 34px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
}

.tree-folder {
  color: var(--accent);
  font-weight: 700;
}

.tree-folder span {
  width: 16px;
  color: var(--muted);
  text-align: center;
}

.tree-file {
  font-size: 0.9rem;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
}

.app-shell.workspace-view-active .workspace {
  grid-template-rows: auto 1fr;
}

.app-shell.app-top-chrome-active .workspace {
  grid-template-rows: auto auto 1fr;
}

.app-shell.workspace-view-active .topbar,
.app-shell.workspace-view-active .tabs {
  display: none;
}

.app-shell.workspace-view-active .views {
  padding-top: 12px;
}

.ai-status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  min-height: 72px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.ai-status-strip > .model-status {
  margin-left: auto;
}

.chat-hub-top-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) 360px minmax(96px, auto);
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 56px;
}

.chat-hub-top-controls[hidden] {
  display: none;
}

.app-top-controls {
  min-width: 0;
  flex: 1 1 auto;
}

.app-top-controls[hidden] {
  display: none;
}

.section-head.is-in-app-top,
.topbar.is-in-app-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.wiki-section-head.is-in-app-top {
  grid-template-columns: minmax(140px, 1fr) auto minmax(0, auto);
}

.section-head.is-in-app-top > div:first-child,
.topbar.is-in-app-top > div:first-child {
  min-width: 0;
}

.section-head.is-in-app-top h2,
.section-head.is-in-app-top h3,
.topbar.is-in-app-top h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head.is-in-app-top p,
.topbar.is-in-app-top p {
  max-width: min(560px, 45vw);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head.is-in-app-top > :last-child:not(:first-child),
.topbar.is-in-app-top > :last-child:not(:first-child) {
  min-width: 0;
}

.section-head.is-in-app-top button,
.section-head.is-in-app-top .file-button,
.topbar.is-in-app-top button {
  min-height: 34px;
}

.section-head.is-in-app-top input,
.section-head.is-in-app-top select {
  min-height: 34px;
}

.section-head.is-in-app-top .source-actions,
.section-head.is-in-app-top .prewiki-upload-actions,
.section-head.is-in-app-top .editor-actions {
  max-width: min(62vw, 820px);
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: flex-end;
}

.section-head.is-in-app-top .url-input-row {
  flex: 0 0 auto;
}

.topbar.is-in-app-top .tabs {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.topbar.is-in-app-top .tab {
  min-height: 34px;
  padding: 0 12px;
}

.chat-hub-top-title {
  min-width: 0;
}

.chat-hub-top-title h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-hub-top-controls .chat-hub-tabbar {
  width: 360px;
}

.chat-hub-top-controls[data-chat-hub-tab-current="conversations"] .chat-hub-model-summary,
.chat-hub-top-controls[data-chat-hub-tab-current="notifications"] .chat-hub-model-summary {
  display: none;
}

.topbar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

.wiki-title-block h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-wiki-menu-shell {
  position: relative;
  display: none;
  flex-shrink: 0;
}

.mobile-wiki-menu-button {
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 1.05rem;
}

.mobile-wiki-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 0;
  width: min(78vw, 280px);
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 42px rgb(0 0 0 / 18%);
}

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

.mobile-wiki-menu-section {
  display: grid;
  gap: 6px;
}

.mobile-wiki-menu-section + .mobile-wiki-menu-section {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.mobile-wiki-menu button {
  justify-content: start;
  min-height: 42px;
  text-align: left;
}

.mobile-wiki-menu button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.model-control {
  display: grid;
  gap: 5px;
  min-width: min(360px, 42vw);
}

.manager-model-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.manager-model-panel h3 {
  margin-bottom: 4px;
}

.manager-model-panel p {
  margin: 0;
  color: var(--muted);
}

.manager-model-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  min-width: min(520px, 56vw);
}

.manager-model-controls .model-control {
  flex: 1;
}

.model-pricing {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.thinking-select {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.8rem;
}

.model-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--muted);
  white-space: nowrap;
}

.model-status span {
  grid-row: 1 / span 2;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6f8f72;
}

.model-status strong {
  font-size: 0.9rem;
  line-height: 1.1;
}

.model-status small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.1;
}

.mini-button {
  grid-row: 1 / span 2;
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.74rem;
}

.model-status.working span {
  background: var(--accent-2);
  animation: pulse 1s ease-in-out infinite;
}

.model-status.working {
  color: var(--ink);
  border-color: var(--working-line);
  background: var(--working-bg);
}

.global-chat-launcher {
  position: relative;
  min-height: 48px;
  padding: 0 14px;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel);
}

.global-chat-launcher.has-pending {
  background: var(--soft);
}

.context-help-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 220;
  width: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 999px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 0 14px 36px rgb(0 0 0 / 22%);
}

.context-help-button:hover,
.context-help-button[aria-expanded="true"] {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.context-help-button[hidden] {
  display: none;
}

.context-help-panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px);
  z-index: 230;
  width: min(430px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 116px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgb(0 0 0 / 24%);
  overflow: hidden;
}

.context-help-panel[hidden] {
  display: none;
}

.context-help-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.context-help-head h3 {
  margin: 0;
  font-size: 1rem;
}

.context-help-head small {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin-top: 3px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-help-log {
  min-height: 0;
  max-height: none;
  padding: 14px;
  overflow-y: auto;
}

.context-help-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.context-help-form textarea {
  min-height: 46px;
  max-height: 120px;
  resize: vertical;
}

.context-help-form button {
  min-height: 46px;
}

.context-help-panel .voice-status {
  min-height: 24px;
  margin: 0;
  padding: 0 12px 10px;
  color: var(--muted);
}

.approvals-shell {
  position: relative;
}

.approvals-button {
  position: relative;
  min-height: 48px;
  padding: 0 14px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.approvals-button.has-pending {
  border-color: var(--accent);
}

.approvals-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.72rem;
  line-height: 1;
}

.approvals-popover {
  position: fixed;
  top: 74px;
  right: 24px;
  z-index: 320;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.approvals-popover-head {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.approvals-popover-head small {
  color: var(--muted);
}

.approvals-list {
  display: grid;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
}

.global-chat-tools-layout {
  align-items: stretch;
}

.tasks-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(340px, 1fr);
  gap: 14px;
  align-items: start;
}

.task-list {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.task-folder-group {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.task-list-children {
  display: grid;
  gap: 4px;
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.task-folder-title {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 28px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: left;
  text-transform: none;
  cursor: pointer;
}

.task-folder-title.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--soft);
}

.task-folder-title.is-expanded {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: var(--panel);
}

.task-folder-title.is-dragging,
.task-list-row.is-dragging,
.task-reminder-row.is-dragging {
  opacity: 0.5;
}

.task-folder-title.is-drop-target,
.task-list-row.is-drop-target,
.focus-task-list-button.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--soft);
}

.task-folder-chevron {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
}

.task-folder-empty {
  margin: 0 0 4px 28px;
  font-size: 0.82rem;
}

.task-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  grid-template-rows: auto auto;
  gap: 5px;
  width: 100%;
  min-height: 30px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  text-align: left;
  align-content: center;
  cursor: pointer;
  font-size: 0.8rem;
}

.task-list-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-list-row small {
  grid-column: 1;
  font-size: 0.7rem;
  line-height: 1.15;
}

.task-list-row small {
  color: var(--muted);
}

.task-list-row.is-active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.task-tree-delete-button {
  display: grid;
  min-width: 22px;
  min-height: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  place-items: center;
  align-self: center;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  text-transform: none;
}

.task-folder-title .task-tree-delete-button {
  grid-column: 3;
  grid-row: 1;
}

.task-list-row .task-tree-delete-button {
  grid-column: 2;
  grid-row: 1 / 3;
}

.task-tree-delete-button svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.sidebar .panel {
  gap: 8px;
  padding: 10px;
}

.sidebar .panel-head {
  min-height: 30px;
}

.sidebar .panel h2,
.sidebar .panel-title-button {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-action,
.wiki-open-button,
.note-tree-button,
.note-tree-folder-title,
.task-folder-title,
.task-list-row {
  border-color: var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font-size: 0.8rem;
}

.sidebar-action {
  min-height: 44px;
  padding: 7px 9px;
}

.chat-hub-sidebar-panel .chat-hub-launcher {
  min-height: 44px;
  border-color: var(--line);
}

.sidebar-action span,
.wiki-open-button strong,
.note-tree-button span,
.note-tree-folder-title span,
.task-list-row strong {
  color: inherit;
  font-weight: 720;
}

.sidebar-action small,
.wiki-open-button small,
.note-tree-button small,
.task-list-row small {
  color: var(--muted);
  font-size: 0.7rem;
}

.wiki-item {
  padding: 3px;
  border-radius: 6px;
}

.wiki-open-button,
.note-tree-button,
.note-tree-folder-title {
  min-height: 30px;
  padding: 4px 6px;
}

.sidebar-action.is-active,
.wiki-item.is-active,
.note-tree-button.is-active,
.task-folder-title.is-active,
.task-list-row.is-active,
.chat-hub-sidebar-panel .chat-hub-launcher.is-active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.note-tree-folder-title.is-expanded,
.task-folder-title.is-expanded {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: var(--panel);
  color: var(--ink);
}

.note-tree-entry .note-tree-button,
.note-tree-entry .note-tree-folder-title {
  border: 0;
  background: transparent;
  color: inherit;
}

.note-tree-entry .note-tree-button:hover,
.note-tree-entry .note-tree-folder-title:hover,
.note-tree-entry .note-tree-button.is-active,
.note-tree-entry .note-tree-folder-title.is-expanded {
  border: 0;
  background: transparent;
  color: inherit;
}

.note-tree-row.is-active > .note-tree-entry,
.note-tree-row.is-expanded > .note-tree-entry {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.task-tree-delete-button:hover,
.task-tree-delete-button:focus-visible {
  background: var(--soft);
  color: var(--danger);
  outline: none;
}

.task-row {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 48px;
  padding: 8px 10px 8px 18px;
  text-align: left;
  align-content: center;
  overflow-wrap: anywhere;
}

.task-row small {
  color: var(--muted);
}

.task-row.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.task-row.is-completed {
  opacity: 0.68;
}

.task-row.is-completed strong {
  text-decoration: line-through;
}

.task-editor-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

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

.task-reminder-list {
  display: grid;
  gap: 8px;
}

.task-list-content-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: end;
}

.task-done-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.task-done-filter input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.task-done-filter input[type="checkbox"]::after {
  content: "✓";
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  top: 0;
  left: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
}

.task-done-filter input[type="checkbox"]:checked::after {
  opacity: 1;
  transform: none;
}

.task-reminder-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  cursor: grab;
}

.task-reminder-row:active {
  cursor: grabbing;
}

.task-reminder-row input[type="checkbox"].task-complete-checkbox {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  width: 20px;
  height: 20px;
  margin: 0;
  box-sizing: border-box;
  position: relative;
  justify-self: center;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
}

.task-reminder-row input[type="checkbox"].task-complete-checkbox::after {
  content: "";
  position: absolute;
  inset: 4px 3px 3px 4px;
  display: block;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  clip-path: polygon(14% 52%, 34% 72%, 84% 18%, 96% 30%, 35% 92%, 3% 60%);
  opacity: 0;
  transform: none;
  transition: opacity 0.12s ease;
}

.task-reminder-row input[type="checkbox"].task-complete-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.task-reminder-row input[type="checkbox"].task-complete-checkbox:checked::after {
  opacity: 1;
  transform: none;
}

.task-reminder-detail {
  display: grid;
  width: 100%;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  align-content: center;
}

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

.recycle-bin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.recycle-bin-item h3 {
  margin: 2px 0;
  font-size: 1rem;
}

.recycle-bin-item p {
  margin: 0 0 4px;
  color: var(--muted);
}

.recycle-bin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .recycle-bin-item {
    grid-template-columns: 1fr;
  }

  .recycle-bin-actions {
    justify-content: flex-start;
  }
}

.task-reminder-row small {
  display: block;
  color: var(--muted);
}

.task-reminder-row.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.task-reminder-row.is-completed strong {
  text-decoration: line-through;
}

.skill-tuning-dialog {
  width: min(1120px, calc(100vw - 28px));
}

.skill-tuning-card {
  width: 100%;
  max-height: min(860px, calc(100vh - 32px));
  overflow: auto;
}

.skill-tuning-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(320px, 1.18fr);
  gap: 14px;
}

.skill-tuning-config,
.skill-tuning-results {
  display: grid;
  align-content: start;
  gap: 12px;
}

.skill-tuning-results h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
}

.skill-tuning-results pre {
  min-height: 110px;
  max-height: 220px;
}

.task-reminder-check {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
}

.compact-toggle {
  min-height: 40px;
}

.tool-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.tool-meta {
  margin-bottom: 12px;
}

#globalChatToolJson,
#globalChatToolTestInput {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
}

.approval-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
}

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

.ghost-button:hover {
  color: var(--text);
  border-color: var(--line);
}

.approval-item-head,
.approval-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.approval-item-head span {
  text-transform: capitalize;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.approval-item h3,
.approval-item p {
  margin: 0;
}

.approval-item h3 {
  font-size: 0.95rem;
}

.approval-item p,
.approval-item small {
  color: var(--muted);
  font-size: 0.8rem;
}

.approval-item .attention-summary {
  white-space: pre-wrap;
}

.approval-item pre {
  max-height: 150px;
  margin: 0;
  padding: 8px;
  overflow: auto;
  border-radius: 6px;
  background: var(--panel);
  font-size: 0.72rem;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.message-meta span {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}

.message-action-card {
  margin-top: 8px;
}

.message-tool-trace {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  overflow: hidden;
}

.message-tool-trace summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
}

.message-tool-trace summary span {
  color: var(--text);
  font-weight: 700;
}

.message-tool-trace summary small {
  color: var(--muted);
}

.message-tool-list {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.message-tool-call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 8px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--control);
}

.message-tool-call.is-failed {
  border-left-color: var(--danger);
}

.message-tool-call.is-running,
.message-tool-call.is-queued {
  border-left-color: var(--accent-2);
}

.message-tool-call strong,
.message-tool-call p {
  margin: 0;
}

.message-tool-call p,
.message-tool-call small {
  color: var(--muted);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.activity-context-chip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-hub {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.chat-hub-tabbar {
  min-width: 0;
  align-self: center;
}

.chat-hub-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
  width: min(100%, 360px);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--control);
}

.chat-hub-tab {
  min-width: 0;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chat-hub-tab.is-active {
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent);
}

.chat-hub-sidebar,
.chat-hub-main,
.chat-hub-attention {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chat-hub-main {
  z-index: 1;
}

.chat-hub-attention {
  z-index: 2;
}

.chat-hub-sidebar,
.chat-hub-attention {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  padding: 12px;
}

.chat-hub-attention {
  grid-template-rows: auto minmax(0, 1fr);
}

.chat-hub-sidebar-head,
.chat-hub-attention-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  min-width: 0;
}

.chat-hub-sidebar-head .mini-button,
.chat-hub-attention-head .mini-button {
  width: 100%;
}

.chat-hub-context-row,
.chat-hub-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.chat-hub-sidebar h3,
.chat-hub-attention h3,
.chat-hub-head h2 {
  margin: 0;
}

.chat-thread-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-top: 8px;
}

.compact-search-input {
  width: 100%;
  height: 32px;
  min-height: 0;
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.84rem;
  box-sizing: border-box;
}

.chat-thread-help-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
}

.chat-thread-help-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.chat-thread-card {
  width: 100%;
  min-height: 58px;
  display: grid;
  gap: 4px;
  align-content: center;
  text-align: left;
  padding: 9px 10px;
  background: var(--control);
}

.chat-thread-card.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.chat-thread-card.is-default {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.chat-thread-card span,
.chat-thread-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread-card small {
  color: var(--muted);
}

.chat-thread-card em {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  font-style: normal;
  vertical-align: middle;
}

.chat-hub-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: 8px 12px 12px;
  overflow: hidden;
}

.chat-hub-head {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-hub-head-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(230px, 360px) auto;
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.chat-hub-menu-shell {
  position: relative;
  z-index: 5;
}

.chat-hub-pane-menu-button {
  width: 34px;
  min-height: 34px;
  border-radius: 7px;
  font-size: 0.98rem;
}

.chat-hub-pane-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgb(0 0 0 / 18%);
}

.chat-hub-pane-menu[hidden],
.chat-hub-model-options[hidden] {
  display: none;
}

.chat-hub-menu-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.chat-hub-menu-actions .mini-button,
.chat-hub-menu-item {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 6px;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.76rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-hub-menu-item {
  text-align: center;
}

.chat-hub-model-options {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
}

.chat-hub-model-options label {
  gap: 5px;
  font-size: 0.76rem;
}

.chat-hub-model-options select {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.82rem;
}

.chat-hub-title-block {
  min-width: 0;
}

.chat-hub-title-block .eyebrow {
  margin-bottom: 2px;
}

.chat-hub-model-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.chat-hub-model-summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-hub-head-right {
  display: flex;
  align-items: start;
  justify-content: end;
  gap: 8px;
  min-width: 0;
}

.chat-hub-head-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(248px, 292px);
  gap: 10px;
  align-items: stretch;
  min-width: 0;
}

.chat-hub-head-left {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.chat-hub-context-row {
  justify-content: start;
  gap: 6px;
  margin: 0;
  min-width: 0;
}

.chat-hub-status-pill,
.chat-hub-context-row .activity-context-chip,
.chat-hub-context-row .context-meter {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  white-space: nowrap;
}

.chat-hub-status-pill {
  color: var(--accent);
  background: var(--soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.chat-hub-log {
  height: auto;
  max-height: none;
  min-height: 0;
  align-self: stretch;
  overflow-y: auto;
}

.chat-hub-form {
  grid-template-columns: minmax(0, 1fr) 60px 76px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  align-items: stretch;
  z-index: 1;
}

.chat-hub-form #chatHubVoiceButton.is-active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.chat-hub-attention .approvals-list {
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  grid-auto-rows: max-content;
  padding: 10px 0 0;
}

.chat-hub-attention-head h3 {
  margin: 0;
}

.chat-hub-attention .approval-item {
  align-self: start;
  min-width: 0;
  overflow: hidden;
}

.chat-hub-attention .approval-item-head,
.chat-hub-attention .approval-actions {
  align-items: start;
  flex-wrap: wrap;
}

.chat-hub-attention .approval-actions button {
  pointer-events: auto;
}

.chat-hub-attention .approval-item h3,
.chat-hub-attention .approval-item p,
.chat-hub-attention .approval-item small {
  overflow-wrap: anywhere;
}

.chat-hub [hidden] {
  display: none !important;
}

.typing-indicator,
.status-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator span,
.status-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: typing-dot 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2),
.status-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3),
.status-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-dot {
  0%,
  80%,
  100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.5;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  background: var(--panel-alt);
}

.tab {
  min-width: max-content;
}

.tab.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.views,
.empty-state {
  min-height: 0;
  padding: 20px 24px;
}

.views {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.is-hidden {
  display: none !important;
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

#chatHubView.view.is-active {
  display: grid;
  height: calc(100vh - 170px);
  overflow: hidden;
}

.split {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 170px);
  overflow: hidden;
}

.page-nav,
.reader {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  min-width: 0;
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
}

.page-nav.is-collapsed {
  height: auto;
  align-self: start;
  overflow: hidden;
}

.reader-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.back-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.page-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.transcript-link {
  min-height: 34px;
  color: var(--accent);
}

.markdown {
  line-height: 1.65;
  max-width: 860px;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.2;
}

.markdown a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.markdown code {
  background: var(--soft);
  padding: 2px 5px;
  border-radius: 5px;
}

.file-button {
  display: inline-grid;
  width: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 10px 14px;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.source-split {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  height: calc(100vh - 260px);
  overflow: hidden;
}

.source-split .file-list {
  overflow: auto;
  height: 100%;
}

.source-actions input[type="text"],
.prewiki-upload-actions input[type="text"],
.staging-actions input[type="text"] {
  min-height: 36px;
  min-width: 180px;
}

.source-folder-root.is-active,
.tree-folder.is-active {
  background: var(--accent-soft);
}

.source-tree-folder-row {
  display: flex;
  align-items: center;
}

.source-open-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.source-open-button > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-status-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--soft);
}

.source-status-badge.ingested {
  border-color: rgba(31, 122, 85, 0.35);
  color: #1f7a55;
  background: rgba(31, 122, 85, 0.1);
}

.source-status-badge.failed {
  border-color: rgba(184, 53, 47, 0.35);
  color: #b8352f;
  background: rgba(184, 53, 47, 0.1);
}

.source-status-badge.pending {
  border-color: rgba(144, 96, 80, 0.35);
  color: #906050;
  background: rgba(144, 96, 80, 0.1);
}

#sourceMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.source-reader {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  min-width: 0;
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
}

.source-content {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.actions-grid,
.cost-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.big-action {
  display: grid;
  gap: 6px;
  text-align: left;
  align-content: center;
  min-height: 120px;
}

.big-action span {
  font-weight: 750;
  color: var(--accent);
}

.danger-action span {
  color: var(--danger);
}

.output {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  padding: 14px;
  min-height: 180px;
  overflow: auto;
}

.compact-output {
  min-height: 52px;
  margin: 14px 0;
}

.prewiki-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.url-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.url-input-row input[type="url"] {
  width: 220px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font-size: 0.88rem;
}

.url-input-row select {
  width: 180px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font-size: 0.88rem;
}

.url-input-row input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
}

.prewiki-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 360px);
  align-items: end;
  gap: 10px;
  margin-top: 16px;
}

.prewiki-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.cost-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.workspace-cost-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.provider-metric {
  margin-bottom: 16px;
}

.provider-metric small {
  color: var(--muted);
}

.cost-dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.cost-dashboard-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  min-width: 0;
}

.cost-dashboard-panel h3 {
  margin: 0 0 12px;
}

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

.breakdown-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  padding: 12px;
  min-width: 0;
}

.breakdown-card h4 {
  margin: 0 0 10px;
}

.breakdown-row,
.workspace-cost-row {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.breakdown-row:first-of-type,
.workspace-cost-row:first-child {
  border-top: 0;
}

.breakdown-row span,
.workspace-cost-row strong {
  overflow-wrap: anywhere;
}

.breakdown-row small,
.workspace-cost-row small {
  color: var(--muted);
}

.workspace-cost-rows {
  display: grid;
}

.workspace-cost-row {
  grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
  align-items: start;
}

.workspace-cost-row > div:last-child {
  text-align: right;
}

.notes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-height: 640px;
}

.notes-layout.show-backlinks {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
}

.notes-layout.hide-tree {
  grid-template-columns: minmax(0, 1fr);
}

.notes-layout.hide-tree.show-backlinks {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
}

.notes-side-panel[hidden] {
  display: none;
}

.notes-editor-panel,
.notes-side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.notes-side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
}

.notes-tree,
.note-tree-children {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.note-tree-children {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.note-tree-row {
  position: relative;
  display: grid;
  gap: 3px;
  min-width: 0;
}

.note-tree-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
}

.note-tree-row.is-drop-target,
.notes-tree.is-drop-target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.note-tree-row > .note-tree-children {
  grid-column: 1 / -1;
}

.note-tree-button,
.note-tree-folder-title,
.note-backlink {
  width: 100%;
  min-height: 28px;
  justify-content: start;
  text-align: left;
  height: auto;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.note-tree-button:hover,
.note-tree-folder-title:hover {
  border: 0;
  background: transparent;
}

.note-tree-folder-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-tree-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.12s ease;
}

.note-tree-folder-title.is-expanded .note-tree-chevron {
  transform: rotate(90deg);
}

.note-tree-folder-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.note-tree-folder-title span {
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
}

.note-tree-menu-wrap {
  position: relative;
}

.note-tree-menu-button {
  min-width: 28px;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.note-tree-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 120px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.note-tree-menu button {
  justify-content: start;
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  text-align: left;
}

.note-tree-menu button:hover {
  background: var(--soft);
}

.note-tree-row.is-active,
.note-tree-row.is-expanded {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.note-tree-button.is-active {
  color: inherit;
}

.notes-editor-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-width: 0;
}

.notes-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.notes-editor-head h3 {
  margin: 0;
}

.notes-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.notes-toolbar button {
  min-height: 32px;
  padding: 4px 8px;
}

.note-editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.note-editor {
  width: 100%;
  min-height: 64vh;
  padding: 18px 22px 40px;
  border: 0;
  border-radius: 0;
  resize: none;
  outline: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.96rem;
  line-height: 1.55;
  overflow: auto;
}

.note-preview {
  min-width: 0;
  min-height: 64vh;
  padding: 18px 22px 40px;
  overflow: auto;
  outline: 0;
  background: var(--panel);
  color: var(--ink);
}

.note-preview[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.note-preview:empty::before {
  content: "Type Markdown. Use / for commands.";
  color: var(--muted);
  pointer-events: none;
}

.note-preview mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #ffe778;
  color: #392d00;
}

.note-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.slash-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 4px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.slash-menu button {
  min-height: 30px;
  justify-content: start;
  text-align: left;
}

.note-selection-toolbar {
  position: fixed;
  z-index: 70;
  display: flex;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.note-selection-toolbar button {
  min-height: 30px;
  padding: 3px 8px;
  font-size: 0.76rem;
}

.note-selection-toolbar.is-hidden,
.slash-menu.is-hidden {
  display: none;
}

.notes-backlinks {
  display: grid;
  gap: 10px;
}

.notes-backlinks h3 {
  margin: 0;
}

.notes-backlinks-list {
  display: grid;
  gap: 8px;
}

.note-backlink {
  display: grid;
  gap: 2px;
}

.job-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.job-monitor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.62fr) minmax(0, 1.38fr);
  gap: 16px;
  height: calc(100vh - 170px);
  min-height: 0;
  overflow: hidden;
}

/* Wiki Profiles */
.profiles-list {
  display: grid;
  gap: 10px;
}
.profile-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.profile-card-info { min-width: 0; }
.profile-card-info strong { display: block; margin-bottom: 3px; }
.profile-card-info small { color: var(--muted); font-size: 0.8rem; }
.profile-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.profile-sections-editor { margin: 4px 0; }
.profile-sections-editor h4 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.profile-sections-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.profile-section-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.profile-section-row span { flex: 1; }
.profile-section-add { display: flex; gap: 6px; margin-top: 4px; }
.profile-section-add input { flex: 1; }
.profile-apply-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.profile-apply-label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; flex: 1; max-width: 360px; }
.profile-dialog-card { max-width: 540px; width: 100%; }
.profile-dialog-card textarea { font-family: var(--mono); font-size: 0.82rem; resize: vertical; }
.processed-preview-dialog-card {
  width: min(1280px, calc(100vw - 28px));
  max-height: calc(100vh - 56px);
  overflow: hidden;
}
.processed-preview-content {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}
.processed-preview-output {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.processed-preview-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.processed-preview-output h3 {
  margin: 0;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}
.processed-preview-output pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.label-hint { font-weight: normal; color: var(--muted); font-size: 0.78rem; margin-left: 6px; }

.job-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.compact-metric {
  padding: 10px;
}

.compact-metric strong {
  font-size: 1.1rem;
}

.job-monitor-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 4px;
}

.job-monitor-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  min-height: 58px;
}

.job-monitor-item.is-active {
  border-color: var(--accent);
}

.job-monitor-item span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.job-monitor-item strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.job-monitor-item small,
.job-detail-head small {
  color: var(--muted);
}

.job-tool-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.job-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.job-dot.queued,
.job-dot.running {
  background: var(--accent-2);
  animation: pulse 1s ease-in-out infinite;
}

.job-dot.completed {
  background: #6f8f72;
}

.job-dot.failed {
  background: var(--danger);
}

.job-dot.cancelled {
  background: #8a7a5a;
}

.job-details {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 4px;
}

.job-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.mobile-job-details-close {
  display: none;
}

.job-progress {
  display: grid;
  gap: 8px;
}

.job-progress > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.job-progress small {
  color: var(--muted);
}

.job-progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.job-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.job-log {
  display: grid;
  gap: 10px;
}

.job-log div {
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.job-log time {
  color: var(--muted);
  font-size: 0.78rem;
}

.job-log p {
  margin: 3px 0 0;
}

.job-parts {
  display: grid;
  gap: 8px;
}

.job-parts h4 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.job-tool-calls {
  display: grid;
  gap: 8px;
}

.job-tool-calls h4 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.job-part {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.job-part > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.job-part small {
  color: var(--muted);
}

.job-part.failed {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.job-tool-call {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.job-tool-call.failed {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 5%, var(--panel));
}

.job-tool-call-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.job-tool-call-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.job-tool-summary {
  margin: 0;
  color: var(--ink);
}

.job-result pre {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
}

.job-result h4 {
  margin: 10px 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.job-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
}

.job-row > span {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--muted);
}

.job-row.running > span,
.job-row.queued > span {
  background: var(--accent-2);
  animation: pulse 1s ease-in-out infinite;
}

.job-row.completed > span {
  background: #6f8f72;
}

.job-row.failed > span {
  background: var(--danger);
}

.job-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.job-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.danger-text {
  color: var(--danger) !important;
}

.prewiki-panel,
.staging-row,
.type-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.job-monitor-layout > .prewiki-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.staging-list,
.type-list,
.type-editor {
  display: grid;
  gap: 10px;
}

.staging-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.staging-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 190px;
}

.staging-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.staging-title-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.staging-title-row strong,
.staging-title-row small {
  overflow-wrap: anywhere;
}

.staging-wiki-target,
.prewiki-note-action {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.staging-wiki-target select,
.prewiki-note-output-select {
  width: 100%;
}

.prewiki-note-action small {
  overflow-wrap: anywhere;
}

.prewiki-job-badge {
  max-width: 280px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prewiki-job-badge.running,
.prewiki-job-badge.queued {
  border-color: var(--accent);
  color: var(--accent);
}

.prewiki-job-badge.completed {
  border-color: #6f8f72;
  color: #4a7a4d;
}

.prewiki-job-badge.failed,
.prewiki-job-badge.cancelled {
  border-color: var(--danger-line);
  color: var(--danger);
}

.reprocess-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.verify-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
  color: var(--accent);
  border-color: var(--accent);
}

.verify-result {
  margin-top: 4px;
}

.verify-result-inner {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 0.85rem;
  border: 1px solid;
}

.verify-good {
  background: color-mix(in srgb, #6f8f72 12%, transparent);
  border-color: #6f8f72;
  color: #4a7a4d;
}

.verify-caution {
  background: color-mix(in srgb, #c8a847 12%, transparent);
  border-color: #c8a847;
  color: #7a6010;
}

.verify-warning {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: var(--danger-line);
  color: var(--danger);
}

.verify-result-inner strong {
  font-size: 0.88rem;
}

.verify-result-inner span,
.verify-absent {
  color: inherit;
  opacity: 0.8;
  font-size: 0.8rem;
}

.verify-absent {
  margin: 0;
  font-style: italic;
}

.staging-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.check-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.check-row span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.check-row strong,
.check-row small {
  overflow-wrap: anywhere;
}

.staging-row details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  padding: 10px;
}

.staging-row summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.staging-row pre {
  white-space: pre-wrap;
  max-height: 180px;
  overflow: auto;
  margin: 10px 0;
  color: var(--muted);
}

.staging-row ul,
.type-row p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.type-row {
  display: grid;
  gap: 6px;
}

.type-row small {
  color: var(--accent-2);
  font-weight: 700;
}

.health-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.health-timestamp {
  font-size: 0.8rem;
  color: var(--muted);
}
.health-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.health-metric {
  font-size: 0.8rem;
  padding: 2px 9px;
  border-radius: 12px;
  font-weight: 500;
}
.health-metric.clean {
  background: #1e3a1e;
  color: #7ec87e;
}
.health-metric.issue {
  background: #3a2e10;
  color: #c8a84a;
}
.health-details {
  margin-top: 12px;
  font-size: 0.85rem;
}
.health-details h4 {
  margin: 10px 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.health-details ul {
  margin: 0 0 4px 16px;
  padding: 0;
}
.health-details li {
  margin: 2px 0;
}
.rules-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  margin-bottom: 16px;
}

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

.rule-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  padding: 12px;
}

.rule-group h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.rule-group ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.rule-group pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.45;
  font: inherit;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  display: grid;
  gap: 8px;
}

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

.metric strong {
  font-size: 1.6rem;
}

.chat-log {
  height: calc(100vh - 290px);
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.chat-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 360px) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.context-meter {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-hub-context-progress {
  --context-fill: 0%;
  position: relative;
  width: 100%;
  min-height: 8px;
  height: 8px;
  display: block;
  margin: 0 0 8px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--line);
}

.chat-hub-context-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--context-fill);
  min-width: 2px;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.message {
  max-width: 78%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--soft);
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message *,
.message .markdown,
.message .markdown-body {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message a {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.message pre,
.message code {
  white-space: pre-wrap;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.user {
  justify-self: end;
  background: var(--user-message);
}

.message.is-loading {
  color: var(--muted);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 92px;
  gap: 10px;
  margin-top: 12px;
}

.chat-form button.is-active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.voice-status {
  min-height: 1.2em;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.voice-status[data-mode="error"] {
  color: var(--danger);
}

.voice-status[data-mode="recording"],
.voice-status[data-mode="ready"] {
  color: var(--accent);
}

.chat-log.chat-hub-log {
  height: auto;
  max-height: none;
  min-height: 0;
  align-self: stretch;
  overflow-y: auto;
}

.chat-form.chat-hub-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px 76px;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  align-items: stretch;
  z-index: 1;
}

.chat-form.chat-hub-form textarea {
  height: 44px;
  min-height: 44px;
  max-height: 74px;
  padding: 8px 10px;
  resize: vertical;
}

.chat-form.chat-hub-form button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(460px, calc(100vw - 28px));
  background: var(--panel);
  color: var(--ink);
}

.dialog-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-mode-toggle {
  display: inline-flex;
  gap: 8px;
}

.dialog-mode-toggle .mini-button.is-active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.dialog-mode-panel {
  display: grid;
  gap: 14px;
}

.compact-section-head {
  align-items: start;
}

.dialog-card h2,
.settings-section h3,
.dialog-copy {
  margin: 0;
}

.settings-section {
  display: grid;
  gap: 12px;
}

.toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.toggle-row span {
  display: grid;
  gap: 3px;
}

/* ── Graph view ─────────────────────────────── */

.graph-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.graph-canvas {
  display: block;
  width: 100%;
  height: calc(100vh - 230px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  cursor: grab;
}

.graph-canvas:active {
  cursor: grabbing;
}

/* ── Notifications ──────────────────────────── */

.notification-bar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9000;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.notification {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 11px 15px;
  min-width: 260px;
  max-width: 380px;
  pointer-events: all;
  box-shadow: 0 4px 20px rgb(0 0 0 / 15%);
  display: grid;
  gap: 2px;
  animation: notify-in 0.18s ease;
  cursor: default;
}

.notification.success {
  border-left-color: #6f8f72;
}

.notification.error {
  border-left-color: var(--danger);
}

.notification.info {
  border-left-color: #8a7a5a;
}

.notification strong {
  font-size: 0.88rem;
  line-height: 1.3;
}

.notification small {
  color: var(--muted);
  font-size: 0.76rem;
}

@keyframes notify-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0);    }
}

/* ── Model status: clickable ────────────────── */

.model-status {
  cursor: pointer;
}

.model-status:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.toggle-row small {
  color: var(--muted);
  font-size: 0.78rem;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 45%, var(--panel));
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
  flex: 0 0 auto;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.22);
  transition: transform 0.18s ease;
}

input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 2px;
}

.toggle-row input {
  justify-self: end;
}

.wiki-visibility-list {
  display: flex;
  flex-direction: column;
}

.wiki-visibility-list .toggle-row {
  display: grid;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.wiki-visibility-list .toggle-row:last-child {
  border-bottom: none;
}

.dialog-copy {
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 920px) {
  .approvals-button {
    min-height: 44px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .approvals-popover {
    position: fixed;
    top: calc(58px + env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    width: auto;
    max-height: min(68dvh, 560px);
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: auto;
    max-height: 38dvh;
    overflow-y: auto;
  }

  .workspace {
    height: auto;
    min-height: 0;
  }

  .split,
  .source-split {
    height: auto;
    overflow: visible;
  }

  .page-nav,
  .reader,
  .source-split .file-list,
  .source-reader {
    height: auto;
    overflow: visible;
  }

  .split,
  .source-split,
  .actions-grid,
  .manager-model-panel,
  .manager-model-controls,
  .prewiki-toolbar,
  .prewiki-layout,
  .cost-filter-bar,
  .workspace-cost-grid,
  .cost-dashboard-layout,
  .job-monitor-layout,
  .job-summary,
  .breakdown-grid,
  .rules-list,
  .cost-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .chat-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .chat-log {
    height: 50vh;
  }

  .job-monitor-layout {
    height: auto;
    overflow: visible;
  }

  .job-monitor-layout > .prewiki-panel,
  .job-monitor-list,
  .job-details {
    overflow: visible;
    min-height: auto;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .ai-status-strip,
  .topbar,
  .tabs,
  .views {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-actions,
  .chat-hub-top-controls,
  .chat-form,
  .staging-row,
  .workspace-cost-row,
  .file-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chat-hub-top-controls .chat-hub-menu-shell,
  .chat-hub-top-controls .chat-hub-top-title,
  .chat-hub-top-controls .chat-hub-tabbar {
    grid-column: 1;
  }

  .workspace-cost-row > div:last-child {
    text-align: left;
  }

  .model-control {
    min-width: 0;
  }

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

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

  .app-shell,
  .app-shell.sidebar-collapsed,
  html[data-layout="topbar"] .app-shell,
  html[data-layout="focus"] .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 100dvh;
  }

  .sidebar,
  html[data-layout="topbar"] .sidebar,
  html[data-layout="focus"] .sidebar {
    display: none;
  }

  .workspace,
  html[data-layout="topbar"] .workspace,
  html[data-layout="focus"] .workspace {
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .ai-status-strip {
    position: sticky;
    top: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    background: color-mix(in srgb, var(--panel-alt) 96%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .model-status {
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
    white-space: normal;
  }

  .model-status strong,
  .model-status small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .global-chat-launcher {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
  }

  .global-chat-launcher span {
    display: none;
  }

  .global-chat-launcher::before {
    content: "Chat";
    font-weight: 700;
  }

  .context-help-button {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: 48px;
    min-height: 48px;
  }

  .context-help-panel {
    right: 10px;
    left: 10px;
    bottom: calc(128px + env(safe-area-inset-bottom));
    width: auto;
    height: min(560px, calc(100dvh - 176px));
  }

  .topbar,
  html[data-layout="focus"] .topbar {
    padding: 10px 12px 8px;
  }

  .mobile-wiki-menu-shell {
    display: block;
  }

  .topbar h2,
  .section-head h3 {
    font-size: 1.12rem;
  }

  .topbar p,
  .section-head p {
    display: none;
  }

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

  .tabs,
  html[data-layout="focus"] .tabs {
    display: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
  }

  .views,
  .app-shell.workspace-view-active .views,
  html[data-layout="focus"] .views {
    width: 100%;
    max-width: none;
    padding: 12px 12px 96px;
  }

  .section-head,
  .compact-section-head {
    display: grid;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 12px;
  }

  .split,
  .source-split,
  .actions-grid,
  .prewiki-toolbar,
  .prewiki-layout,
  .cost-filter-bar,
  .workspace-cost-grid,
  .cost-dashboard-layout,
  .job-monitor-layout,
  .schedule-layout,
  .tasks-layout,
  .skill-tuning-grid,
  .settings-grid,
  .profile-grid,
  .layout-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: visible;
    gap: 12px;
  }

  .page-nav:not(.is-collapsed),
  .source-split .file-list {
    max-height: 38dvh;
    overflow: auto;
  }

  .page-nav.is-collapsed {
    max-height: none;
    overflow: hidden;
    padding: 6px;
  }

  .page-nav-toggle {
    min-height: 34px;
    padding: 4px 8px;
  }

  .page-nav.is-collapsed .page-nav-toggle {
    min-height: 30px;
  }

  .page-nav-toggle span {
    font-size: 0.82rem;
  }

  .page-nav-toggle small {
    display: inline;
    max-width: 62vw;
    font-size: 0.74rem;
    line-height: 1.1;
  }

  .reader,
  .source-reader,
  .prewiki-panel,
  .cost-dashboard-panel,
  .schedule-list-panel,
  .schedule-editor-panel,
  .task-reminder-panel,
  .notes-editor-panel,
  .notes-side-panel {
    border-radius: 8px;
  }

  .reader,
  .source-reader {
    padding: 14px;
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .markdown {
    max-width: none;
    overflow-wrap: anywhere;
  }

  .chat-toolbar,
  .chat-form,
  .url-input-row,
  .editor-bottom-actions,
  .profile-apply-row,
  .profile-section-add,
  .workflow-step,
  .prewiki-upload-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .chat-log {
    height: 54dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .chat-hub {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  .chat-hub-sidebar,
  .chat-hub-main,
  .chat-hub-attention {
    border-radius: 7px;
  }

  .chat-hub-sidebar,
  .chat-hub-attention {
    max-height: 18dvh;
    padding: 8px;
  }

  .chat-hub-main {
    min-height: 0;
    padding: 8px;
    overflow: visible;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .chat-hub-head {
    display: grid;
    gap: 6px;
    padding-bottom: 8px;
  }

  .chat-hub-head-compact,
  .chat-hub-head-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    min-width: 0;
  }

  .chat-hub-head-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
  }

  .chat-hub-head-top .chat-hub-tabbar {
    grid-column: 1 / -1;
  }

  .chat-hub-sidebar-head,
  .chat-hub-attention-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-hub-head .eyebrow,
  .chat-hub-sidebar-head .muted,
  .chat-hub-attention > h3 {
    display: none;
  }

  .chat-hub-head h2,
  .chat-hub-sidebar h3 {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .chat-hub-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .chat-hub-actions .mini-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .chat-hub-context-row {
    display: flex;
    margin: 0 0 6px;
    justify-content: stretch;
    gap: 6px;
  }

  .chat-hub-status-pill {
    display: none;
  }

  .chat-hub-context-row .activity-context-chip,
  .chat-hub-context-row .context-meter {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .chat-hub-context-row .activity-context-chip {
    flex: 1 1 auto;
  }

  .chat-hub-controls {
    margin: 0 0 8px;
  }

  .chat-hub-controls label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(92px, 0.45fr);
    align-items: center;
    gap: 6px;
    font-size: 0;
  }

  .chat-hub-controls .control-label-text {
    display: none;
  }

  .chat-hub-controls select {
    min-width: 0;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.8rem;
  }

  .chat-hub-controls .model-pricing {
    display: none;
  }

  .chat-log.chat-hub-log {
    height: clamp(260px, 44dvh, 440px);
    min-height: 260px;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .chat-form.chat-hub-form {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .chat-form.chat-hub-form textarea {
    min-height: 54px;
  }

  .chat-form.chat-hub-form button {
    min-height: 34px;
  }

  .message {
    max-width: 96%;
    width: fit-content;
  }

  .activity-context-chip {
    max-width: none;
    min-height: 30px;
    font-size: 0.76rem;
    padding: 0 8px;
  }

  .notes-layout,
  .notes-layout.show-backlinks,
  .notes-layout.hide-tree,
  .notes-layout.hide-tree.show-backlinks {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .notes-editor-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .editor-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .notes-toolbar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 8px 12px;
    scrollbar-width: none;
  }

  .notes-toolbar::-webkit-scrollbar {
    display: none;
  }

  .notes-toolbar button {
    min-width: 44px;
    min-height: 40px;
    flex: 0 0 auto;
  }

  .note-editor {
    min-height: 58dvh;
    padding: 14px 14px 32px;
  }

  .note-editor {
    border: 0;
  }

  .note-preview {
    min-height: 58dvh;
    padding: 14px 14px 32px;
  }

  .note-tree-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .note-tree-menu-button {
    width: 44px;
    min-width: 44px;
    min-height: 40px;
    display: grid;
    place-items: center;
  }

  .note-tree-menu {
    min-width: 148px;
    z-index: 340;
  }

  .note-tree-menu button {
    min-height: 38px;
    padding: 7px 10px;
  }

  .note-block-h1 .note-block-content {
    font-size: 1.35rem;
  }

  .note-block-h2 .note-block-content {
    font-size: 1.18rem;
  }

  .note-block[data-indent="1"] { margin-left: 16px; }
  .note-block[data-indent="2"] { margin-left: 28px; }
  .note-block[data-indent="3"] { margin-left: 40px; }

  .job-monitor-list,
  .job-details,
  .schedule-list-panel,
  .schedule-editor-panel {
    max-height: none;
    overflow: visible;
  }

  #jobMonitorView {
    position: relative;
  }

  #jobMonitorView .job-monitor-layout > .prewiki-panel:nth-child(2) {
    position: static;
    display: none;
    padding: 12px;
    border: 1px solid var(--line);
    box-shadow: none;
    overflow: visible;
  }

  #jobMonitorView.show-job-details .job-monitor-layout > .prewiki-panel:nth-child(2) {
    display: flex;
  }

  #jobMonitorView .job-monitor-layout > .prewiki-panel:nth-child(2) > h3 {
    display: none;
  }

  #jobMonitorView .job-details {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 4px 10px 0;
  }

  #jobMonitorView .job-detail-head {
    position: sticky;
    top: 0;
    z-index: 1;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    padding: 0 0 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }

  #jobMonitorView .job-detail-head .danger-text,
  #jobMonitorView .job-detail-head #cancelJobButton {
    grid-column: 1 / -1;
  }

  .mobile-job-details-close {
    display: grid;
    place-items: center;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .job-summary,
  .cost-grid,
  .workspace-cost-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-cost-row,
  .staging-row,
  .file-row,
  .profile-card,
  .schedule-row-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .workspace-cost-row > div:last-child {
    text-align: left;
  }

  .processed-preview-dialog-card,
  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 14px 14px 0 0;
  }

  .dialog-card {
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  }

  #focusNavButton,
  html[data-layout="focus"] #focusNavButton,
  html[data-layout="topbar"] #focusNavButton {
    display: flex;
    position: fixed;
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 220;
    width: 56px;
    height: 56px;
    min-height: 56px;
    border-radius: 999px;
    border: 0;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 6px 22px rgb(0 0 0 / 24%);
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    padding: 0;
  }

  #focusNavDrawer {
    width: min(88vw, 360px);
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
  }

  .focus-nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .focus-nav-head strong {
    font-size: 1rem;
  }

  .focus-nav-item {
    min-height: 54px;
  }
}

@media (max-width: 920px) {
  .chat-hub-top-controls {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
  }

  .chat-hub-top-controls .chat-hub-tabbar {
    grid-column: 1 / -1;
    width: 100%;
  }

  .chat-hub-top-controls .chat-hub-status-pill,
  .chat-hub-top-controls .activity-context-chip {
    display: none;
  }

  .chat-hub {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  .chat-hub-tabs {
    width: 100%;
    max-width: none;
  }

  .chat-hub-tab {
    min-width: 0;
    min-height: 32px;
    padding: 0 8px;
    border-radius: 5px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .chat-hub-tab.is-active {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--accent);
  }

  .chat-hub[data-mobile-tab="chat"] [data-chat-hub-panel]:not([data-chat-hub-panel="chat"]),
  .chat-hub[data-mobile-tab="conversations"] [data-chat-hub-panel]:not([data-chat-hub-panel="conversations"]),
  .chat-hub[data-mobile-tab="notifications"] [data-chat-hub-panel]:not([data-chat-hub-panel="notifications"]) {
    display: none;
  }

  .chat-hub-sidebar,
  .chat-hub-main,
  .chat-hub-attention {
    min-height: 0;
    max-height: none;
    border-radius: 7px;
  }

  .chat-hub-sidebar {
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 10px;
    overflow: hidden;
  }

  .chat-hub-attention {
    grid-template-rows: auto minmax(0, 1fr);
    padding: 10px;
    overflow: hidden;
  }

  .chat-hub-main {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    padding: 10px;
    overflow: hidden;
  }

  .chat-thread-list,
  .chat-hub-attention .approvals-list,
  .chat-log.chat-hub-log {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .chat-thread-list {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .chat-hub-attention .approvals-list {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .chat-log.chat-hub-log {
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 10px;
  }

  .chat-hub-head {
    display: grid;
    gap: 6px;
    padding-bottom: 8px;
  }

  .chat-hub-head-compact,
  .chat-hub-head-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    min-width: 0;
  }

  .chat-hub-head-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
  }

  .chat-hub-head-top .chat-hub-tabbar {
    grid-column: 1 / -1;
  }

  .chat-hub-sidebar-head,
  .chat-hub-attention-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-hub-head-right {
    display: none;
  }

  .chat-hub-status-pill {
    display: none;
  }

  .chat-hub-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .chat-hub-actions .mini-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .chat-hub-context-row {
    display: flex;
    margin: 8px 0;
    justify-content: stretch;
    gap: 6px;
  }

  .chat-hub-context-row .activity-context-chip,
  .chat-hub-context-row .context-meter {
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .chat-hub-context-row .activity-context-chip {
    flex: 1 1 auto;
  }

  .chat-hub-controls {
    margin: 0 0 8px;
  }

  .chat-hub-controls label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(92px, 0.45fr);
    align-items: center;
    gap: 6px;
    font-size: 0;
  }

  .chat-hub-controls .control-label-text {
    display: none;
  }

  .chat-hub-controls select {
    min-width: 0;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.8rem;
  }

  .chat-hub-controls .model-pricing {
    display: none;
  }

  .chat-form.chat-hub-form {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .chat-form.chat-hub-form textarea {
    grid-column: 1 / -1;
    min-height: 54px;
  }

  .chat-form.chat-hub-form button {
    min-height: 34px;
  }

  .chat-form.chat-hub-form #chatHubVoiceButton {
    grid-column: 1;
  }

  .chat-form.chat-hub-form #chatHubSendButton {
    grid-column: 2;
  }
}


/* ═══════════════════════════════════════════════════════════
   LAYOUT SYSTEM
   Three user-selectable layouts: classic (default), topbar, focus.
   Applied via html[data-layout="..."] attribute.
   ═══════════════════════════════════════════════════════════ */


/* ── Focus nav button & drawer (base state — hidden by default) ── */

#focusNavButton {
  display: none;
}

.focus-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgb(0 0 0 / 32%);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.focus-nav-backdrop.is-open {
  opacity: 1;
}

#focusNavDrawer {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 300;
  transform: translateX(-110%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  padding: 1rem;
  box-shadow: 4px 0 32px rgb(0 0 0 / 12%);
  touch-action: pan-y;
}

#focusNavDrawer.is-open {
  transform: translateX(0);
}

#focusNavDrawer.is-swiping {
  transition: none;
}

.focus-nav-head {
  display: none;
}

.focus-nav-inner .sidebar {
  border: none;
  background: transparent;
  padding: 0;
  display: grid;
  gap: 14px;
}

.focus-nav-inner .sidebar-toggle {
  display: none;
}

.focus-nav-menu {
  display: grid;
  gap: 18px;
}

.focus-nav-section {
  display: grid;
  gap: 8px;
}

.focus-nav-section.is-collapsed > :not(h3) {
  display: none;
}

.focus-nav-section h3 {
  margin: 0;
}

.focus-nav-section-toggle {
  width: 100%;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

.focus-nav-section-toggle:hover {
  border: 0;
  color: var(--accent);
}

.focus-nav-section-toggle::before {
  content: "▾";
  display: inline-block;
  width: 16px;
  margin-right: 4px;
  color: var(--muted);
}

.focus-nav-section-toggle[aria-expanded="false"]::before {
  transform: rotate(-90deg);
}

.focus-nav-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 50px;
  text-align: left;
  align-content: center;
}

.focus-nav-item span {
  font-weight: 750;
  color: var(--accent);
}

.focus-nav-item small {
  color: var(--muted);
}

.focus-nav-item.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.focus-notes-tree {
  display: grid;
  gap: 5px;
  padding: 4px 0 0;
}

.focus-task-tree,
.focus-task-folder {
  display: grid;
  gap: 5px;
  padding: 4px 0 0;
}

.focus-task-folder {
  padding: 0;
}

.focus-task-folder-button {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  text-align: left;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.focus-task-folder-button.is-expanded {
  color: var(--text);
}

.focus-task-folder-button.is-active,
.focus-task-list-button.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.focus-task-list-button {
  display: grid;
  gap: 3px;
  width: calc(100% - 24px);
  min-height: 46px;
  margin-left: 24px;
  padding: 7px 10px;
  text-align: left;
  align-content: center;
}

.focus-task-list-button span {
  font-weight: 750;
  color: var(--accent);
}

.focus-task-list-button small,
.focus-task-empty {
  color: var(--muted);
}

.focus-task-empty {
  margin: 0 0 3px 32px;
  font-size: 0.82rem;
}

.focus-note-tree-row {
  display: grid;
  gap: 4px;
}

.focus-note-tree-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
}

.focus-note-tree-button {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 42px;
  padding: 6px 8px 6px calc(8px + (var(--depth, 0) * 14px));
  text-align: left;
  border-radius: 8px;
}

.focus-note-tree-row.is-note .focus-note-tree-button {
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.focus-note-tree-button span,
.focus-note-tree-button small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-note-tree-button small {
  color: var(--muted);
  font-size: 0.76rem;
}

.focus-note-tree-button.is-active,
.focus-note-tree-button.is-expanded {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.focus-note-tree-button .note-tree-chevron {
  width: 13px;
  height: 13px;
}

.focus-note-tree-button.is-expanded .note-tree-chevron {
  transform: rotate(90deg);
}

.focus-note-tree-button .note-tree-folder-icon {
  width: 15px;
  height: 15px;
}

.focus-note-tree-head .note-tree-menu-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
}

.focus-note-tree-head .note-tree-menu {
  z-index: 340;
}


/* ── Layout picker (Account section) ── */

.layout-picker {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.layout-option {
  display: grid;
  gap: 0;
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--panel-alt);
  padding: 10px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  min-width: 140px;
  flex: 1;
  max-width: 200px;
  color: var(--ink);
}

.layout-option:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.layout-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.layout-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.layout-preview {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 9px;
  display: flex;
  position: relative;
}

/* Classic preview thumbnail */
.layout-preview-classic {
  flex-direction: row;
}

.layout-preview-classic .lp-sidebar {
  width: 28%;
  background: var(--panel-alt);
  border-right: 1px solid var(--line);
  height: 100%;
  flex-shrink: 0;
}

.layout-preview-classic .lp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.layout-preview-classic .lp-tabs {
  height: 18%;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.layout-preview-classic .lp-content {
  flex: 1;
  background: var(--bg);
  padding: 5px;
  display: grid;
  gap: 3px;
  align-content: start;
}

.layout-preview-classic .lp-content::before,
.layout-preview-classic .lp-content::after {
  content: "";
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}

.layout-preview-classic .lp-content::after {
  width: 65%;
}

/* Topbar preview thumbnail */
.layout-preview-topbar {
  flex-direction: column;
}

.layout-preview-topbar .lp-topnav {
  height: 22%;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 4px;
}

.layout-preview-topbar .lp-topnav::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
}

.layout-preview-topbar .lp-topnav::after {
  content: "";
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.layout-preview-topbar .lp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 5px;
  gap: 4px;
}

.layout-preview-topbar .lp-content-full {
  flex: 1;
  background: var(--panel);
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* Focus preview thumbnail */
.layout-preview-focus {
  flex-direction: column;
  position: relative;
}

.layout-preview-focus .lp-main-centered {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
}

.layout-preview-focus .lp-content-centered {
  width: 68%;
  height: 65%;
  background: var(--panel);
  border-radius: 4px;
  border: 1px solid var(--line);
}

.layout-preview-focus .lp-fab {
  position: absolute;
  bottom: 7px;
  left: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.layout-option > span {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
}

.layout-option > small {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}


/* ═══════════════════════════════════════════════════════════
   TOPBAR LAYOUT
   Sidebar becomes a horizontal strip at the top.
   ═══════════════════════════════════════════════════════════ */

html[data-layout="topbar"] .app-shell {
  display: flex;
  flex-direction: column;
  transition: none;
}

html[data-layout="topbar"] .app-shell.sidebar-collapsed {
  /* Collapsed state irrelevant in topbar — override grid shorthand */
  grid-template-columns: unset;
}

html[data-layout="topbar"] .sidebar {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: auto;
  min-height: 0;
  border-right: none;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
  flex-wrap: nowrap;
  position: static;
  background: var(--panel-alt);
}

html[data-layout="topbar"] .sidebar::-webkit-scrollbar {
  height: 3px;
}

html[data-layout="topbar"] .sidebar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

html[data-layout="topbar"] .brand {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  flex-shrink: 0;
  margin-right: 12px;
}

html[data-layout="topbar"] .brand-copy {
  display: none;
}

html[data-layout="topbar"] .sidebar-toggle,
html[data-layout="topbar"] #sidebarToggleButton {
  display: none;
}

html[data-layout="topbar"] .panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 6px 0;
  gap: 3px;
  border-radius: 0;
}

html[data-layout="topbar"] .panel + .panel {
  border-left: 1px solid var(--line);
  margin-left: 6px;
  padding-left: 10px;
}

html[data-layout="topbar"] .panel-head {
  display: none;
}

html[data-layout="topbar"] #adminPanel {
  display: flex;
  border-left: 1px solid var(--line);
  margin-left: 6px;
  padding-left: 10px;
}

html[data-layout="topbar"] .wiki-list {
  flex-direction: row;
  gap: 4px;
  flex-wrap: nowrap;
}

html[data-layout="topbar"] .wiki-list > * {
  flex-shrink: 0;
}

/* Wiki items become horizontal pills */
html[data-layout="topbar"] .wiki-item {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 2px 2px 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  min-height: 34px;
  grid-template-columns: unset;
  width: auto;
}

html[data-layout="topbar"] .wiki-open-button {
  display: inline-flex;
  min-height: 28px;
  gap: 6px;
  align-items: center;
  padding: 2px 4px;
}

html[data-layout="topbar"] .wiki-open-button small {
  display: none;
}

html[data-layout="topbar"] .wiki-menu-popover {
  top: 38px;
}

/* Workspace actions become compact pills */
html[data-layout="topbar"] .sidebar-action {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  width: auto;
  white-space: nowrap;
  font-size: 0.8rem;
}

html[data-layout="topbar"] .sidebar-action span {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink);
}

html[data-layout="topbar"] .sidebar-action small {
  display: none;
}

html[data-layout="topbar"] .sidebar-action.is-active {
  background: var(--soft);
  border-color: var(--accent);
}

html[data-layout="topbar"] .sidebar-action.is-active span {
  color: var(--accent);
}

html[data-layout="topbar"] .notes-sidebar-tree-panel {
  display: none;
}

/* Workspace fills the remaining space */
html[data-layout="topbar"] .workspace {
  flex: 1;
  height: auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

html[data-layout="topbar"] #focusNavButton {
  display: none;
}

/* Sidebar collapsed class is meaningless in topbar mode — undo its hiding */
html[data-layout="topbar"] .app-shell.sidebar-collapsed .brand-copy {
  display: none;
}

html[data-layout="topbar"] .app-shell.sidebar-collapsed .panel {
  display: flex;
}


/* ═══════════════════════════════════════════════════════════
   FOCUS LAYOUT
   Sidebar hidden. Content centered. Floating nav FAB.
   ═══════════════════════════════════════════════════════════ */

html[data-layout="focus"] .app-shell {
  grid-template-columns: 1fr;
  transition: none;
}

html[data-layout="focus"] .app-shell.sidebar-collapsed {
  grid-template-columns: 1fr;
}

html[data-layout="focus"] .sidebar {
  display: none;
}

html[data-layout="focus"] .workspace {
  padding-left: 0;
  max-width: 100%;
  min-width: 0;
}

/* Slim, retreating status strip */
html[data-layout="focus"] .ai-status-strip {
  opacity: 0.55;
  transition: opacity 0.2s ease;
  padding: 8px 24px;
}

html[data-layout="focus"] .ai-status-strip:hover {
  opacity: 1;
}

/* Centered topbar */
html[data-layout="focus"] .topbar {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 2rem 0;
  border-bottom: none;
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

/* Centered tabs */
html[data-layout="focus"] .tabs {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--line);
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

/* Centered views */
html[data-layout="focus"] .views {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
  width: 100%;
  box-sizing: border-box;
}

/* Browse view: single-column reader, larger text */
html[data-layout="focus"] #browseView .split {
  grid-template-columns: 1fr;
  height: auto;
  overflow: visible;
}

html[data-layout="focus"] #browseView .page-nav {
  display: none;
}

html[data-layout="focus"] #browseView .reader {
  height: auto;
  min-height: 60vh;
  overflow: visible;
  font-size: 1.05rem;
  line-height: 1.8;
}

html[data-layout="focus"] .markdown {
  max-width: 720px;
}

/* Floating nav button */
html[data-layout="focus"] #focusNavButton {
  display: flex;
  position: fixed;
  bottom: 1.75rem;
  left: 1.75rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 3px 14px rgb(0 0 0 / 22%);
  z-index: 200;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
  min-height: unset;
}

html[data-layout="focus"] #focusNavButton:hover {
  background: var(--accent-hover);
  transform: scale(1.06);
  box-shadow: 0 5px 20px rgb(0 0 0 / 28%);
}

/* ---- Scheduled Tasks ---- */
.schedule-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.55fr) minmax(0, 1.45fr);
  gap: 16px;
  height: calc(100vh - 170px);
  min-height: 0;
  overflow: hidden;
}

.schedule-list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel-alt);
  transition: border-color 0.12s, background 0.12s;
}

.schedule-row:hover {
  border-color: var(--accent);
}

.schedule-row.is-active {
  border-color: var(--accent);
  background: var(--soft);
}

.schedule-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-row-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.schedule-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.toggle-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-ai-prompt {
  background: var(--soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.badge-workflow {
  background: #f5ede2;
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
}

.schedule-editor-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.schedule-editor-panel fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.schedule-editor-panel fieldset legend {
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0 6px;
  color: var(--muted);
}

.schedule-conditional {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.editor-bottom-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.schedule-job-info {
  font-size: 0.85rem;
}

.workflow-step-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-step select {
  flex: 1;
}

.mini-button {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.mini-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger-text {
  color: var(--danger);
}

.danger-text:hover {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 920px) {
  .schedule-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .schedule-editor-panel {
    height: auto;
  }
}

@media (max-width: 760px) {
  html[data-layout="topbar"] .app-shell,
  html[data-layout="focus"] .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  html[data-layout="topbar"] .sidebar,
  html[data-layout="focus"] .sidebar {
    display: none;
  }

  html[data-layout="topbar"] .workspace,
  html[data-layout="focus"] .workspace {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  html[data-layout="topbar"] .ai-status-strip,
  html[data-layout="focus"] .ai-status-strip {
    opacity: 1;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  }

  html[data-layout="focus"] .topbar,
  html[data-layout="focus"] .tabs,
  html[data-layout="focus"] .views {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  html[data-layout="focus"] .views {
    padding: 12px 12px 96px;
  }

  html[data-layout="focus"] #browseView .page-nav {
    display: block;
  }

  html[data-layout="focus"] #browseView .reader {
    min-height: 0;
    font-size: 1rem;
    line-height: 1.65;
  }

  html[data-layout="topbar"] #focusNavButton,
  html[data-layout="focus"] #focusNavButton,
  #focusNavButton {
    display: flex;
    position: fixed;
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 220;
    width: 56px;
    height: 56px;
    min-height: 56px;
    border-radius: 999px;
  }
}
