:root {
  --accent: #0061ff; --accent-dark: #004fe0; --accent-tint: #eaf1ff; --accent-tint2: #f3f7ff;
  --accent-ring: rgba(0,97,255,.15); --accent-border: #b7cdfb;
  --bg: #f7f8fa; --surface: #ffffff; --surface2: #f3f4f7; --line: #e8eaef; --line2: #dfe2e8;
  --ink: #1a1d26; --body: #3d4354; --muted: #8b91a1; --faint: #b4bac8;
  --coral: #e85d3a; --teal: #2aabb8; --purple: #6b5ce0; --green: #22a06b; --red: #e5484d;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "PingFang HK", sans-serif;
  --serif: var(--sans);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --shadow: 0 1px 2px rgba(26,29,38,.04), 0 4px 16px rgba(26,29,38,.05);
  --radius: 6px;
  --top-h: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--sans); background: var(--bg); color: var(--body);
       -webkit-font-smoothing: antialiased; overflow: hidden;
       overscroll-behavior: none; text-size-adjust: 100%; }

/* Boot splash — covers shell until pack branding is applied (avoids Pi logo flash). */
.boot-splash {
  position: fixed; inset: 0; z-index: 10000;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .18s ease, visibility .18s ease;
}
.boot-splash.hidden { display: none; }
.boot-splash.is-done {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.boot-splash-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.boot-splash-logo {
  width: 56px; height: 56px; object-fit: contain; display: block;
}
.boot-splash-logo.hidden { display: none; }
.boot-splash-spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line2);
  border-top-color: var(--accent);
  animation: boot-spin .7s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }

/* app shell — dvh for iOS dynamic toolbar, fallback vh */
.app { display: grid; height: 100vh; height: 100dvh;
       grid-template-columns: 280px 1fr; grid-template-rows: var(--top-h) auto auto 1fr; }

/* slim topbar */
.topbar { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center;
          justify-content: space-between; gap: 10px; padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
          padding-top: env(safe-area-inset-top); background: rgba(255,255,255,.88);
          backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
          border-bottom: 1px solid var(--line); z-index: 5; min-height: var(--top-h); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 28px; height: 28px; border-radius: 6px; background: var(--ink); color: #fff;
        display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.logo svg { width: 100%; height: 100%; display: block; }
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo.has-custom-logo { background: transparent; }
.brand h1 { font-family: var(--serif); font-size: 15px; margin: 0; font-weight: 700; color: var(--ink);
            letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.accent { color: var(--accent); }
  .topright { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }


.runtime-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line2);
  background: var(--surface2); color: var(--muted); line-height: 1; white-space: nowrap;
}
.runtime-badge.local { color: var(--teal); border-color: rgba(42,171,184,.35); background: rgba(42,171,184,.08); }
.runtime-badge.remote { color: var(--accent-dark); border-color: var(--accent-border); background: var(--accent-tint); }

.warm-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 14px;
  background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(42,171,184,.25);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--ink); font-size: 12.5px; font-weight: 600;
  /* tint via inset so overlay stays opaque enough over tabs/messages */
  box-shadow: 0 4px 14px rgba(26,29,38,.08), inset 0 0 0 999px rgba(42,171,184,.1);
}
.warm-banner.hidden { display: none; }
.warm-banner.failed {
  border-bottom-color: rgba(232,93,58,.28);
  box-shadow: 0 4px 14px rgba(26,29,38,.08), inset 0 0 0 999px rgba(232,93,58,.1);
}
.warm-banner.failed .warm-spin { display: none; }
.warm-banner .warm-retry.hidden { display: none; }
.warm-copy { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.warm-copy #warmText { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warm-steps { display: none !important; } /* compact overlay: hide step row */
.warm-dismiss {
  flex-shrink: 0; border: none; background: transparent; color: var(--muted);
  cursor: pointer; width: 28px; height: 28px; border-radius: 5px;
  font-size: 18px; line-height: 1; padding: 0; display: grid; place-items: center;
}
.warm-dismiss:hover { color: var(--ink); background: rgba(26,29,38,.06); }
.sleep-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  background: rgba(232,93,58,.1); border-bottom: 1px solid rgba(232,93,58,.28);
  color: var(--ink); font-size: 12.5px; font-weight: 600; flex-shrink: 0;
}
.sleep-banner.hidden { display: none; }
.sleep-banner .sleep-copy { flex: 1; min-width: 0; line-height: 1.35; }
.sleep-banner .sleep-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--coral); box-shadow: 0 0 0 3px rgba(232,93,58,.22);
  animation: warm-pulse 1.2s ease-in-out infinite;
}
.notif-wrap { position: relative; flex-shrink: 0; }
.notif-bell { position: relative; }
.notif-bell .notif-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--coral); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 16px; text-align: center;
  pointer-events: none; box-shadow: 0 0 0 1.5px var(--surface);
}
.notif-bell .notif-badge.hidden { display: none; }
.notif-panel {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(340px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 40; overflow: hidden;
}
.notif-panel.hidden { display: none; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface2);
}
.notif-panel-head .t { font-size: 12px; font-weight: 700; color: var(--ink); }
.notif-panel-head button {
  border: none; background: transparent; color: var(--accent); font-size: 11.5px;
  font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 4px;
}
.notif-panel-head button:hover { background: var(--accent-tint); }
.notif-section-label {
  padding: 8px 12px 4px; font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.user-menu-wrap { position: relative; flex-shrink: 0; }
.user-menu-panel {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(260px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 40; overflow: hidden; padding: 4px;
}
.user-menu-panel.hidden { display: none; }
.user-menu-profile {
  padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.user-menu-profile-label {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.user-menu-email {
  font-size: 13px; font-weight: 600; color: var(--ink);
  word-break: break-all; line-height: 1.35;
}
.user-menu-pack {
  margin-top: 4px; font-size: 11.5px; color: var(--muted); font-weight: 500;
}
.user-menu-pack:empty { display: none; }
.user-menu-item {
  display: flex; align-items: center; width: 100%; border: none; background: transparent;
  color: var(--ink); font-size: 12.5px; font-weight: 600; text-align: left;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; min-height: 36px;
  text-decoration: none; box-sizing: border-box;
}
.user-menu-item:hover { background: var(--accent-tint2); color: var(--accent-dark); }
.user-menu-item.hidden { display: none !important; }

/* CV profile modal */
.cv-profile-modal {
  width: min(860px, 96vw);
  max-height: min(92vh, 960px);
  display: flex;
  flex-direction: column;
  transition: width .2s ease, max-height .2s ease;
}
.cv-profile-modal.cv-profile-modal--full {
  width: min(920px, 98vw);
  max-height: min(96vh, 1100px);
}
.cv-profile-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 18px 18px;
  overflow: auto;
}
.cv-profile-editor {
  flex-shrink: 0;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface2, var(--bg));
}
.cv-profile-upload {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.cv-profile-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cv-profile-file-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink);
}
.cv-profile-parse-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 6.5rem;
}
.cv-profile-upload-hint {
  display: block;
  margin-top: 6px;
}
.cv-profile-editor-label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0;
  text-transform: none;
}
.cv-profile-url-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.cv-profile-url-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
}
.cv-profile-refresh-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 7.5rem;
  padding-left: 14px;
  padding-right: 14px;
}
.cv-profile-editor-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 10px;
}
.cv-profile-editor-hint {
  flex: 1 1 12rem;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
button.btn-link {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 600;
  font-size: 12.5px;
  padding: 0;
  min-height: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.btn-link.sm { font-size: 12.5px; }
button.btn-link:hover { filter: brightness(1.05); }
button.btn-link:disabled { opacity: .45; cursor: default; text-decoration: none; }
.cv-profile-feedback {
  margin: 10px 0 0;
  min-height: 0;
}
.cv-profile-feedback:empty { display: none; }
.cv-profile-preview {
  margin-top: 16px;
  min-height: 120px;
}
.cv-profile-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cv-profile-preview-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.cv-profile-preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.cv-profile-raw-btn,
.cv-profile-copy-btn {
  flex: 0 0 auto;
  font-size: 11px !important;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted) !important;
  text-decoration: none !important;
}
.cv-profile-raw-btn:hover,
.cv-profile-copy-btn:hover { color: var(--accent-dark) !important; }
.cv-profile-raw-btn.hidden,
.cv-profile-copy-btn.hidden { display: none !important; }
/* Beat `.modal-body pre { color: var(--ink) }` so light text stays readable on dark bg. */
.modal-body pre.cv-profile-raw,
pre.cv-profile-raw {
  margin: 0 0 12px;
  padding: 10px 12px;
  max-height: min(36vh, 320px);
  overflow: auto;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: #1a1d26;
  color: #e8eaef;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.cv-profile-raw.hidden { display: none !important; }
.cv-profile-body { min-height: 64px; }
.ok-msg {
  font-size: 13px; color: var(--accent-dark); font-weight: 600;
}
.ok-msg.hidden { display: none !important; }
.cv-profile-empty {
  margin: 0;
  padding: 22px 16px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--line2);
  border-radius: 8px;
}
.cv-profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.cv-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-tint2);
  border: 1px solid var(--accent-border);
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
}
.cv-profile-chip span {
  color: var(--muted);
  font-weight: 500;
}
.cv-profile-hint { margin: 14px 0 0; font-size: 12px; }

/* A4 paper CV preview */
.cv-paper-stage {
  margin: 0 -2px;
  padding: 18px 12px 22px;
  background: linear-gradient(180deg, #e8ebf2 0%, #d9dee8 100%);
  border: 1px solid var(--line2);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  overflow: auto;
}
.cv-paper {
  --cv-ink: #1a1a1a;
  --cv-muted: #555;
  --cv-rule: #c8c8c8;
  width: min(100%, 210mm);
  min-height: 297mm;
  box-sizing: border-box;
  background: #fff;
  color: var(--cv-ink);
  padding: 18mm 16mm 20mm;
  box-shadow:
    0 1px 2px rgba(26, 29, 38, .06),
    0 12px 36px rgba(26, 29, 38, .14);
  font-family: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 10.5pt;
  line-height: 1.45;
  transform-origin: top center;
}
.cv-paper.cv-paper--reveal {
  animation: cv-paper-in .35s ease-out;
}
@keyframes cv-paper-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cv-paper-header {
  text-align: center;
  padding-bottom: 10pt;
  border-bottom: 1.25pt solid var(--cv-ink);
  margin-bottom: 14pt;
}
.cv-paper-name {
  margin: 0 0 4pt;
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.15;
  color: var(--cv-ink);
}
.cv-paper-headline {
  margin: 0 0 6pt;
  font-family: var(--sans);
  font-size: 11pt;
  font-weight: 500;
  color: var(--cv-muted);
  line-height: 1.35;
}
.cv-paper-contact {
  margin: 0;
  font-family: var(--sans);
  font-size: 8.5pt;
  color: var(--cv-muted);
  letter-spacing: .01em;
  word-break: break-word;
}
.cv-paper-section {
  margin: 0 0 13pt;
}
.cv-paper-section-title {
  margin: 0 0 7pt;
  font-family: var(--sans);
  font-size: 9pt;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cv-ink);
  border-bottom: 0.75pt solid var(--cv-rule);
  padding-bottom: 3pt;
}
.cv-paper-summary {
  margin: 0;
  font-family: var(--sans);
  font-size: 10pt;
  line-height: 1.5;
  color: var(--cv-ink);
  text-align: justify;
  hyphens: auto;
}
.cv-paper-summary + .cv-paper-summary { margin-top: 6pt; }
.cv-paper-summary + .cv-paper-bullets { margin-top: 6pt; }
.cv-paper-entry {
  margin: 0 0 9pt;
}
.cv-paper-entry:last-child { margin-bottom: 0; }
.cv-paper-entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10pt;
}
.cv-paper-entry-left { min-width: 0; flex: 1 1 auto; }
.cv-paper-entry-title {
  font-family: var(--sans);
  font-size: 10.5pt;
  font-weight: 700;
  color: var(--cv-ink);
  line-height: 1.3;
}
.cv-paper-entry-sub {
  font-family: var(--sans);
  font-size: 9.5pt;
  font-style: italic;
  color: var(--cv-muted);
  margin-top: 1pt;
}
.cv-paper-entry-meta {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 8.5pt;
  color: var(--cv-muted);
  text-align: right;
  white-space: nowrap;
  padding-top: 1pt;
}
.cv-paper-entry-body {
  margin: 3pt 0 0;
  font-family: var(--sans);
  font-size: 9.5pt;
  line-height: 1.45;
  color: #333;
}
.cv-paper-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5pt 6pt;
}
.cv-paper-tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 8.5pt;
  font-weight: 600;
  color: var(--cv-ink);
  padding: 2pt 7pt;
  border: 0.6pt solid var(--cv-rule);
  border-radius: 2pt;
  background: #fafafa;
}
.cv-paper-bullets {
  margin: 0;
  padding-left: 1.15em;
  font-family: var(--sans);
  font-size: 9.5pt;
  line-height: 1.5;
  color: var(--cv-ink);
}
.cv-paper-bullets li { margin-bottom: 3pt; }

@media (max-width: 720px) {
  .cv-paper {
    width: 100%;
    min-height: 0;
    padding: 22px 18px 28px;
    font-size: 13px;
  }
  .cv-paper-name { font-size: 22px; }
  .cv-paper-headline { font-size: 13px; }
  .cv-paper-contact { font-size: 11px; }
  .cv-paper-section-title { font-size: 11px; }
  .cv-paper-entry-title { font-size: 13px; }
  .cv-paper-entry-sub { font-size: 12px; }
  .cv-paper-entry-meta {
    white-space: normal;
    text-align: left;
    max-width: 40%;
  }
  .cv-paper-entry-body,
  .cv-paper-summary,
  .cv-paper-bullets { font-size: 12.5px; }
  .cv-paper-tag { font-size: 11px; padding: 3px 8px; }
  .cv-paper-stage { padding: 12px 8px 16px; }
}

@media (max-width: 560px) {
  .cv-profile-modal,
  .cv-profile-modal.cv-profile-modal--full {
    width: min(100vw - 16px, 96vw);
    max-height: 94vh;
  }
  .cv-profile-editor {
    padding: 10px 10px 8px;
  }
  .cv-profile-editor-label { margin-bottom: 6px; }
  .cv-profile-url-row,
  .cv-profile-upload-row {
    flex-direction: row;
    align-items: stretch;
  }
  .cv-profile-refresh-btn,
  .cv-profile-parse-btn {
    width: auto;
    min-width: 4.5rem;
    padding-left: 10px;
    padding-right: 10px;
  }
  .cv-profile-editor-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 6px;
    gap: 4px 10px;
  }
  .cv-profile-editor-hint {
    display: none;
  }
  .cv-profile-upload {
    margin-top: 8px;
    padding-top: 8px;
  }
  .cv-paper-entry-head { flex-direction: column; gap: 2px; }
  .cv-paper-entry-meta { max-width: none; }
}

@media print {
  .cv-profile-modal-body > :not(.cv-profile-preview),
  .cv-profile-preview-head,
  .cv-profile-meta,
  .cv-profile-hint,
  .cv-profile-feedback { display: none !important; }
  .cv-paper-stage {
    margin: 0; padding: 0; border: none; background: none; border-radius: 0;
  }
  .cv-paper {
    box-shadow: none; width: 210mm; min-height: 297mm;
    margin: 0; padding: 18mm 16mm;
  }
}

/* onboarding wizard */
.onboard-modal { width: min(480px, 94vw); max-height: 84vh; }
.onboard-body { padding-top: 12px; min-height: 180px; }
.onboard-dots {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 16px;
}
.onboard-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--line2);
  transition: background .15s ease, transform .15s ease;
}
.onboard-dot.on { background: var(--accent); transform: scale(1.15); }
.onboard-step-title {
  margin: 0 0 10px; font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.3;
}
.onboard-step-body {
  margin: 0; font-size: 14px; line-height: 1.55; color: var(--body); white-space: pre-wrap;
}
.onboard-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.onboard-foot-right { display: flex; gap: 8px; align-items: center; }
.btn-accent {
  border: none; background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  border-radius: 6px; padding: 8px 14px; cursor: pointer; min-height: 36px;
}
.btn-accent.sm { padding: 6px 12px; min-height: 32px; font-size: 12.5px; }
.btn-accent:hover { filter: brightness(1.05); }
.btn-accent:disabled { opacity: .45; cursor: default; }

.usage-list { list-style: none; margin: 0; padding: 0 0 6px; max-height: 160px; overflow: auto;
              border-bottom: 1px solid var(--line); }
.usage-list li {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 12px; font-size: 12.5px; color: var(--body);
}
.usage-list li .udot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--faint);
}
.usage-list li.live .udot { background: var(--green); box-shadow: 0 0 0 3px rgba(34,160,107,.2); }
.usage-list li .uname {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: var(--ink);
}
.usage-list li .utimes { text-align: right; font-size: 11px; color: var(--muted); line-height: 1.3; }
.usage-list li .utimes b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.usage-empty, .notif-empty {
  padding: 14px 12px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 550;
}
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow: auto; }
.notif-list li {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--body);
  cursor: default;
}
.notif-list li:last-child { border-bottom: none; }
.notif-list li.unread { background: var(--accent-tint2); }
.notif-list li .ntitle { font-weight: 600; color: var(--ink); }
.notif-list li .nmeta { font-size: 11px; color: var(--muted); }
.warm-spin {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(42,171,184,.3); border-top-color: var(--teal);
  animation: warm-spin .7s linear infinite;
}
@keyframes warm-spin { to { transform: rotate(360deg); } }
.ws-dot.warming { background: var(--teal); box-shadow: 0 0 0 3px rgba(42,171,184,.25); animation: warm-pulse 1.2s ease-in-out infinite; }
@keyframes warm-pulse { 50% { opacity: .45; } }

body.ui-locked #workspaces { pointer-events: none; opacity: .55; }
body.ui-locked #newWsControls { pointer-events: none; opacity: .55; }
body.ui-locked #dropzone { pointer-events: none; opacity: .55; }
body.ui-locked #opStatus { opacity: 1; }
body.ui-locked #files .rowbtn.del { pointer-events: none; opacity: .4; }
body.ui-locked #manageChatsList .sess-actions { pointer-events: none; opacity: .45; }
body.ui-locked #manageChatsList .sess-main { pointer-events: none; }
body.ui-locked #stopBtn { pointer-events: auto; opacity: 1; }
/* Agent runs do not lock navigation — tabs/workspaces stay interactive. */

.chat-tab .tab-spin {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid rgba(0,97,255,.25); border-top-color: var(--accent);
  animation: warm-spin .7s linear infinite;
}
.chat-tab .tab-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
}
.ws-dot.running {
  background: transparent; border: 2px solid rgba(0,97,255,.28);
  border-top-color: var(--accent); box-shadow: none;
  animation: warm-spin .7s linear infinite;
}
.ws-dot.unread { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.composer-col { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); background: var(--surface); }
.composer-tip {
  padding: 6px 16px 0; font-size: 11.5px; font-weight: 550; color: var(--muted); line-height: 1.35;
}
.composer-tip.hidden { display: none; }

.mode-toggle { display: inline-flex; align-items: stretch; border: 1px solid var(--line2);
               border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--surface); }
.mode-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px;
            font-weight: 600; padding: 7px 12px; cursor: pointer; letter-spacing: .02em; }
.mode-btn:hover:not(:disabled) { color: var(--ink); background: var(--bg); }
.mode-btn.on { background: var(--accent-tint); color: var(--accent-dark); }
.mode-btn:disabled { opacity: .35; cursor: not-allowed; }
.modebar {
  grid-row: 2; grid-column: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; min-height: 48px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  z-index: 2;
}
.modebar .mode-hint { font-size: 11px; color: var(--muted); min-width: 0; flex: 1;
                      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.op-status {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 10px;
  padding: 8px 10px; border-radius: 6px;
  background: rgba(42,171,184,.12); border: 1px solid rgba(42,171,184,.3);
  color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1.35;
}
.op-status.hidden { display: none; }
.btn-spin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(26,29,38,.2); border-top-color: var(--accent);
  animation: warm-spin .7s linear infinite; vertical-align: -1px;
}
.newws-input-wrap .btn-embed.busy { min-width: 72px; color: var(--accent-dark); }

/* Chat / Files — mobile only, above the composer */
.segbar { display: none; }

/* sidebar (file manager) */
.sidebar { grid-row: 2 / -1; grid-column: 1; background: var(--surface2); border-right: 1px solid var(--line);
           display: flex; flex-direction: column; min-height: 0; overflow: hidden; z-index: 1; }
.sb-section { display: flex; flex-direction: column; min-height: 0; }
.sb-section + .sb-section { border-top: 1px solid var(--line); }
.sb-fill { flex: 1; min-height: 0; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; flex-shrink: 0; }
.sb-head .t { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sb-head .active { color: var(--ink); font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

ul.list { list-style: none; margin: 0; padding: 0 8px 10px; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
ul.list li { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--radius);
             cursor: pointer; font-size: 13px; color: var(--ink); min-height: 40px; font-weight: 500;
             transition: background .12s; }
ul.list li:hover { background: rgba(255,255,255,.7); }
li.ws.active { background: var(--accent-tint); color: var(--accent-dark); font-weight: 600; }
li .ico { width: 18px; text-align: center; flex-shrink: 0; }
li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
li .meta { font-size: 11px; color: var(--muted); flex-shrink: 0; }
li .rowbtns { display: flex; gap: 2px; flex-shrink: 0; }
/* desktop: reveal actions on hover; touch keeps them always visible (no sticky :hover trap) */
@media (hover: hover) and (pointer: fine) {
  li .rowbtns { display: none; }
  li:hover .rowbtns { display: flex; }
  li:hover .meta { display: none; }
}
.rowbtn { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 6px; border-radius: 5px; font-size: 14px; min-width: 32px; min-height: 32px; }
.rowbtn:hover { background: rgba(26,29,38,.06); color: var(--ink); }
.rowbtn.dl:hover { color: var(--accent); }
.rowbtn.del:hover { color: var(--red); }
.rowbtn.ws-more { font-size: 16px; line-height: 1; letter-spacing: .02em; }
.ws-menu {
  position: fixed; min-width: 168px; padding: 4px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
}
.ws-menu.hidden { display: none; }
.ws-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: transparent;
  color: var(--ink); font-size: 12.5px; font-weight: 600; text-align: left;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; min-height: 36px;
}
.ws-menu button:hover { background: var(--accent-tint2); color: var(--accent-dark); }
.ws-menu button:disabled { opacity: .4; cursor: not-allowed; }
.ws-menu button.hidden { display: none; }
.badge-s { background: var(--accent); color: #fff; border-radius: 999px; font-size: 9.5px; padding: 1px 6px; font-weight: 700; }
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.ws-dot.on { background: var(--green); }
/* workspace controls: name input with embedded New, then Open + Import */
.newws-controls { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 12px; flex-shrink: 0; }
.pack-switch {
  display: flex; flex-direction: column; gap: 4px;
  padding: 0 12px 10px; flex-shrink: 0;
}
.pack-switch-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.pack-switch-select { width: 100%; }
.newws-input-wrap { display: flex; align-items: stretch; width: 100%;
                    border: 1.5px solid var(--line2); border-radius: 6px; background: var(--surface);
                    overflow: hidden; min-height: 40px; transition: border-color .12s, box-shadow .12s; }
.newws-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.newws-controls.highlight .newws-input-wrap { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.newws-input-wrap input { flex: 1; min-width: 0; border: none !important; box-shadow: none !important;
                          border-radius: 0; background: transparent; font-size: 12.5px;
                          padding: 8px 10px; min-height: 38px; }
.newws-input-wrap input:focus { outline: none; }
.newws-input-wrap .btn-embed { flex-shrink: 0; border: none; border-left: 1.5px solid var(--line2);
                               border-radius: 0; background: var(--surface2); color: var(--ink);
                               padding: 0 12px; font-size: 12px; font-weight: 600; min-height: 0;
                               min-width: 64px; white-space: nowrap; }
.newws-input-wrap .btn-embed:hover { background: var(--accent-tint2); color: var(--accent-dark); }
.ws-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.newws-actions { display: flex; gap: 6px; }
.newws-actions button { flex: 1 1 0; min-width: 0; justify-content: center; }

.import-choices { display: flex; flex-direction: column; gap: 8px; }
.import-choices .btn-soft { justify-content: center; min-height: 44px; font-weight: 600; }
.import-git-panel.hidden { display: none; }

/* server folder browser */
.browse-path { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all;
               padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; }
.browse-list { list-style: none; margin: 0; padding: 0; max-height: min(48vh, 360px); overflow: auto;
               border: 1px solid var(--line); border-radius: 6px; }
.browse-list li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer;
                  border-bottom: 1px solid var(--line); font-size: 13px; min-height: 40px; }
.browse-list li:last-child { border-bottom: none; }
.browse-list li:hover { background: var(--accent-tint2); }
.browse-list li .ico { flex-shrink: 0; opacity: .7; }
.browse-list li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-empty { color: var(--muted); padding: 16px; text-align: center; font-size: 13px; }

/* dropzone */
.dropzone { margin: 4px 12px 8px; border: 1.5px dashed var(--line2); border-radius: var(--radius); padding: 14px;
            text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; transition: .15s;
            background: var(--surface); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-tint2); color: var(--accent-dark); }
.dropzone b { color: var(--accent); }

/* chat */
.chat-head { grid-row: 3; grid-column: 2; display: flex; align-items: center; justify-content: space-between; padding: 10px 20px;
             border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; min-height: 48px; z-index: 2;
             position: relative; }
.chat-head .ct { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.chat-head .fname { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 14px; letter-spacing: -.02em;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title-btn {
  display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  border: none; background: transparent; padding: 0; margin: 0; cursor: default;
  color: inherit; font: inherit; text-align: left;
}
.chat-title-btn.is-switch {
  cursor: pointer;
  border: 1.5px solid var(--line2);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px 6px 12px;
  box-shadow: 0 1px 0 rgba(26,29,38,.04);
}
.chat-title-btn.is-switch:hover {
  background: var(--accent-tint2);
  border-color: var(--accent-border);
  color: var(--accent-dark);
}
.chat-title-btn.is-switch:hover .fname { color: var(--accent-dark); }
.chat-title-btn.is-switch:hover .topic-switch-caret { color: var(--accent-dark); background: var(--accent-tint); }
.chat-title-btn.is-switch[aria-expanded="true"] {
  background: var(--accent-tint);
  border-color: var(--accent-border);
}
.chat-title-btn:disabled { opacity: 1; cursor: default; }
.chat-title-btn.is-switch .fname { font-size: 13.5px; }
.topic-switch-label {
  flex-shrink: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); line-height: 1;
}
.chat-title-btn.is-switch:hover .topic-switch-label { color: var(--accent-dark); }
.topic-switch-caret {
  flex-shrink: 0;
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px; font-weight: 700; line-height: 1;
}
.chat-title-btn.is-switch[aria-expanded="true"] .topic-switch-caret {
  background: var(--accent-tint2);
  color: var(--accent-dark);
  transform: rotate(180deg);
}
.topic-switch-panel {
  position: absolute; top: calc(100% + 4px); left: 12px; right: auto;
  width: min(280px, calc(100vw - 24px)); max-height: min(60vh, 360px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 30; padding: 4px;
}
.topic-switch-panel.hidden { display: none; }
.topic-switch-item {
  display: block; width: 100%; border: none; background: transparent; text-align: left;
  padding: 9px 10px; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink); cursor: pointer;
}
.topic-switch-item:hover { background: var(--accent-tint2); color: var(--accent-dark); }
.topic-switch-item.active { background: var(--accent-tint); color: var(--accent-dark); }
.topic-switch-empty { padding: 12px 10px; font-size: 12.5px; color: var(--muted); }
.chat-head .chat-ws-more { display: none; flex-shrink: 0; }
html.query-mode .chat-head .chat-ws-more,
body.query-mode .chat-head .chat-ws-more { display: none !important; }
html.query-mode .sb-agent-only,
body.query-mode .sb-agent-only { display: none !important; }
html.query-mode .sb-query-only,
body.query-mode .sb-query-only { display: flex !important; flex-direction: column; min-height: 0; }
html:not(.query-mode):not(.pack-query-only) body:not(.query-mode):not(.pack-query-only) .sb-query-only,
body:not(.query-mode):not(.pack-query-only) .sb-query-only { display: none !important; }
/* Pack disables the query surface (capabilities.query === false, e.g.
   core-only superadmin): no mode bar, no query sidebar — agent only. */
html.agent-only .modebar,
body.agent-only .modebar { display: none !important; }
html.agent-only .sb-query-only,
body.agent-only .sb-query-only { display: none !important; }
/* Pack-admin disabled Agent mode: hide workspaces/files on first paint */
html.pack-query-only .modebar,
body.pack-query-only .modebar { display: none !important; }
/* Keep the bell for import notifications on query-only packs. */
html.pack-query-only .notif-wrap .notif-section-label:first-of-type,
body.pack-query-only .notif-wrap .notif-section-label:first-of-type,
html.pack-query-only .notif-wrap #usageList,
body.pack-query-only .notif-wrap #usageList { display: none !important; }
html.pack-query-only .segbar,
body.pack-query-only .segbar { display: none !important; }
html.pack-query-only .sb-agent-only,
body.pack-query-only .sb-agent-only { display: none !important; }
html.pack-query-only .sb-query-only,
body.pack-query-only .sb-query-only { display: flex !important; flex-direction: column; min-height: 0; }
/* Single-chat-tab packs: hide multi-tab chrome on first paint */
html.pack-single-chat #chatTabsBar,
body.pack-single-chat #chatTabsBar,
html.pack-single-chat #resumePill,
body.pack-single-chat #resumePill { display: none !important; }
.sb-query-only.sb-fill { flex: 1; min-height: 0; }
.chat-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; flex-shrink: 0; }
.chat { grid-row: 4; grid-column: 2; display: flex; flex-direction: column; min-height: 0; background: var(--bg); overflow: hidden; position: relative; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-dark); flex-shrink: 0; }
.pill.idle { background: var(--surface2); color: var(--muted); }

/* browser-style chat session tabs */
.chat-tabs { display: flex; align-items: stretch; gap: 0; background: var(--surface2);
             border-bottom: 1px solid var(--line); flex-shrink: 0; min-height: 38px; }
.chat-tabs-scroll { display: flex; align-items: stretch; gap: 2px; flex: 1; min-width: 0;
                    overflow-x: auto; overflow-y: hidden; padding: 4px 4px 0;
                    -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.chat-tab { display: flex; align-items: center; gap: 6px; max-width: 180px; min-width: 72px;
            padding: 6px 8px 6px 12px; border: 1px solid transparent; border-bottom: none;
            border-radius: 6px 6px 0 0; background: transparent; color: var(--muted);
            font-size: 12px; font-weight: 600; cursor: pointer; flex-shrink: 0; min-height: 32px; }
.chat-tab:hover { background: var(--surface); color: var(--ink); }
.chat-tab.active { background: var(--surface); color: var(--ink); border-color: var(--line);
                   box-shadow: 0 -1px 0 var(--surface); position: relative; z-index: 1; }
.chat-tab .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
                text-align: left; pointer-events: none; }
.chat-tab .tx { border: none; background: transparent; color: var(--muted); cursor: pointer;
                padding: 0; margin: 0; width: 22px; min-width: 22px; height: 22px; min-height: 22px;
                border-radius: 4px; font-size: 14px; line-height: 1; display: grid; place-items: center;
                flex-shrink: 0; opacity: .55; }
.chat-tab .tx:hover { background: rgba(26,29,38,.08); color: var(--ink); opacity: 1; }
.chat-tab-add { flex-shrink: 0; border: none; background: transparent; color: var(--muted);
                width: 36px; min-width: 36px; min-height: 36px; padding: 0; margin: 1px 2px 0 2px;
                border-radius: 5px; font-size: 18px; line-height: 1; cursor: pointer;
                display: grid; place-items: center; }
.chat-tab-add:hover { background: var(--accent-tint2); color: var(--accent-dark); }
.chat-tab-add:disabled { opacity: .35; cursor: not-allowed; }
.chat-tab-manage { font-size: 15px; }
.chat-focus-btn { display: none; font-size: 15px; }
.chat.disabled .chat-tabs { pointer-events: none; opacity: .55; }

.sess-list { list-style: none; margin: 0; padding: 0; max-height: min(52vh, 420px); overflow: auto;
             border: 1px solid var(--line); border-radius: 6px; }
.sess-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
                border-bottom: 1px solid var(--line); min-height: 48px; }
.sess-list li:last-child { border-bottom: none; }
.sess-list li.closed { opacity: .72; background: var(--bg); }
.sess-list .sess-main { flex: 1; min-width: 0; cursor: pointer; }
.sess-list .sess-title { font-weight: 600; font-size: 13px; color: var(--ink);
                         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-list .sess-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sess-list .sess-actions { display: flex; gap: 6px; flex-shrink: 0; }
.sess-empty { color: var(--muted); padding: 20px; text-align: center; font-size: 13px; }

.messages { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-height: 0;
            -webkit-overflow-scrolling: touch; }
.msg { max-width: 80%; display: flex; flex-direction: column; gap: 5px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; }
.bubble { padding: 10px 13px; border-radius: 10px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; white-space: pre-wrap; }
.msg.agent .bubble { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 3px; box-shadow: var(--shadow); }
.msg .who { font-size: 10.5px; color: var(--muted); font-weight: 600; padding: 0 4px; }
.toolgroup { font-family: var(--mono); font-size: 11.5px; background: var(--accent-tint2); border: 1px solid var(--accent-border);
             border-radius: 6px; padding: 5px 9px; color: var(--accent-dark); margin: 4px 0; }
.toolgroup > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
                       user-select: none; color: var(--muted); font-weight: 600; }
.toolgroup > summary::-webkit-details-marker { display: none; }
.toolgroup > summary::before { content: '▸'; font-size: 10px; color: var(--muted); transition: transform .12s ease; }
.toolgroup[open] > summary::before { transform: rotate(90deg); }
.toolgroup > summary .tn { color: var(--coral); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolgroup-chips { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.toolgroup .toolchip { margin: 2px 0; background: var(--surface); }
.toolchip { font-family: var(--mono); font-size: 11.5px; background: var(--accent-tint2); border: 1px solid var(--accent-border);
            border-radius: 5px; padding: 5px 9px; color: var(--accent-dark); margin: 4px 0; }
.toolchip > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
                      user-select: none; color: var(--muted); font-weight: 600; }
.toolchip > summary::-webkit-details-marker { display: none; }
.toolchip > summary::before { content: '▸'; font-size: 10px; color: var(--muted); transition: transform .12s ease; }
.toolchip[open] > summary::before { transform: rotate(90deg); }
.toolchip .tn { color: var(--coral); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolchip.is-error .tn { color: var(--red); }
.toolchip-body { margin: 6px 0 2px; padding: 6px 8px; border-radius: 4px; background: var(--surface);
                 border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; line-height: 1.45;
                 white-space: pre-wrap; word-break: break-word; color: var(--ink); overflow-x: auto; max-height: 220px; overflow-y: auto; }
.md { white-space: normal; color: var(--ink); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.55em 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 0.85em 0 0.35em; line-height: 1.3; font-weight: 800; color: var(--ink);
  letter-spacing: -0.02em;
}
.md h1 { font-size: 1.45em; }
.md h2 { font-size: 1.28em; }
.md h3 { font-size: 1.14em; }
.md h4, .md h5, .md h6 { font-size: 1.05em; font-weight: 700; }
.md ul, .md ol { margin: 0.45em 0; padding-left: 1.45em; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md li { margin: 0.25em 0; }
.md li > p { margin: 0.2em 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md blockquote { margin: 0.5em 0; padding: 0.15em 0 0.15em 0.75em; border-left: 3px solid var(--accent-border); color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 0.75em 0; }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--accent-tint2); border: 1px solid var(--accent-border);
           border-radius: 4px; padding: 0.1em 0.35em; }
.md pre { margin: 0.55em 0; padding: 8px 10px; border-radius: 6px; background: var(--accent-tint2);
          border: 1px solid var(--accent-border); overflow-x: auto; }
.md pre code { background: none; border: none; padding: 0; font-size: 12px; white-space: pre; }
.md table { border-collapse: collapse; margin: 0.55em 0; font-size: 0.92em; width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md th { background: var(--accent-tint2); font-weight: 600; }
.md strong { font-weight: 700; }
.agentmeta { font-size: 11px; color: var(--green); font-weight: 600; }
.match-diag-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px; padding: 6px 12px; font-size: 12px; font-weight: 650;
  border: 1px solid var(--accent-border); border-radius: 6px;
  background: var(--accent-tint2); color: var(--accent-dark); cursor: pointer;
}
.match-diag-btn:hover { background: var(--accent-tint); border-color: var(--accent); }
.match-diag-modal { width: min(720px, 94vw); max-height: 88vh; }
.match-diag-body { display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.match-diag-step {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--bg);
}
.match-diag-step h4 {
  margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--ink);
}
.match-diag-step .step-kicker {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}
.match-diag-pre {
  margin: 0; padding: 8px; border-radius: 6px; background: var(--surface);
  border: 1px solid var(--line); font-size: 11px; line-height: 1.45;
  overflow: auto; max-height: 220px; white-space: pre-wrap; word-break: break-word;
}
.match-diag-job {
  border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px;
}
.match-diag-job:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.match-diag-job .job-title { font-weight: 700; font-size: 13px; }
.match-diag-job .job-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.match-diag-comps {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.match-diag-comps span {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.match-diag-comps span.pos { border-color: #86efac; color: #166534; }
.match-diag-comps span.neg { border-color: #fecaca; color: #991b1b; }
.match-diag-sort-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px;
}
.match-diag-sort-select {
  flex: 1 1 180px; min-width: 160px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px;
}
.match-diag-apply { white-space: nowrap; }
.match-diag-preview-meta { margin-top: 8px; }
.match-diag-preview-jobs {
  margin-top: 6px;
  max-height: min(48vh, 420px);
  overflow: auto;
}
.typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.35;
  min-height: 1.35em;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  animation: typing-bounce 1.05s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}
.typing-label {
  color: var(--muted);
  font-weight: 500;
}
.typing-timer {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--faint);
  font-weight: 550;
  flex-shrink: 0;
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots span {
    animation: none;
    opacity: 0.7;
  }
}
.empty { margin: auto; text-align: center; color: var(--muted); padding: 28px 24px; max-width: 360px; }
.welcome-wrap { width: 100%; padding: 12px 16px 20px; }
.welcome-wrap .msg { max-width: 720px; }
.empty .big { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 8px;
              background: var(--accent-tint); border: 1px solid var(--accent-border);
              display: grid; place-items: center; font-size: 22px; line-height: 1; color: var(--accent); }
.empty b { color: var(--ink); font-weight: 600; }
.chat.disabled { opacity: .55; }
.chat-head.disabled { pointer-events: none; opacity: .55; }
.chat.disabled .composer { pointer-events: none; opacity: .5; }
.segbtn:disabled { opacity: .4; cursor: not-allowed; }

/* composer — sits above iOS home indicator */
.composer { background: transparent; padding: 12px 16px; position: relative;
            padding-bottom: max(12px, env(safe-area-inset-bottom));
            display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; border-top: none; }
.cmd-menu { position: absolute; left: 16px; right: 60px; bottom: calc(100% + 4px); z-index: 20;
            background: var(--surface); border: 1px solid var(--line2); border-radius: 10px;
            box-shadow: 0 8px 24px rgba(15,23,42,.14); max-height: 260px; overflow-y: auto; }
.cmd-menu.hidden { display: none; }
.cmd-item { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; cursor: pointer; }
.cmd-item.on, .cmd-item:hover { background: var(--accent-tint); }
.cmd-name { font-weight: 700; color: var(--accent-dark); white-space: nowrap; font-size: 13.5px; }
.cmd-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* TG-style "/" button pinned at the composer's left edge */
/* Queued follow-up bubble (runs next on the same stream) */
.msg.user.queued .bubble { opacity: .55; font-style: italic; }
.msg.user.queued .who::after { content: '· queued ⏳'; margin-left: .35em; opacity: .7; font-size: .85em; }

/* ── photo upload (query mode) ─────────────────────────── */
.upload-preview {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .5rem; margin-bottom: .35rem;
  border: 1px solid var(--line, #333); border-radius: .5rem;
  background: var(--panel, #1a1a1a); font-size: .82rem;
}
.upload-preview.hidden { display: none; }
.upload-preview img {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: .35rem; border: 1px solid var(--line, #333);
}
.upload-preview .upload-name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; opacity: .8;
}
.upload-preview .upload-cancel {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .6; font-size: .9rem; padding: .2rem .35rem;
}
.upload-preview .upload-cancel:hover { opacity: 1; }
.msg .bubble img.msg-photo {
  display: block; max-width: 260px; max-height: 260px;
  border-radius: .5rem; margin-bottom: .3rem;
}
.msg .bubble .msg-photo-caption { white-space: pre-wrap; }

.cmd-menu-btn { flex: 0 0 auto; width: 44px; height: 44px; padding: 0;
                font-size: 19px; font-weight: 700; line-height: 1; color: var(--muted); }
.cmd-menu-btn:hover, .cmd-menu-btn.on { color: var(--accent-dark); border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; font-family: var(--sans);
                     font-size: 15px; padding: 10px 12px; border: 1.5px solid var(--line2); border-radius: 8px;
                     line-height: 1.4; background: var(--bg); }
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
#sendBtn {
  width: 44px; min-width: 44px; height: 44px; min-height: 44px;
  padding: 0; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 8px; align-self: flex-end;
}
#sendBtn svg { width: 18px; height: 18px; display: block; }
#langBtn { min-width: 52px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

button { font: inherit; cursor: pointer; border: 1.5px solid transparent; border-radius: 6px;
         padding: 10px 16px; font-weight: 600; transition: .12s; min-height: 42px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.btn-soft { background: var(--surface); border-color: var(--line2); color: var(--ink); }
button.btn-soft:hover { background: var(--surface2); border-color: var(--line); }
button.sm { padding: 7px 12px; font-size: 12px; min-height: 36px; border-radius: 5px; }
button.icon { padding: 8px; background: transparent; color: var(--muted); border: none; min-width: 38px; min-height: 38px; border-radius: 5px; }
button.icon:hover { color: var(--accent); background: var(--accent-tint2); }

.hint { color: var(--muted); font-size: 12px; margin: 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(26,29,38,.4); display: none; place-items: center;
            z-index: 20; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.modal-bg.open { display: grid; }
.modal { background: var(--surface); border-radius: 10px; width: min(720px, 94vw); max-height: 84vh;
         display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 64px rgba(26,29,38,.18);
         border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head .mn { font-weight: 700; color: var(--ink); font-family: var(--mono); font-size: 13px; }
.modal-body { padding: 16px; overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-body pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--ink); }
#passwordErr { color: var(--red); font-size: 12.5px; font-weight: 600; min-height: 1.2em; }

/* customize modal */
.cust-field { display: flex; flex-direction: column; }
.cust-field label { font-weight: 700; color: var(--ink); font-size: 13px; margin-bottom: 5px; }
.cust-field .hint { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.cust-ta { width: 100%; min-height: 110px; font-family: var(--mono); font-size: 12.5px; padding: 10px;
           border: 1.5px solid var(--line2); border-radius: 6px; resize: vertical; line-height: 1.5; background: var(--bg); }
.cust-ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }

select, input.inp { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line2);
                    border-radius: 6px; padding: 8px 10px; min-height: 38px; }
select:focus, input.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.hidden { display: none !important; }

/* ── responsive: iPad portrait & mobile (≤ 860px) ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top-h) auto auto 1fr auto; }
  .topbar { grid-row: 1; }
  .modebar { grid-row: 2; grid-column: 1; padding: 6px 12px; min-height: 40px; }
  .modebar .mode-hint { display: none; }
  .composer-tip { display: none !important; }
  .warm-banner { padding: 6px 10px 6px 12px; font-size: 12px; }
  .sleep-banner {
    gap: 8px; padding: 6px 10px 6px 12px; font-size: 12px;
    flex-wrap: nowrap;
  }
  .sleep-banner .sleep-copy {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3;
  }
  .sleep-banner #sleepNowBtn { display: none; }
  .chat-head { grid-row: 3; grid-column: 1; padding: 8px 12px; min-height: 44px; background: var(--surface2);
               border-bottom: 1px solid var(--line); }
  .chat-head .fname { font-size: 15px; }
  .chat-head .chat-ws-more { display: grid; place-items: center; width: 36px; min-width: 36px;
                             height: 36px; min-height: 36px; font-size: 18px;
                             border: 1px solid var(--line2); border-radius: 6px; background: var(--surface); }
  .chat-head .chat-ws-more:hover { background: var(--accent-tint2); color: var(--accent-dark); }
  .sidebar { grid-row: 4; grid-column: 1; border-right: none; background: var(--bg); }
  .chat { grid-row: 4; grid-column: 1; }
  body:not(.view-files) .sidebar { display: none; }
  body.view-files .chat { display: none; }
  body.view-files #resumePill { display: none; }
  /* Keep modebar visible on Files so Agent-without-workspace can switch to Query. */
  .segbar { display: flex; grid-row: 5; grid-column: 1; justify-content: center; align-items: center;
            padding: 6px 12px; padding-bottom: max(6px, env(safe-area-inset-bottom));
            background: var(--surface); border-top: 1px solid var(--line); z-index: 3; }
  .segbar-track { display: flex; gap: 2px; width: fit-content; max-width: calc(100% - 24px);
                  margin: 0 auto; padding: 3px; background: var(--bg); border: 1px solid var(--line2);
                  border-radius: 8px; }
  .segbtn { flex: 0 0 auto; min-width: 96px; border: none; background: transparent; color: var(--muted);
            padding: 7px 14px; border-radius: 6px; font-weight: 600; font-size: 13px; min-height: 34px; cursor: pointer; }
  .segbtn.on { background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow); }
  .messages { padding: 14px; }
  .msg { max-width: 88%; }
  li .meta { display: none; }              /* hide size so action buttons always fit */
  .chat-tabs { background: var(--surface); }
  .chat-focus-btn { display: grid; }

  /* full-screen chat: hide chrome, give messages the full viewport */
  body.chat-focus .app { grid-template-rows: 1fr; }
  body.chat-focus .topbar,
  body.chat-focus .modebar,
  body.chat-focus .chat-head,
  body.chat-focus .segbar { display: none; }
  body.chat-focus .chat {
    grid-row: 1;
    padding-top: env(safe-area-inset-top);
  }
  body.chat-focus .chat-focus-btn { color: var(--accent-dark); background: var(--accent-tint2); }
}

/* phones */
@media (max-width: 480px) {
  .brand h1 { font-size: 14px; }
  .segbtn { font-size: 12.5px; padding: 6px 12px; min-width: 88px; min-height: 32px; }
  .composer { padding: 8px 10px; }
  .messages { padding: 12px 10px; }
  .bubble { font-size: 13.5px; padding: 9px 12px; }
}

/* landscape phones — keep segmented, give chat priority */
@media (max-width: 860px) and (orientation: landscape) and (max-height: 500px) {
  .app { grid-template-rows: var(--top-h) auto auto 1fr auto; }
  .messages { padding-top: 8px; padding-bottom: 8px; }
}

/* ── admin pages (superadmin + pack admin) ── */
body.admin-page .admin-mobile-only { display: none; }
body.admin-page .admin-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: 10px;
}
body.admin-page .admin-table-wrap table { margin: 0; }
body.admin-page .admin-actions-cell {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

@media (max-width: 860px) {
  body.admin-page .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--top-h) 1fr auto;
    height: 100vh; height: 100dvh;
  }
  body.admin-page .sidebar { display: none !important; }
  body.admin-page .admin-main {
    grid-row: 2; grid-column: 1;
    min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
    display: block;
  }
  body.admin-page .segbar {
    display: flex; grid-row: 3; grid-column: 1;
    justify-content: center; align-items: center;
    padding: 6px 12px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); z-index: 3;
  }
  body.admin-page .segbar-track {
    display: flex; gap: 2px; width: fit-content; max-width: calc(100% - 8px);
    margin: 0 auto; padding: 3px; background: var(--bg); border: 1px solid var(--line2);
    border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  body.admin-page .segbar-track::-webkit-scrollbar { display: none; }
  body.admin-page .segbtn {
    flex: 0 0 auto; min-width: 88px; border: none; background: transparent;
    color: var(--muted); padding: 7px 14px; border-radius: 6px;
    font-weight: 600; font-size: 13px; min-height: 34px; cursor: pointer;
  }
  body.admin-page .segbtn.on {
    background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow);
  }
  body.admin-page .topbar {
    gap: 8px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }
  body.admin-page .topright { gap: 4px; min-width: 0; }
  body.admin-page .admin-desk-only { display: none !important; }
  body.admin-page .admin-mobile-only { display: block; }
  body.admin-page .admin-wrap {
    padding: 16px max(14px, env(safe-area-inset-right)) max(72px, calc(env(safe-area-inset-bottom) + 56px)) max(14px, env(safe-area-inset-left));
  }
  body.admin-page .settings-row {
    flex-direction: column; align-items: stretch; gap: 10px;
  }
  body.admin-page .admin-main button,
  body.admin-page .admin-main select,
  body.admin-page .admin-main input[type="email"],
  body.admin-page .admin-main input[type="password"],
  body.admin-page .admin-main input[type="text"],
  body.admin-page .admin-main input[type="url"],
  body.admin-page .admin-main input[type="number"],
  body.admin-page .admin-main input[type="date"],
  body.admin-page .admin-main input[type="tel"] {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  body.admin-page .segbtn {
    font-size: 12px; padding: 6px 10px; min-width: 72px; min-height: 32px;
  }
  body.admin-page .admin-wrap { padding: 12px 10px max(68px, calc(env(safe-area-inset-bottom) + 52px)); }
}

@media (max-width: 860px) and (orientation: landscape) and (max-height: 500px) {
  body.admin-page .admin-wrap { padding-top: 10px; padding-bottom: max(56px, calc(env(safe-area-inset-bottom) + 44px)); }
}
