:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1a1d24;
  --muted: #5c6578;
  --line: #e2e5ec;
  --user: #1f2a3a;
  --user-ink: #f5f7fb;
  --assist: #ffffff;
  --accent: #2a6f6a;
  --warn: #9a4b2e;
  --radius: 18px;
  --composer-radius: 24px;
  --max: 720px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  background:
    radial-gradient(900px 420px at 50% -20%, #e8eef2 0%, transparent 70%),
    var(--bg);
  transition: max-width 0.25s ease;
}

.app.story-open {
  max-width: 1280px;
}

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.app.story-open .chat-column {
  flex: 1 1 48%;
  border-right: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.locale-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

.locale-select {
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  max-width: 14rem;
  min-width: 9rem;
}

.docs-flourish {
  border-left: 3px solid #0f766e;
  padding-left: 0.75rem;
  margin-bottom: 1rem;
}

/* Shear guardrail: fixed-volume projection — string length must not buckle layout. */
[data-concept-id],
#loginTitle,
#loginLead,
.login-lead,
.docs-title,
.docs-section h2,
.docs-section p {
  overflow: hidden;
  text-overflow: ellipsis;
}

#loginTitle,
.docs-title {
  max-height: 3.2em;
}

#loginLead,
.login-lead,
.docs-section p {
  max-height: 8.5em;
}

.login-card,
.docs-section {
  contain: layout;
}

html[dir="rtl"] .docs-flourish {
  border-left: none;
  border-right: 3px solid #0f766e;
  padding-left: 0;
  padding-right: 0.75rem;
}

html[dir="rtl"] .docs-critical,
html[dir="rtl"] .docs-slash {
  border-left: none;
  border-right: 3px solid #b45309;
  padding-left: 0;
  padding-right: 0.75rem;
}

html[dir="rtl"] .docs-slash {
  border-right-color: #9f1239;
}

html[dir="rtl"] .docs-table th,
html[dir="rtl"] .docs-table td {
  text-align: right;
}

html[dir="rtl"] .app.story-open .chat-column {
  border-right: none;
  border-left: 1px solid var(--line);
}

.story-toggle[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--accent);
  background: rgba(42, 111, 106, 0.08);
}

/* Research story layer — secondary to chat */
.story-panel {
  flex: 1 1 52%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(165deg, #f7faf9 0%, #eef3f4 42%, #f4f5f7 100%);
  overflow: hidden;
}

.story-panel[hidden] {
  display: none !important;
}

.story-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.55rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  flex-shrink: 0;
}

.story-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
}

.story-page-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.story-hero {
  padding: 0.85rem 1rem 0.55rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.story-hero h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.story-sub {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.story-thesis {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 42rem;
}

.story-pillars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
}

.story-pillars span {
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(42, 111, 106, 0.1);
  border: 1px solid rgba(42, 111, 106, 0.18);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.story-ext {
  margin: 0;
  font-size: 0.78rem;
}

.story-ext a { color: var(--accent); }

.story-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  max-height: 9.5rem;
  overflow: auto;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.45);
}

.story-path-label {
  flex: 1 0 100%;
  margin: 0.25rem 0 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.story-nav-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.story-nav-btn.happy {
  border-color: rgba(42, 111, 106, 0.35);
  color: var(--ink);
}

.story-nav-btn.active,
.story-nav-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: rgba(42, 111, 106, 0.08);
}

.story-body {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1.1rem 2rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.story-body h1 { font-size: 1.25rem; margin: 0 0 0.65rem; }
.story-body h2 { font-size: 1.05rem; margin: 1.1rem 0 0.45rem; }
.story-body h3 { font-size: 0.95rem; margin: 0.95rem 0 0.35rem; }
.story-body h4 { font-size: 0.88rem; margin: 0.8rem 0 0.3rem; }
.story-body p { margin: 0 0 0.7rem; }
.story-body ul, .story-body ol { margin: 0 0 0.75rem 1.1rem; padding: 0; }
.story-body li { margin: 0.2rem 0; }
.story-body blockquote {
  margin: 0 0 0.85rem;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: rgba(42, 111, 106, 0.06);
  color: var(--ink);
}
.story-body code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.8em;
  background: #eef1f5;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}
.story-body pre {
  overflow: auto;
  background: #1a1d24;
  color: #e8ecf2;
  padding: 0.75rem;
  border-radius: 10px;
  font-size: 0.75rem;
}
.story-body a { color: var(--accent); }
.story-note {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(42, 111, 106, 0.08);
  border: 1px solid rgba(42, 111, 106, 0.16);
}
.story-table-wrap {
  overflow: auto;
  margin: 0 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.story-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.78rem;
}
.story-body th, .story-body td {
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.story-body th { background: #f0f3f6; font-weight: 650; }
.story-media {
  margin: 0 0 1rem;
}
.story-img, .story-video {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  background: #0f1418;
  border: 1px solid var(--line);
}
.story-media figcaption {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.story-loading, .story-error { color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.brand-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.ghost-btn:hover { color: var(--ink); border-color: #c8ceda; }

.chat-shell {
  flex: 1;
  overflow: auto;
  padding: 1rem 1rem 0.5rem;
}

.message-list {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 1rem;
}

.msg {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  max-width: 100%;
}

.msg.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #dfe8e6;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.msg.user .avatar {
  background: var(--user);
  color: var(--user-ink);
}

.bubble {
  background: var(--assist);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  max-width: min(100%, 560px);
  line-height: 1.45;
  box-shadow: 0 1px 0 rgba(26, 29, 36, 0.03);
}

.msg.user .bubble {
  background: var(--user);
  color: var(--user-ink);
  border-color: transparent;
}

.bubble p { margin: 0 0 0.55rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble em { font-style: italic; color: inherit; opacity: 0.92; }

.bubble .meta {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.msg.user .bubble .meta { color: rgba(245, 247, 251, 0.65); }

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.attach-preview span {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
}

.msg.user .attach-preview span {
  background: rgba(255, 255, 255, 0.12);
}

.raw-details {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.raw-details summary {
  cursor: pointer;
  user-select: none;
}

.raw-details pre {
  margin: 0.4rem 0 0;
  padding: 0.55rem;
  background: #f0f2f6;
  border-radius: 8px;
  overflow: auto;
  max-height: 12rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem;
  color: #334;
}

.typing {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
  padding: 0.2rem 0;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  animation: blink 1.1s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

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

.composer-wrap {
  flex-shrink: 0;
  padding: 0.35rem 1rem 0.85rem;
  background: linear-gradient(180deg, transparent, var(--bg) 28%);
}

.frontier-suggest {
  max-width: var(--max);
  margin: 0.35rem auto 0.65rem;
  padding: 0 0.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-start;
}

.frontier-suggest[hidden] { display: none !important; }

.frontier-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.55rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.frontier-chip:hover {
  border-color: var(--accent, #3d6b5a);
  background: color-mix(in srgb, var(--surface) 85%, var(--accent, #3d6b5a) 15%);
}

.frontier-chip:disabled {
  opacity: 0.55;
  cursor: wait;
}

.attach-chips {
  max-width: var(--max);
  margin: 0 auto 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.attach-chips[hidden], .ground-bar[hidden] { display: none !important; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  color: var(--muted);
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}

.ground-bar {
  max-width: var(--max);
  margin: 0 auto 0.45rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.ground-bar input {
  width: 100%;
  border: 1px solid #d7b3a4;
  background: #fff8f5;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
}

.jit-bar {
  max-width: var(--max);
  margin: 0 auto 0.45rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0.45rem;
}

.jit-bar input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
}

.jit-bar input:focus {
  outline: 2px solid rgba(42, 111, 106, 0.35);
  border-color: var(--accent);
}

.status-lock {
  max-width: var(--max);
  margin: 0 auto 0.4rem;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: rgba(42, 111, 106, 0.08);
  color: var(--ink);
  font-size: 0.88rem;
}

.status-lock[hidden] { display: none !important; }

.composer {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--composer-radius);
  padding: 0.45rem 0.5rem 0.45rem 0.35rem;
  box-shadow: 0 8px 28px rgba(26, 29, 36, 0.06);
}

.composer.drag-hot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 111, 106, 0.12);
}

.icon-btn, .send-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover { color: var(--ink); background: #f0f2f6; }

.send-btn {
  background: var(--accent);
  color: #fff;
}

.send-btn:hover:not(:disabled) { filter: brightness(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#textInput {
  flex: 1;
  border: 0;
  resize: none;
  outline: none;
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.4;
  max-height: 160px;
  padding: 0.55rem 0.25rem;
  background: transparent;
  color: var(--ink);
}

.composer-hint {
  max-width: var(--max);
  margin: 0.4rem auto 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.app.drop-target::after {
  content: "Drop files to attach";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(244, 245, 247, 0.82);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 50;
}

/* Past sessions drawer */
.app.sessions-open {
  max-width: 1100px;
}

.sessions-drawer {
  flex: 0 0 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  overflow: hidden;
}

.sessions-drawer[hidden] {
  display: none !important;
}

.sessions-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 0.9rem 0.55rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sessions-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.55rem 1rem;
}

.session-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.6rem;
  border-radius: 12px;
  border: 1px solid transparent;
  margin-bottom: 0.35rem;
}

.session-row:hover {
  border-color: var(--line);
  background: rgba(42, 111, 106, 0.05);
}

.session-row.active {
  border-color: rgba(42, 111, 106, 0.35);
  background: rgba(42, 111, 106, 0.08);
}

.session-row-title {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
}

.session-row-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.session-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.session-row-actions button {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.session-row-actions button.primary {
  border-color: rgba(42, 111, 106, 0.45);
  color: var(--accent);
  background: rgba(42, 111, 106, 0.08);
}

.session-row-actions button:hover {
  border-color: var(--accent);
}

.sessions-empty {
  margin: 1rem 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .app.story-open {
    max-width: 100%;
  }
  .app.story-open .workspace {
    flex-direction: column;
  }
  .app.story-open .chat-column {
    flex: 0 0 42%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .story-panel {
    flex: 1 1 58%;
  }
  .app.sessions-open .workspace {
    flex-direction: column;
  }
  .sessions-drawer {
    flex: 0 0 auto;
    max-height: 40%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .ground-bar { grid-template-columns: 1fr; }
  .jit-bar { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .brand-sub { display: none; }
  .app.story-open .chat-column { flex: 0 0 38%; }
  .login-loc-row { grid-template-columns: 1fr; }
}

/* Wallet + location login (no password) */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(26, 29, 36, 0.42);
  backdrop-filter: blur(4px);
}

.login-gate[hidden] { display: none !important; }

.login-card {
  width: min(520px, 96vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.15rem;
  box-shadow: 0 18px 48px rgba(26, 29, 36, 0.16);
}

.login-locale-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
}

.login-card[dir="rtl"] .login-locale-row {
  justify-content: flex-start;
}

.login-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.login-lead, .login-hint {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.login-hint { margin: 0.85rem 0 0; font-size: 0.78rem; }

.login-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.login-tab {
  flex: 1;
  border: 1px solid var(--line);
  background: #fafbfc;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
}

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

.login-consent {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0.35rem 0 0.75rem;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--ink);
  cursor: pointer;
}

.login-consent input[type="checkbox"] {
  width: auto;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.login-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.55rem 0 0.28rem;
  font-weight: 650;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: #fafbfc;
}

.login-card input:focus {
  outline: 2px solid rgba(42, 111, 106, 0.35);
  border-color: var(--accent);
}

.login-loc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.login-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.login-submit {
  min-width: 7.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  padding: 0 1.1rem;
}

.login-status {
  margin: 0.75rem 0 0;
  font-size: 0.84rem;
  color: var(--warn);
}

.login-status.ok { color: var(--accent); }

.profile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 35;
  width: min(360px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 1rem 1.1rem;
  box-shadow: -12px 0 36px rgba(26, 29, 36, 0.1);
  overflow: auto;
}

.profile-drawer[hidden] { display: none !important; }

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.profile-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.profile-dl {
  margin: 0;
}

.profile-dl dt {
  margin: 0.7rem 0 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.profile-dl dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-all;
  line-height: 1.4;
}

.profile-actions {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.profile-wallet-ops {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.profile-wallet-ops h3,
.profile-game-use h3,
.profile-spends h3,
.profile-domain h3 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-wallet-ops input {
  width: 100%;
  margin: 0.2rem 0 0.55rem;
  box-sizing: border-box;
}

.profile-wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.profile-game-use,
.profile-spends {
  margin-top: 0.85rem;
}

#profilePegHint {
  margin: 0 0 0.65rem;
}

.login-optional-domain {
  margin: 0.85rem 0 0.4rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.login-optional-domain summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 650;
}

.login-optional-domain .login-select {
  width: 100%;
  margin-top: 0.45rem;
}

.profile-capture,
.docs-capture-bar {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.docs-capture-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-top: 0;
  border-top: none;
}

.docs-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 36;
  width: min(440px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 1rem 1.1rem;
  box-shadow: -12px 0 36px rgba(26, 29, 36, 0.12);
  overflow: auto;
}

.docs-drawer[hidden] { display: none !important; }

.sandbox-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 37;
  width: min(520px, 100%);
  height: 100%;
  background: #0a0f14;
  color: #c8d2dc;
  border-left: 1px solid #1e2a33;
  padding: 1rem 1.1rem;
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.45);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sandbox-drawer[hidden] { display: none !important; }

.sandbox-drawer .profile-head h2 {
  color: #e8eef2;
  margin: 0;
  font-size: 1rem;
}

.games-drawer {
  z-index: 39;
  width: min(540px, 100%);
}

.games-catalog {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #1e2a33;
  background: #0d141a;
  color: #c8d2dc;
  cursor: pointer;
  font: inherit;
}

.game-card:hover {
  border-color: #3a5a6a;
  background: #121c24;
}

.game-card.is-active {
  border-color: #7dff9a;
  box-shadow: inset 0 0 0 1px rgba(125, 255, 154, 0.25);
}

.game-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e8eef2;
}

.game-card-meta {
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #7a929e;
}

.games-panel {
  border-top: 1px solid #1e2a33;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.games-panel h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #e8eef2;
}

.games-drawer .login-select,
.games-drawer input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

.sandbox-lead {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #9aafbc;
}

.mirror-manifold-canvas {
  width: 100%;
  height: min(420px, 48vh);
  border-radius: 12px;
  background: #04070a;
  border: 1px solid #1e2a33;
  display: block;
}

.sandbox-status {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: #7dff9a;
}

.sandbox-status[data-primitive="VORONOI_SHATTER"] {
  color: #ff4fd0;
}

.sandbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reality-drawer {
  z-index: 38;
  width: min(560px, 100%);
}

.reality-mode-tabs {
  display: flex;
  gap: 0.35rem;
}

.reality-narrative {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #9aafbc;
}

.reality-seed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.reality-seed-grid > div:nth-child(3) {
  grid-column: span 1;
}

.reality-rational-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.reality-rational-row input {
  width: 100%;
}

.cinema-film-meta {
  margin: 0.25rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: #7aa0b0;
  word-break: break-all;
}

#cinemaBeatScrub {
  width: 100%;
  accent-color: #3dff8a;
}

.reality-drawer .login-label {
  display: block;
  margin-top: 0.45rem;
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  color: #8aa0ae;
}

.reality-drawer input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: #0d141a;
  border: 1px solid #1e2a33;
  color: #e8eef2;
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
}

.docs-body .docs-title {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  line-height: 1.35;
}

.docs-section {
  margin-bottom: 1.1rem;
}

.docs-section h2 {
  font-size: 0.88rem;
  margin: 0 0 0.4rem;
}

.docs-section p {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink);
}

.docs-critical {
  border-left: 3px solid #b45309;
  padding-left: 0.75rem;
  background: rgba(180, 83, 9, 0.06);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.docs-slash {
  border-left: 3px solid #9f1239;
  padding-left: 0.75rem;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 0.4rem 0 0.6rem;
}

.docs-table th,
.docs-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.35rem 0.25rem;
  vertical-align: top;
}

.docs-muted { color: var(--muted); font-size: 0.85em; }

.docs-key-box {
  font-size: 0.7rem;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg, #0f1218);
  color: #e8edf5;
  padding: 0.65rem;
  border-radius: 6px;
  max-height: 160px;
  overflow: auto;
}

.docs-export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.onboard-docs {
  max-height: min(42vh, 320px);
  overflow: auto;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}

.onboard-docs .docs-title { font-size: 0.82rem; }

.profile-domain {
  margin-top: 0.85rem;
  font-size: 0.82rem;
}

.profile-domain h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* UMC Director — stagnation red pulse */
.umc-drawer.umc-pulse-stagnant #umcStatus,
#umcStatus.umc-stagnant {
  color: #ff2d55;
  animation: umc-stagnant-pulse 1.1s ease-in-out infinite;
}
@keyframes umc-stagnant-pulse {
  0%, 100% { opacity: 1; text-shadow: 0 0 0 transparent; }
  50% { opacity: 0.55; text-shadow: 0 0 12px rgba(255, 45, 85, 0.85); }
}
.umc-drawer .sandbox-lead { margin-bottom: 0.5rem; }
