/* Finn — Outlook-styled workspace (Fluent 2 design language) with a VS Code-like IDE. */

/* ============================================================ tokens */
:root {
  --brand: #0f6cbd;
  --brand-hover: #115ea3;
  --brand-pressed: #0c3b5e;
  --brand-fg: #0f6cbd;
  --brand-subtle: #ebf3fc;
  --brand-subtle-2: #cfe4fa;
  --brand-stroke: #b4d6fa;
  --header-bg: #0f6cbd;
  --header-fg: #ffffff;
  --header-search: rgba(255, 255, 255, .92);

  --canvas: #f0f0f0;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f5f5f5;
  --surface-hover: #f5f5f5;
  --surface-pressed: #e0e0e0;
  --stroke: #e0e0e0;
  --stroke-2: #ebebeb;
  --stroke-strong: #d1d1d1;
  --text: #242424;
  --text-2: #424242;
  --text-3: #616161;
  --text-4: #707070;

  --danger: #c50f1f;
  --danger-bg: #fdf3f4;
  --success: #107c10;
  --success-bg: #f1faf1;
  --warning: #bc4b09;
  --warning-bg: #fff9f5;

  --word: #185abd;
  --excel: #107c41;
  --ppt: #c43e1c;
  --pdf: #c50f1f;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --shadow-2: 0 0 2px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .14);
  --shadow-4: 0 0 2px rgba(0, 0, 0, .12), 0 2px 4px rgba(0, 0, 0, .14);
  --shadow-8: 0 0 2px rgba(0, 0, 0, .12), 0 4px 8px rgba(0, 0, 0, .14);
  --shadow-16: 0 0 2px rgba(0, 0, 0, .12), 0 8px 16px rgba(0, 0, 0, .14);
  --shadow-28: 0 0 8px rgba(0, 0, 0, .12), 0 14px 28px rgba(0, 0, 0, .14);

  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --topbar-h: 48px;
  --statusbar-h: 24px;
  --activity-w: 48px;
  --sidebar-w: 260px;
  --agent-w: 380px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2886de;
    --brand-hover: #3a96e8;
    --brand-pressed: #1f6fb6;
    --brand-fg: #62abf5;
    --brand-subtle: #0e2a46;
    --brand-subtle-2: #123a62;
    --brand-stroke: #1f5b94;
    --header-bg: #0f3d68;
    --header-search: rgba(255, 255, 255, .12);
    --canvas: #141414;
    --surface: #1f1f1f;
    --surface-2: #242424;
    --surface-3: #292929;
    --surface-hover: #2b2b2b;
    --surface-pressed: #333333;
    --stroke: #333333;
    --stroke-2: #2b2b2b;
    --stroke-strong: #474747;
    --text: #f5f5f5;
    --text-2: #e0e0e0;
    --text-3: #adadad;
    --text-4: #8f8f8f;
    --danger: #f1707b;
    --danger-bg: #3b1215;
    --success: #6ccb5f;
    --success-bg: #12301a;
    --warning: #fab97f;
    --warning-bg: #3a2210;
    --word: #6aa7f8;
    --excel: #4ec27f;
    --ppt: #f0845f;
    --pdf: #f1707b;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #2886de;
  --brand-hover: #3a96e8;
  --brand-pressed: #1f6fb6;
  --brand-fg: #62abf5;
  --brand-subtle: #0e2a46;
  --brand-subtle-2: #123a62;
  --brand-stroke: #1f5b94;
  --header-bg: #0f3d68;
  --header-search: rgba(255, 255, 255, .12);
  --canvas: #141414;
  --surface: #1f1f1f;
  --surface-2: #242424;
  --surface-3: #292929;
  --surface-hover: #2b2b2b;
  --surface-pressed: #333333;
  --stroke: #333333;
  --stroke-2: #2b2b2b;
  --stroke-strong: #474747;
  --text: #f5f5f5;
  --text-2: #e0e0e0;
  --text-3: #adadad;
  --text-4: #8f8f8f;
  --danger: #f1707b;
  --danger-bg: #3b1215;
  --success: #6ccb5f;
  --success-bg: #12301a;
  --warning: #fab97f;
  --warning-bg: #3a2210;
  --word: #6aa7f8;
  --excel: #4ec27f;
  --ppt: #f0845f;
  --pdf: #f1707b;
  color-scheme: dark;
}

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 14px/20px var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--brand-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; color: var(--text); }
h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
h2 { font-size: 16px; line-height: 22px; font-weight: 600; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
p { margin: 0 0 8px; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  background: var(--surface);
  border: 1px solid var(--stroke-strong);
  border-bottom-color: var(--text-4);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-bottom: 2px solid var(--brand); padding-bottom: 4px; }
::selection { background: var(--brand-subtle-2); }
.muted { color: var(--text-3); }
.small { font-size: 12px; line-height: 16px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.pad { padding: 8px 12px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.error-text { color: var(--danger); }
.link { font-weight: 600; }

.tint-word { color: var(--word); }
.tint-excel { color: var(--excel); }
.tint-ppt { color: var(--ppt); }
.tint-pdf { color: var(--pdf); }
.tint-image { color: #8764b8; }
.tint-folder { color: #c19c00; }

/* scrollbars (thin, Fluent-like) */
* { scrollbar-width: thin; scrollbar-color: var(--stroke-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--stroke-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .1s, border-color .1s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--stroke-strong); text-decoration: none; }
.btn:active { background: var(--surface-pressed); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { background: var(--brand-pressed); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-on-brand { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .4); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn-xs { min-height: 24px; padding: 0 8px; font-size: 12px; }
.btn-lg { min-height: 40px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn-stop { border-color: var(--danger); color: var(--danger); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--brand-fg); text-decoration: none; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.xs { width: 22px; height: 22px; }
.icon-btn.danger:hover { color: var(--danger); }
.only-sm { display: none; }

.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--brand-subtle-2); border-top-color: var(--brand);
  animation: spin .8s linear infinite; display: inline-block;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.spinner.xs { width: 12px; height: 12px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { height: 100%; display: grid; place-items: center; }

/* ============================================================ app shell + top bar (Outlook header) */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.app-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 0 4px;
  background: var(--header-bg); color: var(--header-fg);
}
.topbar-left { display: flex; align-items: center; gap: 4px; min-width: 200px; }
.waffle { width: 40px; height: 40px; display: grid; place-items: center; color: #fff; border-radius: var(--radius-sm); }
.waffle:hover { background: rgba(255, 255, 255, .12); }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font: 600 16px var(--font-display); }
.brand:hover { text-decoration: none; }
.topbar-search {
  flex: 1; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  background: var(--header-search); border-radius: var(--radius);
  color: var(--text-3);
}
:root[data-theme="dark"] .topbar-search, .topbar-search:focus-within { color: var(--text-2); }
.topbar-search input { flex: 1; border: 0; background: transparent; padding: 0; height: 30px; color: var(--text); }
:root[data-theme="dark"] .topbar-search input { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar-search input { color: #fff; } }
.topbar-search input:focus { border: 0; padding: 0; }
.topbar-right { display: flex; align-items: center; gap: 4px; min-width: 200px; justify-content: flex-end; }
.topbar-btn { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; border-radius: var(--radius-sm); }
.topbar-btn:hover { background: rgba(255, 255, 255, .12); }
.topbar-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 14px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 12px; font-weight: 600;
}
.topbar-pill:hover { background: rgba(255, 255, 255, .22); text-decoration: none; }
.topbar-pill.paid { background: linear-gradient(90deg, rgba(255, 214, 102, .3), rgba(255, 255, 255, .14)); }
.me { position: relative; margin-left: 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5);
  background: #e8ebfa; color: #3d3d9b; font-weight: 600; font-size: 12px;
  display: grid; place-items: center; cursor: pointer; padding: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; border: 0; cursor: default; }
.flyout-backdrop { position: fixed; inset: 0; z-index: 40; }
.flyout {
  position: absolute; right: 0; top: 40px; z-index: 41; min-width: 300px;
  background: var(--surface); color: var(--text); border-radius: var(--radius-lg); box-shadow: var(--shadow-28);
  padding: 8px; animation: pop .12s ease-out;
}
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } }
.me-head { display: flex; gap: 12px; padding: 8px 8px 12px; border-bottom: 1px solid var(--stroke); margin-bottom: 4px; }
.me-name { font-weight: 600; }
.me-mail, .me-plan { color: var(--text-3); font-size: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--surface-hover); text-decoration: none; }

/* Finn Desktop (Electron): the header is the title bar; leave room for window controls. */
.shell-desktop .topbar { -webkit-app-region: drag; padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 12px); }
.shell-desktop .topbar a, .shell-desktop .topbar button, .shell-desktop .topbar input, .shell-desktop .topbar form { -webkit-app-region: no-drag; }
.platform-darwin.shell-desktop .topbar { padding-left: 84px; }
.shell-mobile .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }

/* ============================================================ Home: Outlook mail layout */
.mail-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 360px 1fr; gap: 0; }
.folder-pane {
  background: var(--canvas); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto;
}
.btn-new { width: 100%; min-height: 36px; margin-bottom: 12px; justify-content: flex-start; padding: 0 14px; border-radius: var(--radius); }
.folder-title { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 12px 10px 4px; }
.folder {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border: 0; background: none; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; text-align: left;
}
.folder:hover { background: var(--surface-hover); text-decoration: none; }
.folder.active { background: var(--brand-subtle); font-weight: 600; position: relative; }
.folder.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--brand); }
.folder .count { margin-left: auto; color: var(--brand-fg); font-weight: 600; font-size: 12px; }
.folder-foot { margin-top: auto; padding-top: 12px; }

.list-pane {
  background: var(--surface); display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--stroke); border-right: 1px solid var(--stroke);
}
.list-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; }
.list-head h1 { font-size: 18px; flex: 1; }
.list-filter { padding: 0 16px 8px; color: var(--text-3); font-size: 12px; }
.list { flex: 1; overflow: auto; }
.list-group { padding: 10px 16px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.item {
  display: flex; gap: 12px; padding: 10px 12px 10px 16px; cursor: pointer;
  border-left: 3px solid transparent; border-bottom: 1px solid var(--stroke-2);
  outline: none;
}
.item:hover { background: var(--surface-hover); }
.item:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.item.selected { background: var(--brand-subtle); border-left-color: var(--brand); }
.item.attention .item-title { color: var(--warning); }
.item-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--brand-subtle-2); color: var(--brand-fg);
}
.item-body { flex: 1; min-width: 0; }
.item-row { display: flex; gap: 8px; align-items: baseline; }
.item-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--text-3); flex: none; }
.item.selected .item-time { color: var(--brand-fg); }
.item-preview { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
  border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2);
}
.tag.tier-low { background: #f1faf1; color: #0e700e; }
.tag.tier-medium { background: var(--brand-subtle); color: var(--brand-fg); }
.tag.tier-high { background: #f7f0fc; color: #7a3db8; }
:root[data-theme="dark"] .tag.tier-low { background: #12301a; color: #6ccb5f; }
:root[data-theme="dark"] .tag.tier-high { background: #2e1a40; color: #c3a6ff; }
.tag.working { background: var(--brand-subtle); color: var(--brand-fg); }
.tag.attention { background: var(--warning-bg); color: var(--warning); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.list-empty { display: grid; place-items: center; gap: 8px; padding: 48px 16px; color: var(--text-3); text-align: center; }

.reading-pane { background: var(--surface); margin: 8px 8px 8px 8px; border-radius: var(--radius-lg); box-shadow: var(--shadow-2); overflow: auto; min-width: 0; }
.read-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px 6px; }
.read-head h2 { flex: 1; font-size: 20px; line-height: 28px; }
.read-actions { display: flex; gap: 4px; align-items: center; }
.read-meta { padding: 0 24px 12px; color: var(--text-3); font-size: 12px; border-bottom: 1px solid var(--stroke); }
.read-body { padding: 16px 24px 32px; display: flex; flex-direction: column; gap: 14px; }
.preview-msg { padding: 12px 16px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--stroke-2); }
.preview-msg.user { background: var(--brand-subtle); border-color: transparent; }
.preview-who { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.callout { display: flex; align-items: center; gap: 10px; margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--radius); }
.callout.danger { background: var(--danger-bg); color: var(--danger); }
.callout span { flex: 1; }

.start { max-width: 680px; margin: 0 auto; padding: 8vh 24px 32px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.start h2 { font-size: 24px; line-height: 32px; }
.start-logo { filter: drop-shadow(0 6px 14px rgba(15, 108, 189, .3)); }
.start-composer {
  width: 100%; margin-top: 12px; text-align: left;
  border: 1px solid var(--stroke); border-radius: var(--radius-xl); background: var(--surface);
  box-shadow: var(--shadow-8); padding: 12px;
}
.start-composer textarea { width: 100%; border: 0; resize: none; padding: 4px; background: transparent; font-size: 15px; line-height: 22px; }
.start-composer textarea:focus { border: 0; padding: 4px; }
.start-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }

/* ============================================================ plan + engine cards */
.plan-card { border-radius: var(--radius-lg); padding: 12px; background: var(--surface); border: 1px solid var(--stroke); display: flex; flex-direction: column; gap: 6px; }
.plan-card.compact { font-size: 12px; line-height: 16px; }
.plan-card.paid { background: linear-gradient(135deg, var(--brand-subtle), var(--surface)); border-color: var(--brand-stroke); }
.plan-head { display: flex; align-items: center; gap: 6px; color: var(--brand-fg); }
.plan-text { color: var(--text-2); }
.plan-link { font-weight: 600; font-size: 12px; }
.plan-usage { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-3); }
.bar { height: 4px; border-radius: 2px; background: var(--surface-pressed); overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); border-radius: 2px; transition: width .2s; }

.engine-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--stroke);
}
.engine-card.ok { background: var(--success-bg); border-color: transparent; }
.engine-card.warn { background: var(--warning-bg); border-color: transparent; }
.engine-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--brand-fg); flex: none; }
.engine-card.warn .engine-icon { color: var(--warning); }
.engine-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); min-width: 0; }
.engine-text b { color: var(--text); }
.start .engine-card { margin-top: 12px; }

/* ============================================================ tier picker */
.tier-picker { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--surface-3); border: 1px solid var(--stroke); }
.tier {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 12px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.tier:hover:not(:disabled) { color: var(--brand-fg); }
.tier.on { background: var(--surface); color: var(--brand-fg); box-shadow: var(--shadow-2); }
.tier:disabled { cursor: default; opacity: .6; }
.tier-picker.compact .tier { height: 24px; padding: 0 8px; font-size: 12px; }

/* ============================================================ IDE (workspace) */
.ws {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--activity-w) var(--sidebar-w) minmax(0, 1fr) var(--agent-w);
  background: var(--surface);
}
.ws.no-side { grid-template-columns: var(--activity-w) 0 minmax(0, 1fr) var(--agent-w); }
.ws:has(.agent-panel.collapsed) { grid-template-columns: var(--activity-w) var(--sidebar-w) minmax(0, 1fr) 0; }
.ws.no-side:has(.agent-panel.collapsed) { grid-template-columns: var(--activity-w) 0 minmax(0, 1fr) 0; }

.activitybar { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; background: var(--canvas); border-right: 1px solid var(--stroke); }
.ab-btn {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-3); cursor: pointer;
}
.ab-btn:hover { color: var(--text); background: var(--surface-hover); text-decoration: none; }
.ab-btn.on { color: var(--brand-fg); background: var(--surface); box-shadow: var(--shadow-2); }
.ab-btn.on::before { content: ""; position: absolute; left: -4px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--brand); }

.sidebar { display: flex; flex-direction: column; min-width: 0; background: var(--surface-2); border-right: 1px solid var(--stroke); overflow: hidden; }
.sidebar.collapsed { border: 0; }
.side-title { padding: 10px 10px 4px; }
.ws-title { width: 100%; font-weight: 600; font-size: 14px; border-color: transparent; background: transparent; }
.ws-title:hover { border-color: var(--stroke); }
.side-content { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.pane-head { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 6px 0 14px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); }
.pane-tools { display: flex; gap: 0; }
.pane-error { margin: 8px; padding: 8px 10px; border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); font-size: 12px; cursor: pointer; }
.pane-error.ok { background: var(--success-bg); color: var(--success); }

.tree { flex: 1; min-height: 80px; padding-bottom: 24px; outline: none; }
.tree.drop-over { background: var(--brand-subtle); box-shadow: inset 0 0 0 2px var(--brand); }
.tree-row {
  display: flex; align-items: center; gap: 4px; height: 26px; padding-right: 6px;
  cursor: pointer; user-select: none; white-space: nowrap; color: var(--text-2); font-size: 13px;
}
.tree-row:hover { background: var(--surface-hover); }
.tree-row.selected { background: var(--brand-subtle); }
.tree-row.active .tree-name { color: var(--brand-fg); font-weight: 600; }
.tree-row .chev { color: var(--text-4); }
.chev-space { width: 12px; flex: none; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; margin-left: 2px; }
.tree-actions { display: none; gap: 0; }
.tree-row:hover .tree-actions { display: inline-flex; }
.tree-input { flex: 1; min-width: 0; height: 22px; padding: 0 6px; font-size: 13px; }
.tree-confirm { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 6px; color: var(--danger); background: var(--danger-bg); }
.tree-empty { padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; color: var(--text-3); }

.editor-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.tabs { display: flex; align-items: stretch; height: 36px; flex: none; background: var(--surface-2); border-bottom: 1px solid var(--stroke); overflow-x: auto; overflow-y: hidden; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 6px 0 12px; max-width: 220px;
  border-right: 1px solid var(--stroke-2); cursor: pointer; color: var(--text-3); font-size: 13px; position: relative; flex: none;
}
.tab:hover { background: var(--surface-hover); }
.tab.active { background: var(--surface); color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--brand); }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-close { width: 20px; height: 20px; border: 0; border-radius: var(--radius-sm); background: none; color: inherit; display: grid; place-items: center; cursor: pointer; opacity: 0; }
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--surface-pressed); }
.tab .dirty-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.tab.dirty .tab-close { opacity: 1; }
.tab.dirty .tab-close .icon { display: none; }
.tab.dirty .dirty-dot { display: block; }
.tab.dirty .tab-close:hover .icon { display: inline-block; }
.tab.dirty .tab-close:hover .dirty-dot { display: none; }
.tabs-fill { flex: 1; }
.tabs > .icon-btn { align-self: center; margin-right: 6px; flex: none; }

.editor-stack { flex: 1; min-height: 0; position: relative; }
.monaco-host, .frame-host { position: absolute; inset: 0; }
.frame-host iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--surface); }
.image-view { height: 100%; display: grid; place-items: center; overflow: auto; padding: 24px; background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 50% / 20px 20px; }
.image-view img { max-width: 100%; max-height: 100%; box-shadow: var(--shadow-8); }
.binary-view { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); }
.editor-welcome { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; overflow: auto; z-index: 1; background: var(--surface); }
.editor-welcome h2 { font-size: 22px; line-height: 30px; }
.welcome-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 10px; margin: 16px 0; }
.welcome-grid > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 14px; border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--stroke-2); font-size: 13px; color: var(--text-3); }
.welcome-grid b { color: var(--text); font-size: 14px; }
.welcome-grid .icon { color: var(--brand-fg); }

/* ---------------- agent panel (Antigravity-style sidebar with Outlook colours) */
.agent-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface-2); border-left: 1px solid var(--stroke); }
.agent-panel.collapsed { overflow: hidden; border: 0; }
.agent-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 12px; border-bottom: 1px solid var(--stroke); flex: none; }
.agent-title { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--brand-fg); }
.engine-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.engine-chip.cloud { background: var(--brand-subtle); color: var(--brand-fg); }
.agent-messages { flex: 1; overflow: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 14px; }
.agent-empty { margin: auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; }
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; width: 100%; }
.suggestion { text-align: left; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--stroke); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-2); }
.suggestion:hover { border-color: var(--brand-stroke); color: var(--brand-fg); }
.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 88%; padding: 8px 12px; border-radius: 12px 12px 2px 12px;
  background: var(--brand); color: #fff; white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant { padding: 10px 12px; border-radius: 2px 12px 12px 12px; background: var(--surface); border: 1px solid var(--stroke-2); box-shadow: var(--shadow-2); }
.msg.assistant.error { background: var(--danger-bg); color: var(--danger); border-color: transparent; box-shadow: none; }
.msg-meta { font-size: 11px; color: var(--text-4); }
.thinking { font-size: 12px; color: var(--text-3); }
.thinking summary { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; user-select: none; }
.thinking-body { margin-top: 6px; padding: 8px 10px; border-left: 2px solid var(--stroke-strong); white-space: pre-wrap; max-height: 260px; overflow: auto; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: 100%;
  padding: 4px 10px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--surface-2);
  font-size: 12px; color: var(--text-2); cursor: pointer;
}
.tool-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-chip:hover:not(:disabled) { border-color: var(--brand-stroke); color: var(--brand-fg); }
.tool-chip:disabled { cursor: default; }
.tool-chip.failed { color: var(--danger); }
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: bounce 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.agent-notice { padding: 0 12px 8px; }
.agent-notice .engine-card { font-size: 12px; flex-wrap: wrap; }
.composer { flex: none; margin: 0 10px 10px; padding: 8px; border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--stroke); box-shadow: var(--shadow-4); }
.composer:focus-within { border-color: var(--brand-stroke); }
.composer textarea { width: 100%; border: 0; resize: none; background: transparent; padding: 4px 6px; max-height: 240px; line-height: 20px; }
.composer textarea:focus { border: 0; padding: 4px 6px; }
.composer-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.btn-send { width: 32px; padding: 0; border-radius: 50%; }
.context-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 120px; font-size: 11px; color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* markdown in messages */
.md { word-wrap: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; font-size: 15px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md code { font-family: var(--mono); font-size: 12.5px; padding: 1px 4px; border-radius: 3px; background: var(--surface-3); }
.md pre { margin: 8px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-3); overflow: auto; }
.md pre code { padding: 0; background: none; }
.md table { border-collapse: collapse; margin: 8px 0; display: block; overflow: auto; }
.md th, .md td { border: 1px solid var(--stroke); padding: 4px 8px; }
.md blockquote { margin: 8px 0; padding-left: 10px; border-left: 3px solid var(--brand-stroke); color: var(--text-3); }

/* ---------------- extensions + search */
.ext-search { display: flex; align-items: center; gap: 6px; margin: 4px 10px 6px; padding: 0 8px; border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-3); }
.ext-search input { flex: 1; border: 0; padding: 5px 0; background: transparent; min-width: 0; }
.ext-search input:focus { border: 0; padding: 5px 0; }
.ext-note { padding: 0 12px; font-size: 11px; line-height: 15px; color: var(--text-3); }
.ext-section { padding: 10px 14px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); }
.ext-item { display: flex; gap: 10px; padding: 8px 10px 8px 12px; align-items: flex-start; }
.ext-item:hover { background: var(--surface-hover); }
.ext-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: contain; flex: none; background: var(--surface-3); }
.ext-body { flex: 1; min-width: 0; font-size: 12px; }
.ext-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext-ver, .ext-pub, .ext-meta { color: var(--text-4); font-weight: 400; }
.ext-desc { color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ext-theme { display: flex; align-items: center; gap: 4px; margin-top: 4px; padding: 2px 8px; border: 1px solid var(--stroke); border-radius: 10px; background: var(--surface); font-size: 11px; cursor: pointer; }
.ext-theme.on { border-color: var(--brand); color: var(--brand-fg); }
.ext-installed { font-size: 11px; color: var(--success); font-weight: 600; }
.ext-reset { margin: 4px 12px; }
.ext-loading { padding: 12px; display: grid; place-items: center; }
.search-hit { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 6px 12px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 12px; }
.search-hit:hover { background: var(--surface-hover); }
.search-hit .icon { display: none; }
.hit-path { font-weight: 600; color: var(--text); }
.hit-line { color: var(--text-3); font-family: var(--mono); font-size: 11px; }

/* ---------------- status bar */
.statusbar {
  height: var(--statusbar-h); flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px;
  background: var(--brand); color: #fff; font-size: 12px;
}
.sb-item { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; height: 100%; white-space: nowrap; }
.mobile-tabs { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px; max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: var(--radius-lg); background: var(--text); color: var(--surface);
  box-shadow: var(--shadow-16); cursor: pointer; animation: pop .15s ease-out;
}

/* ============================================================ pages */
.page { flex: 1; overflow: auto; padding: 24px; max-width: 960px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 8px; }
.lead { font-size: 15px; line-height: 22px; color: var(--text-2); }
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-4); padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.card h2 { margin-bottom: 4px; }
.card h3 { margin-top: 8px; }
.row-kv { display: flex; gap: 12px; width: 100%; padding: 4px 0; border-bottom: 1px solid var(--stroke-2); }
.row-kv span { width: 120px; color: var(--text-3); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 14px; cursor: pointer; border-right: 1px solid var(--stroke); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.tier-list { margin: 4px 0; padding-left: 18px; color: var(--text-2); }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.app-card .icon { color: var(--brand-fg); }
.app-card ul { margin: 0; padding-left: 18px; color: var(--text-3); }
.app-card.featured { background: linear-gradient(135deg, var(--brand-subtle), var(--surface) 70%); border: 1px solid var(--brand-stroke); }
.dl-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.dl-list .btn { justify-content: flex-start; }
.center-card { margin: 10vh auto; max-width: 420px; text-align: center; background: var(--surface); padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-8); display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* landing */
.landing { flex: 1; overflow: auto; }
.landing-hero { text-align: center; padding: 10vh 24px 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; background: linear-gradient(180deg, var(--brand-subtle), var(--canvas)); }
.landing-hero h1 { font-size: 36px; line-height: 44px; }
.landing-hero .lead { max-width: 640px; }
.landing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 1040px; margin: 0 auto; padding: 0 24px 24px; }
.feature { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.feature .icon { color: var(--brand-fg); }
.feature p { color: var(--text-3); font-size: 13px; }
.landing-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 1040px; margin: 0 auto; padding: 0 24px 48px; }
.plan { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; border: 1px solid var(--stroke); }
.plan.featured { border-color: var(--brand-stroke); background: linear-gradient(135deg, var(--brand-subtle), var(--surface)); }

/* reconnect modal from the Blazor template */
#components-reconnect-modal { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-28); padding: 20px 24px; background: var(--surface); color: var(--text); }

/* ============================================================ responsive */
@media (max-width: 1200px) {
  :root { --agent-w: 340px; --sidebar-w: 220px; }
  .mail-shell { grid-template-columns: 200px 320px 1fr; }
}

@media (max-width: 960px) {
  .topbar-left, .topbar-right { min-width: 0; }
  .hide-sm { display: none !important; }
  .mail-shell { grid-template-columns: 1fr; }
  .folder-pane { display: none; position: fixed; z-index: 30; inset: var(--topbar-h) auto 0 0; width: 260px; box-shadow: var(--shadow-28); background: var(--surface); }
  .folder-pane.open { display: flex; }
  .only-sm { display: inline-flex; }
  .list-pane { border: 0; }
  .reading-pane { display: none; }
  .mail-shell:has(.item.selected) .list-pane { display: none; }
  .mail-shell:has(.item.selected) .reading-pane { display: block; margin: 0; border-radius: 0; box-shadow: none; }
  .mail-shell:not(:has(.item)) .reading-pane { display: block; margin: 0; border-radius: 0; box-shadow: none; }
  .mail-shell:not(:has(.item)) .list-pane { display: none; }

  /* IDE becomes three tabs: Files · Editor · Finn */
  .ws, .ws.no-side, .ws:has(.agent-panel.collapsed) { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .activitybar { display: none; }
  .ws > .sidebar, .ws > .editor-area, .ws > .agent-panel { grid-area: 1 / 1; display: none; border: 0; }
  .ws.mobile-files > .sidebar, .ws.mobile-editor > .editor-area, .ws.mobile-chat > .agent-panel { display: flex; }
  .ws.mobile-files > .sidebar.collapsed { display: flex; }
  .ws.mobile-chat > .agent-panel.collapsed { display: flex; }
  .statusbar { display: none; }
  .mobile-tabs {
    display: flex; flex: none; border-top: 1px solid var(--stroke); background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--text-3); font-size: 11px; cursor: pointer; }
  .mobile-tabs button.on { color: var(--brand-fg); font-weight: 600; }
  .topbar-search { display: none; }
  .composer textarea { font-size: 16px; } /* no iOS zoom */
}

@media (max-width: 520px) {
  .page { padding: 16px; }
  .welcome-grid { grid-template-columns: 1fr; }
  .brand span { display: none; }
}
