:root {
  --bg: #ffffff;
  --ink: #0d0d0d;
  --mute: #6e6e80;
  --line: #e8e8ea;
  --soft: #f7f7f8;
  --disabled: #b0b0b8;
  --font: "Söhne", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --brand-bar-h: 68px;
  --sticky-search-top: calc(var(--brand-bar-h) + 20px);
  --search-w: 560px;
  --search-side: 84px;
  --process-w: 90%;
  --accent: #2563eb;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}
.hidden { display: none !important; }

.portal-body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -8%, #f4f4f6 0%, transparent 55%),
    var(--bg);
  padding-top: var(--brand-bar-h);
}

.brand-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  min-height: var(--brand-bar-h);
  height: var(--brand-bar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 20px 2px;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  border-bottom: none;
  outline: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.brand-mark {
  justify-self: start;
  align-self: center;
  margin: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand-mark:hover { opacity: 0.82; }

.brand-bar .app-nav {
  justify-self: center;
  align-self: center;
  margin: 0;
  transform: translateY(5px);
  pointer-events: auto;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(13, 13, 13, 0.08);
  box-shadow:
    0 6px 16px rgba(13, 13, 13, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.top-actions {
  justify-self: end;
  align-self: center;
  margin: 0;
  position: static;
  z-index: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: auto;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 2px 4px 2px 2px;
  cursor: pointer;
  color: var(--mute);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
}
.account-chip:hover { color: var(--ink); }
.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(13, 13, 13, 0.08);
}
.account-avatar.is-guest {
  background: #e8e8ea;
  color: #9a9aa3;
}
.account-avatar.is-guest svg {
  width: 16px;
  height: 16px;
  display: block;
}
.account-avatar.is-user {
  background: var(--avatar-bg, #94a3b8);
  color: #fff;
}
.account-avatar-initials {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.account-label {
  line-height: 1;
}

.app-nav {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.nav-tab {
  border: 0;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab:active { transform: scale(0.98); }
.nav-tab.active {
  color: var(--ink);
  background: #ececef;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.ghost-chip, .gear-btn, .mini-btn, .secondary, .start-btn, .run-btn, .nav-tab, .account-chip {
  font: inherit;
}
.ghost-chip {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--mute);
  font-size: 13px;
  font-weight: 500;
}
.ghost-chip:hover { color: var(--ink); }
.gear-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.gear-btn:hover { color: var(--ink); }

.portal-stage {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 15px 0 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: calc(100vh - var(--brand-bar-h));
  justify-content: flex-start;
  transition: padding 0.45s ease, justify-content 0.45s ease;
}
.portal-stage.stage-cold {
  padding-top: 20px;
}
.portal-stage.stage-ready {
  justify-content: flex-start;
  padding-top: 20px;
}
.search-stack {
  width: min(var(--search-w), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.portal-guide {
  grid-column: 2;
  margin: 10px 0 0;
  text-align: center;
  color: var(--mute);
  font-size: 14px;
  line-height: 1.4;
  transition: opacity 0.18s ease, transform 0.18s ease, height 0.18s ease, margin 0.18s ease;
  will-change: opacity, transform;
}
.portal-guide.is-faded {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}
.portal-guide.is-hidden {
  visibility: hidden;
  height: 0;
  margin: 0;
  overflow: hidden;
  transform: none;
}
.portal-search {
  --search-side: 84px;
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: var(--search-side) minmax(0, 1fr) var(--search-side);
  column-gap: 6px;
  align-items: center;
  justify-items: stretch;
}
.portal-stage.stage-ready .portal-search {
  position: sticky;
  top: var(--sticky-search-top);
  z-index: 45;
  width: 100%;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.portal-stage.stage-ready .portal-guide {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  height: 0;
  margin: 0;
  overflow: hidden;
}
.search-process {
  width: var(--process-w);
  max-width: var(--process-w);
  margin: 0 auto;
  display: grid;
  gap: 4px;
  justify-items: stretch;
  text-align: left;
  align-self: center;
}
.portal-stage.stage-ready .search-process {
  margin-top: 2px;
}
.search-process.hidden { display: none !important; }
.search-process .snapshot-process {
  width: 100%;
  max-width: 100%;
  text-align: left;
  overflow: visible;
}
.search-process .snap-group-toggle {
  justify-content: flex-start;
  min-width: 0;
  align-items: flex-start;
}
.search-process .snap-group-body {
  text-align: left;
}
.search-process .snap-activity-log {
  width: 100%;
  max-width: 100%;
  overflow: visible;
}
.portal-search-row {
  display: contents;
}
.portal-search-row .search-icon {
  grid-column: 1;
  justify-self: center;
  align-self: center;
}
.portal-search-row .search-shell {
  grid-column: 2;
  min-width: 0;
}
.portal-search-row .start-btn {
  grid-column: 3;
  justify-self: center;
  align-self: center;
}
.settings-sheet select {
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
  width: 100%;
}
.account-auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.account-auth-actions .run-btn,
.account-auth-actions .secondary {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
}
.search-shell { position: relative; }
.search-icon {
  width: 16px;
  height: 16px;
  color: #9a9aa3;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  pointer-events: none;
}
.search-icon svg { display: block; }
.search-shell input {
  width: 100%;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  background: #fff;
}
.search-shell input::placeholder {
  color: #a8a8b3;
  opacity: 1;
}
.search-shell input:focus {
  outline: none;
  border-color: #cfcfcf;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.start-btn, .run-btn {
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.start-btn {
  display: inline-grid;
  place-items: center;
  justify-items: center;
  align-items: center;
  min-width: 84px;
  width: 84px;
  height: 42px;
  position: relative;
  background: var(--accent);
  color: #fff;
  border: 1.5px solid transparent;
  box-shadow: none;
  padding: 0;
}
.start-btn .start-label {
  line-height: 1;
}
.start-btn .start-spinner {
  display: none;
  width: 22px;
  height: 22px;
  position: absolute;
  inset: 0;
  margin: auto;
}
.start-btn .start-spinner svg {
  width: 22px;
  height: 22px;
  display: block;
  animation: start-spin 0.85s linear infinite;
}
.start-btn .start-ring-track {
  stroke: rgba(37, 99, 235, 0.18);
  stroke-width: 2.2;
}
.start-btn .start-ring-arc {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 18 40;
  stroke-dashoffset: 0;
}
.start-btn .start-check {
  display: none;
  width: 13px;
  height: 13px;
  place-items: center;
  color: var(--accent);
  position: absolute;
  inset: 0;
  margin: auto;
}
.start-btn .start-check svg { display: block; }
.start-btn.is-running {
  background: transparent;
  border-color: transparent;
  color: transparent;
  box-shadow: none;
  min-width: 42px;
  width: 42px;
  padding: 0;
}
.start-btn.is-running .start-label { visibility: hidden; }
.start-btn.is-running .start-check { display: none; }
.start-btn.is-running .start-spinner { display: block; }
.start-btn.is-ready {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  cursor: default;
  min-width: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  box-shadow: none;
}
.start-btn.is-ready .start-label { display: none; }
.start-btn.is-ready .start-check { display: grid; }
.start-btn.is-ready .start-spinner { display: none; }
.start-btn.is-error {
  background: #fde8e6;
  border-color: transparent;
  color: #a1281f;
}
.start-btn.is-error .start-spinner { display: none; }
.start-btn.is-error .start-check { display: none; }
@keyframes start-spin {
  to { transform: rotate(360deg); }
}
.start-btn:disabled, .run-btn:disabled {
  background: #d7d7d7;
  color: #f5f5f5;
  cursor: not-allowed;
  border-color: transparent;
}
.start-btn:disabled.is-running {
  background: transparent;
  border-color: transparent;
  cursor: wait;
}
.start-btn:disabled.is-ready {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  cursor: default;
}
.portal-toast {
  display: none !important;
}
.snapshot-address { margin: 6px 0 0; color: var(--mute); font-size: 13px; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--soft);
  color: var(--mute);
  font-size: 12px;
  white-space: nowrap;
}
.pill.running,
.pill.snap-running {
  background: #fff6db;
  color: #8a6400;
  animation: pulse 1.2s ease-in-out infinite;
}
.pill.ready,
.pill.snap-ready {
  background: #e5f6ea;
  color: #1f6b38;
  animation: none;
}
.pill.snap-partial {
  background: #fff6db;
  color: #8a6400;
  animation: none;
}
.pill.snap-error {
  background: #fde8e6;
  color: #a1281f;
  animation: none;
}
.pill.snap-idle {
  background: var(--soft);
  color: var(--mute);
}

.snapshot-process {
  margin-top: 0;
  border: 0;
  background: transparent;
  padding: 0;
}
.snap-thinking {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(90deg, #9a9aa8 0%, #1a1a1a 40%, #9a9aa8 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: think-shimmer 1.6s linear infinite, snap-in 0.28s ease both;
  overflow: visible;
  white-space: normal;
  max-width: 100%;
  line-height: 1.35;
}
.snap-thinking.hidden { display: none !important; }
@keyframes think-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.snap-activity-log {
  display: grid;
  gap: 2px;
  max-height: none;
  margin: 0;
}
.snap-group {
  border: 0;
  background: transparent;
  padding: 0;
  animation: snap-in 0.32s ease both;
  min-width: 0;
}
@keyframes snap-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.snap-group-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px 0;
  margin: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: #6e6e80;
  min-width: 0;
}
.snap-group-toggle:hover { color: var(--ink); }
.snap-group-label {
  font-size: 13px;
  font-weight: 500;
  color: #4a4a55;
  flex: 0 0 auto;
  padding-top: 1px;
}
.snap-group[data-kind="thought"] .snap-group-label { color: #8a8a96; font-weight: 400; }
.snap-group[data-kind="worked"] .snap-group-label { color: #2f2f37; font-weight: 550; }
.snap-group[data-kind="checked"] .snap-group-label { color: #5a5a66; }
.snap-group-summary {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #9a9aa8;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.35;
  word-break: break-word;
}
.snap-group-chevron {
  font-size: 11px;
  color: #b0b0b8;
  flex: 0 0 auto;
  padding-top: 2px;
}
.snap-closing {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: #5a5a66;
  animation: snap-in 0.32s ease both;
}
.snap-closing.hidden { display: none !important; }
.snap-group-body {
  display: none;
  padding: 2px 0 6px 14px;
}
.snap-group.open .snap-group-body { display: grid; gap: 4px; }
.snap-group.open .snap-group-chevron { transform: rotate(90deg); }
.snap-line {
  font-size: 12.5px;
  line-height: 1.4;
  color: #3d3d47;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}
.snap-line .snap-role {
  color: #9a9aa8;
  margin-right: 6px;
  font-size: 11px;
}
.snap-line.muted-line { color: #8a8a96; }

.chat-head.compact h3 {
  margin: 4px 0 0;
  font-size: 15px;
}
.search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.08);
  z-index: 30;
  max-height: 300px;
  overflow: auto;
}
.dropdown-label {
  padding: 8px 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
}
.dropdown-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--soft);
  font: inherit;
}
.dropdown-item:hover { background: var(--soft); }
.dropdown-item.blocked { color: var(--disabled); cursor: not-allowed; }
.dropdown-item strong { font-size: 14px; }
.dropdown-item span { font-size: 12px; color: var(--mute); }

.snapshot-panel, .config-panel, .run-chat {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.94);
  padding: 18px;
  animation: rise 0.45s ease both;
}
.snapshot-head, .chat-head, .config-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}
.snapshot-panel h2, .run-chat h3, .config-block h3 {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 600;
}

.snap-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}
.snap-card.snap-wide { grid-column: 1 / -1; }
.snap-card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}
.snap-list {
  margin: 0;
  padding-left: 16px;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
}
.snap-list.numbered { padding-left: 18px; }
.snap-list .placeholder { color: var(--mute); font-style: italic; }

.config-panel { display: grid; gap: 22px; }
.config-block { display: grid; gap: 10px; }
.config-value { font-size: 13px; color: var(--mute); text-align: right; }
.muted { margin: 0; color: var(--mute); font-size: 13px; }
.range {
  width: 100%;
  accent-color: var(--ink);
}
.tick-row {
  display: grid;
  gap: 8px;
  font-size: 11px;
  color: var(--mute);
}
.tick-row.three { grid-template-columns: repeat(3, 1fr); }
.scope-ticks {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}
.scope-tick {
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
  color: var(--mute);
}
.scope-tick strong {
  display: block;
  font-size: 11px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 2px;
}
.scope-tick.disabled strong,
.scope-tick.disabled { color: var(--disabled); }

.addon-list { display: grid; gap: 8px; }
.addon-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.addon-row.disabled {
  opacity: 0.55;
  background: var(--soft);
}
.addon-row label {
  display: grid;
  gap: 2px;
  font-size: 13px;
}
.addon-row .dev-tag {
  font-size: 11px;
  color: var(--mute);
}
.upload-box {
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--soft);
}
.upload-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
}
.run-btn { width: 100%; height: 48px; }

.run-chat { min-height: 280px; }
.chat-thread {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
}
.msg { animation: fadeSlide 0.25s ease both; }
.msg .role { font-size: 12px; color: var(--mute); margin-bottom: 4px; }
.msg .bubble {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.45;
}
.msg.user .bubble { background: var(--soft); }
.msg.progress .bubble { color: #333; }
.thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--mute);
  font-size: 13px;
}
.thinking i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #999;
  animation: bounce 1.1s infinite ease-in-out;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
.report-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.report-links a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
}
.msg-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.msg-links a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
}
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.msg-actions .chat-action {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--panel, #fff);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.msg-actions .chat-action:disabled {
  opacity: 0.55;
  cursor: default;
}

.cursor-bubble {
  position: fixed;
  z-index: 50;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}

.settings-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 520px;
  width: calc(100% - 32px);
}
.settings-modal::backdrop { background: rgba(0,0,0,0.28); }
.settings-sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 16px;
}
.settings-sheet header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-sheet h2 { margin: 0; font-size: 18px; }
.settings-sheet h3 { margin: 0 0 8px; font-size: 14px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-advanced {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}
.settings-advanced > summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 10px;
}
.secondary, .mini-btn {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.settings-out {
  margin: 10px 0 0;
  padding: 10px;
  background: var(--soft);
  border-radius: 10px;
  max-height: 160px;
  overflow: auto;
  font-size: 11px;
  white-space: pre-wrap;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.scope-hint { margin-top: 4px; }

.workspace-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  gap: 0;
  min-height: calc(100vh - var(--brand-bar-h));
  padding-top: 12px;
  background: #fafafa;
}
.ws-nav, .ws-context {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
}
.ws-context {
  border-right: 0;
  border-left: 1px solid var(--line);
}
.ws-brand {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
}
.ws-sub {
  margin: 4px 0 16px;
  color: var(--mute);
  font-size: 12px;
}
.ws-nav-list {
  display: grid;
  gap: 4px;
}
.ws-nav-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 10px;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.ws-nav-item em {
  font-style: normal;
  font-size: 10px;
  color: var(--mute);
  white-space: nowrap;
}
.ws-nav-item:hover { background: var(--soft); }
.ws-nav-item.active {
  background: var(--soft);
  font-weight: 600;
}
.ws-main {
  padding: 24px 28px 48px;
  overflow: auto;
}
.ws-main-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.ws-main-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 600;
}
.ws-lead {
  margin: 0 0 18px;
  color: #333;
  line-height: 1.5;
  max-width: 62ch;
}
.ws-placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.ws-live-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.ws-live-grid article {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.ws-live-grid h4 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--mute);
}
.ws-live-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.ws-live-list li {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.ws-live-list .ws-live-links {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.ws-live-list .ws-live-links a {
  font-size: 12px;
}
.pill.ws-status-live { background: #e7f2ea; color: #1f4d2c; }
.ws-ph-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  min-height: 140px;
}
.ws-ph-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
}
.ws-ph-card .dev-tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 11px;
  color: var(--mute);
}
.ws-context h3 {
  margin: 6px 0 10px;
  font-size: 16px;
  line-height: 1.35;
}
.ws-context-meta {
  margin: 14px 0;
  padding-left: 16px;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
}
.ws-go-search { margin-top: 8px; width: 100%; }
.pill.ws-status-hypothesis { background: #f3efe6; }
.pill.ws-status-coming-soon { background: #eef1f5; }
.pill.ws-status-in-development { background: var(--soft); }

/* Phase 10 — Quick Search packs + Workspace lock */
.nav-tab-workspace {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-tab-workspace.locked {
  opacity: 0.72;
}
.nav-lock {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  position: relative;
  display: inline-block;
}
.nav-lock::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: -5px;
  height: 6px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.nav-lock.hidden { display: none; }

.pack-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.pack-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pack-card.selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.pack-card.locked {
  background: #f6f4ef;
  color: #5c574e;
}
.pack-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.pack-card-top strong {
  font-size: 16px;
}
.pack-en {
  font-size: 12px;
  color: var(--mute);
}
.pack-lock {
  margin-left: auto;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  position: relative;
}
.pack-lock::before {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: -4px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}
.pack-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  flex: 1;
}
.pack-card-actions {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
}
.pack-price { font-weight: 600; }
.pack-sub, .pack-status { color: var(--mute); }

.pro-config {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.ws-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(247, 244, 238, 0.82);
  backdrop-filter: blur(2px);
  padding: 24px;
}
.ws-lock-overlay.hidden { display: none; }
.workspace-shell { position: relative; }
.ws-lock-card {
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 28px 24px;
  display: grid;
  gap: 12px;
}
.ws-lock-card h2 {
  margin: 0;
  font-size: 22px;
}
.ws-lock-card .run-btn { width: 100%; }
.ws-canvas-placeholder {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.ws-canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.ws-canvas-toolbar a.mini-btn {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
}
.ws-canvas-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  margin-top: 12px;
}
.ws-canvas-chapters {
  display: grid;
  gap: 14px;
}
.ws-chapter {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.ws-chapter.dragging { opacity: 0.55; }
.ws-chapter.drag-over {
  outline: 1px dashed var(--ink);
  outline-offset: 4px;
}
.ws-chapter-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.ws-chapter-head h4 {
  margin: 0;
  flex: 1;
  font-size: 15px;
}
.ws-drag-handle {
  cursor: grab;
  user-select: none;
  color: var(--mute);
  font-size: 14px;
  letter-spacing: -2px;
  padding-right: 4px;
}
.ws-drag-handle:active { cursor: grabbing; }
.ws-chapter-body {
  margin: 8px 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
  white-space: pre-wrap;
}
.ws-chapter-bullets {
  margin: 0 0 10px 18px;
  font-size: 13px;
  color: #333;
}
.ws-chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mini-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  cursor: pointer;
}
.ws-markup-note {
  margin: 6px 0 0;
  font-size: 12px;
}
.ws-canvas-versions h4 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mute);
}
.ws-canvas-versions .mini-btn {
  margin-bottom: 10px;
}

.account-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.account-pack-unlocks {
  display: grid;
  gap: 8px;
}
.account-pack-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

@media (max-width: 860px) {
  .portal-search {
    width: 100%;
    --search-side: 72px;
  }
  .portal-stage.stage-ready .portal-search {
    top: var(--sticky-search-top);
    width: 100%;
  }
  .search-stack { width: min(var(--search-w), calc(100% - 8px)); }
  .snapshot-grid { grid-template-columns: 1fr; }
  .scope-ticks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tick-row.three { grid-template-columns: 1fr; }
  .brand-bar { padding: 0 12px 2px; }
  .brand-mark { font-size: 15px; margin: 0; }
  .top-actions { margin: 0; }
  .workspace-shell {
    grid-template-columns: 1fr;
    padding-top: 12px;
  }
  .ws-nav, .ws-context { border: 0; border-bottom: 1px solid var(--line); }
  .ws-placeholder-grid { grid-template-columns: 1fr; }
  .pack-cards { grid-template-columns: 1fr; }
  .ws-canvas-grid { grid-template-columns: 1fr; }
}

/* —— Phone-first ArchMind (≤640px) —— */
.ws-nav-mobile-bar { display: none; }
.mobile-bottom-nav { display: none; }

@media (max-width: 640px) {
  :root {
    --brand-bar-h: 56px;
    --mobile-nav-h: calc(56px + env(safe-area-inset-bottom, 0px));
    --sticky-search-top: calc(var(--brand-bar-h) + 10px);
  }

  .portal-body {
    padding-top: calc(var(--brand-bar-h) + env(safe-area-inset-top, 0px));
    padding-bottom: var(--mobile-nav-h);
  }

  .brand-bar {
    height: auto;
    min-height: calc(var(--brand-bar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 6px;
    grid-template-columns: 1fr auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(13, 13, 13, 0.06);
  }
  .brand-bar .app-nav { display: none; }
  .brand-mark { font-size: 17px; letter-spacing: -0.04em; }
  /* Hide "Account" text (bottom tab covers it); keep £ balance visible */
  .account-chip:not(.balance-chip) .account-label { display: none; }
  .balance-chip .account-label {
    display: inline;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
  }
  .account-chip { min-height: 44px; padding: 0 10px; border-radius: 12px; }
  .gear-btn { min-width: 44px; min-height: 44px; border-radius: 12px; }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    min-height: var(--mobile-nav-h);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(13, 13, 13, 0.08);
    box-shadow: 0 -8px 24px rgba(13, 13, 13, 0.06);
  }
  .mobile-tab {
    appearance: none;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    color: var(--mute);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    border-radius: 12px;
  }
  .mobile-tab.active {
    color: var(--ink);
    background: var(--soft);
  }
  .mobile-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .mobile-tab-ico { display: grid; place-items: center; }

  .portal-stage {
    padding-left: 12px;
    padding-right: 12px;
  }
  .search-stack { width: 100%; }
  .portal-search, .portal-stage.stage-ready .portal-search {
    width: 100%;
    left: 0;
    transform: none;
    padding: 0 12px;
  }
  .portal-search-row {
    gap: 8px;
  }
  .start-btn {
    min-width: 52px;
    min-height: 48px;
    border-radius: 14px;
  }
  .search-shell input {
    font-size: 16px; /* avoid iOS zoom */
    min-height: 48px;
  }

  .snapshot-panel { padding: 12px 0 24px; }
  .snapshot-head h2 { font-size: 1.25rem; }
  .snap-card {
    border-radius: 14px;
    padding: 12px 14px;
  }
  .snap-collapsible summary {
    cursor: pointer;
    font-weight: 650;
    list-style: none;
  }
  .snap-collapsible summary::-webkit-details-marker { display: none; }
  .snap-card[data-block="findings"] {
    order: -1;
    border-color: rgba(37, 99, 235, 0.25);
  }

  .workspace-shell {
    padding: 8px 12px 24px;
    gap: 12px;
  }
  .ws-nav-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
  }
  .ws-nav-toggle { min-height: 44px; border-radius: 12px; }
  .ws-nav-current { font-size: 13px; color: var(--mute); font-weight: 600; }
  .ws-brand, .ws-sub { display: none; }
  .ws-nav .ws-nav-list { display: none; }
  .ws-nav.is-open .ws-nav-list {
    display: grid;
    gap: 4px;
    margin-top: 8px;
  }
  .ws-nav-item {
    min-height: 48px;
    border-radius: 12px;
    padding: 10px 12px;
  }
  .ws-context {
    order: 3;
    border-radius: 14px;
    background: var(--soft);
    padding: 14px;
  }
  .ws-go-search { min-height: 44px; width: 100%; border-radius: 12px; }

  .react-account-sheet {
    align-items: end;
    padding: 0;
  }
  .react-account-card {
    width: 100%;
    max-height: min(88vh, 760px);
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
}

/* Landscape phone / short height */
@media (max-width: 960px) and (orientation: landscape) {
  :root {
    --brand-bar-h: 48px;
    --mobile-nav-h: calc(48px + env(safe-area-inset-bottom, 0px));
  }
  .brand-bar {
    min-height: calc(var(--brand-bar-h) + env(safe-area-inset-top, 0px));
  }
  .mobile-bottom-nav {
    min-height: var(--mobile-nav-h);
    padding-top: 2px;
    padding-bottom: calc(2px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-tab { min-height: 40px; font-size: 10px; gap: 0; }
  .mobile-tab-ico svg { width: 18px; height: 18px; }
  .portal-stage.stage-ready .portal-search {
    top: calc(var(--brand-bar-h) + 6px);
  }
  .snapshot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .snap-wide { grid-column: 1 / -1; }
  .workspace-shell {
    grid-template-columns: minmax(180px, 32%) 1fr;
  }
  .ws-context { display: none; }
}

@media (min-width: 641px) {
  .ws-nav-mobile-bar { display: none !important; }
  .mobile-bottom-nav { display: none !important; }
}

