:root {
  --bg0: #0b1220;
  --bg1: #121a2b;
  --panel: rgba(18, 28, 46, 0.92);
  --panel-solid: #152033;
  --line: rgba(148, 175, 210, 0.16);
  --text: #e8eef8;
  --muted: #8b9bb3;
  --accent: #2f9e8b;
  --accent-hi: #5fd0bb;
  --accent-dim: rgba(47, 158, 139, 0.16);
  --danger: #e07a6a;
  --warn: #d2b15a;
  --user: linear-gradient(145deg, #1a3a48, #163445);
  --assistant: #101927;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "DM Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --bar-h: 64px;
  --mobile-nav-h: 58px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(47, 158, 139, 0.22), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(64, 110, 180, 0.16), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #0d1524);
}
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.75rem; }
.block { display: block; }
.err { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.logo-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(95, 208, 187, 0.95), rgba(47, 158, 139, 0.75)),
    repeating-linear-gradient(-28deg, transparent, transparent 6px, rgba(255,255,255,0.08) 6px, rgba(255,255,255,0.08) 7px);
  box-shadow: 0 8px 24px rgba(47, 158, 139, 0.28);
}
.logo-mark.small { width: 28px; height: 28px; border-radius: 8px; }

.auth-view { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; }
.auth-shell {
  width: min(860px, 100%);
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; align-items: center;
}
.auth-brand h1 {
  margin: 0.85rem 0 0.45rem; font-size: clamp(2.4rem, 5vw, 3.4rem);
  letter-spacing: -0.04em; font-weight: 700;
}
.auth-brand .lede {
  margin: 0; color: var(--muted); line-height: 1.55; max-width: 30ch; font-size: 1.05rem;
}
.auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 1.4rem 1.35rem; display: grid; gap: 0.8rem; box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.auth-card label, .settings label, .inline-field {
  display: grid; gap: 0.35rem; font-size: 0.86rem; color: var(--muted);
}
.auth-card input, .settings input, .settings select, .composer textarea,
.search-field input, .ask-composer textarea, select, .title-input {
  width: 100%; border: 1px solid var(--line); background: rgba(8, 14, 24, 0.72);
  color: var(--text); border-radius: 12px; padding: 0.7rem 0.8rem;
}
.auth-card input:focus, .settings input:focus, .composer textarea:focus,
.search-field input:focus, .ask-composer textarea:focus, select:focus, .title-input:focus {
  outline: none; border-color: rgba(95, 208, 187, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.auth-actions, .settings-row, .top-actions, .viewer-actions, .ask-bar {
  display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center;
}
label.check { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); }

.app { height: 100%; display: grid; grid-template-rows: var(--bar-h) 1fr; min-height: 0; }
.app-bar {
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  border-bottom: 1px solid var(--line); background: rgba(6, 10, 18, 0.55);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.app-brand { display: flex; gap: 0.7rem; align-items: center; min-width: 160px; }
.app-brand strong { letter-spacing: -0.02em; }
.app-nav { display: flex; gap: 0.35rem; flex: 1; justify-content: center; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 999px; padding: 0.45rem 0.95rem; cursor: pointer;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-btn.active {
  color: var(--accent-hi); border-color: rgba(95, 208, 187, 0.35);
  background: var(--accent-dim);
}
.app-bar-right { display: flex; gap: 0.5rem; align-items: center; }
.pill {
  font-size: 0.72rem; padding: 0.22rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-family: var(--mono);
}
.pill.ok { color: var(--accent-hi); border-color: rgba(95, 208, 187, 0.35); }
.pill.warn { color: var(--warn); }
.pill.err { color: var(--danger); }

.view { min-height: 0; height: 100%; overflow: hidden; }
.mobile-nav { display: none; }

.library-layout {
  height: 100%; display: grid; grid-template-columns: 300px 1fr; min-height: 0;
}
.library-side {
  border-right: 1px solid var(--line); padding: 1rem 0.85rem; overflow: auto;
  background: rgba(6, 10, 18, 0.35);
}
.side-head, .ask-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
}
.side-head h2, .settings-page h2, .profile-editor h3 {
  margin: 0; font-size: 1.1rem; letter-spacing: -0.02em;
}
.search-field { display: block; margin: 0.75rem 0 0.4rem; }
.search-field.compact { margin: 0; min-width: 150px; }
.map-list { display: grid; gap: 0.45rem; margin-top: 0.5rem; }
.folder-group {
  border: 1px solid transparent; border-radius: 12px; overflow: hidden;
}
.folder-group.open { border-color: var(--line); background: rgba(255,255,255,0.02); }
.folder-head {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 0.45rem;
  border: 0; background: transparent; color: var(--text); padding: 0.55rem 0.6rem;
  cursor: pointer; border-radius: 12px;
}
.folder-head:hover { background: rgba(255,255,255,0.04); }
.folder-head .chev { color: var(--muted); width: 1rem; flex: 0 0 auto; }
.folder-head .fname {
  flex: 1; min-width: 0; font-weight: 600; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.folder-head .fcnt {
  font-size: 0.7rem; color: var(--muted); font-family: var(--mono);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.08rem 0.4rem;
}
.folder-body { display: none; padding: 0 0.35rem 0.4rem; }
.folder-group.open .folder-body { display: grid; gap: 0.25rem; }
.map-item {
  text-align: left; width: 100%; border: 1px solid transparent; background: transparent;
  color: var(--text); border-radius: 10px; padding: 0.55rem 0.65rem; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.map-item:hover, .map-item.active {
  background: var(--panel-solid); border-color: var(--line);
}
.map-item.active { box-shadow: inset 0 0 0 1px rgba(95, 208, 187, 0.25); }
.map-item .t {
  display: block; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-item .s {
  display: block; font-size: 0.7rem; color: var(--muted); margin-top: 0.18rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono);
}

.library-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty-state {
  margin: auto; text-align: center; max-width: 34rem; padding: 2rem 1rem; color: var(--muted);
}
.empty-state h2 {
  margin: 0 0 0.5rem; color: var(--text); font-size: 1.45rem; letter-spacing: -0.03em;
}
.empty-state p { margin: 0; line-height: 1.55; }

.map-viewer { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.viewer-head {
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: center;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
}
.viewer-titles h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.viewer-titles p { margin: 0.2rem 0 0; word-break: break-all; }
.viewer-body {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 0.85fr;
}
.browse-body { grid-template-columns: 1.5fr 0.9fr; }
.browse-layout {
  min-width: 0; min-height: 0; display: grid; grid-template-columns: 1.15fr 0.85fr;
  border-right: 1px solid var(--line);
}
.browse-main {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background: rgba(6, 10, 18, 0.2);
}
.browse-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.browse-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; min-width: 0; }
.crumb-sep { color: var(--muted); font-size: 0.75rem; padding: 0 0.15rem; }
.crumb-btn {
  border: 0; background: transparent; color: var(--muted); padding: 0.15rem 0.35rem;
  border-radius: 6px; font-size: 0.78rem; cursor: pointer; max-width: 140px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumb-btn:hover { color: var(--accent-hi); background: rgba(255,255,255,0.04); }
.browse-hint { white-space: nowrap; }

.outline-list {
  flex: 1; overflow: auto; padding: 0.35rem 0.45rem 0.85rem; min-height: 0;
  outline: none;
}
.outline-list:focus { box-shadow: inset 0 0 0 2px rgba(95, 208, 187, 0.18); }
.outline-empty { padding: 1rem; }
.outline-row {
  display: flex; align-items: center; gap: 0.45rem; width: 100%;
  text-align: left; border: 1px solid transparent; background: transparent;
  color: var(--text); border-radius: 10px; padding: 0.52rem 0.65rem;
  margin-bottom: 0.18rem; cursor: pointer; line-height: 1.35;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.outline-row:hover { background: rgba(255,255,255,0.035); }
.outline-row.focused {
  background: rgba(95, 208, 187, 0.14);
  border-color: rgba(95, 208, 187, 0.35);
  box-shadow: 0 0 0 1px rgba(95, 208, 187, 0.12);
}
.outline-row.selected { border-color: rgba(95, 208, 187, 0.25); }
.outline-row.hit .o-text { color: var(--accent-hi); }
.outline-row.root .o-text { font-weight: 650; }
.o-chev {
  width: 1rem; flex: 0 0 auto; color: var(--muted); font-size: 0.82rem; text-align: center;
}
.o-text {
  flex: 1; min-width: 0; font-size: 0.92rem; word-break: break-word;
}
.o-meta {
  flex: 0 0 auto; font-size: 0.68rem; color: var(--muted); font-family: var(--mono);
  white-space: nowrap;
}

.node-detail {
  min-width: 0; min-height: 0; overflow: auto; padding: 0.85rem 0.9rem 1rem;
  background: rgba(8, 12, 20, 0.35);
}
.node-detail h3 {
  margin: 0 0 0.35rem; font-size: 1.05rem; line-height: 1.4; letter-spacing: -0.02em;
  word-break: break-word;
}
.detail-note {
  margin-top: 0.75rem; padding: 0.75rem 0.85rem; border-radius: 12px;
  background: rgba(0,0,0,0.22); border: 1px solid var(--line);
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  font-size: 0.9rem; color: var(--muted);
}
.detail-children { margin-top: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.detail-chip {
  border: 1px solid var(--line); background: rgba(255,255,255,0.03);
  color: var(--text); border-radius: 999px; padding: 0.28rem 0.65rem;
  font-size: 0.82rem; cursor: pointer;
}
.detail-chip:hover { border-color: rgba(95,208,187,0.4); color: var(--accent-hi); }
.detail-sub { margin: 0 0 0.35rem; }

.viewer-stage { min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; }

.seg {
  display: inline-flex; padding: 0.18rem; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(0,0,0,0.22); gap: 0.15rem;
}
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; padding: 0.28rem 0.7rem; font-size: 0.82rem; cursor: pointer;
}
.seg-btn.active {
  background: var(--accent-dim); color: var(--accent-hi);
}

/* legacy tree (unused) */
.tree {
  overflow: auto; padding: 0.85rem 0.75rem 1.4rem; min-height: 0; flex: 1;
  content-visibility: auto;
}
.tree-node { margin: 0; padding: 0; list-style: none; }
.tree-row {
  display: flex; align-items: flex-start; gap: 0.35rem;
  padding: 0.28rem 0.4rem; border-radius: 8px; cursor: default;
}
.tree-row:hover { background: rgba(255,255,255,0.035); }
.tree-row.hit { background: rgba(95, 208, 187, 0.12); }
.tree-toggle {
  width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: pointer; flex: 0 0 auto; line-height: 1;
}
.tree-toggle:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.tree-toggle.leaf { visibility: hidden; }
.tree-text { flex: 1; min-width: 0; line-height: 1.4; word-break: break-word; }
.tree-meta {
  display: inline-flex; gap: 0.3rem; flex-wrap: wrap; margin-left: 0.35rem;
}
.tree-meta span {
  font-size: 0.68rem; padding: 0.05rem 0.35rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-family: var(--mono);
}
.tree-children { margin: 0 0 0 0.85rem; padding: 0 0 0 0.55rem; border-left: 1px solid var(--line); }
.tree-note {
  margin: 0.15rem 0 0.25rem 1.7rem; color: var(--muted); font-size: 0.82rem; line-height: 1.4;
}

.ask-panel {
  border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
  background: rgba(8, 12, 20, 0.35);
}
.ask-head { padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); }
.ask-composer {
  border-top: 1px solid var(--line); padding: 0.7rem 0.8rem 0.85rem;
  display: grid; gap: 0.5rem;
}
.ask-composer textarea { resize: none; min-height: 72px; }
.ask-bar select { width: auto; min-width: 140px; }

.chat-layout { height: 100%; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--line); padding: 0.85rem; overflow: auto;
  background: rgba(0,0,0,0.15);
}
.side-top { display: flex; justify-content: space-between; align-items: center; }
.side-label {
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.conv-list { display: grid; gap: 0.35rem; margin-top: 0.55rem; }
.conv-item {
  text-align: left; border: 1px solid transparent; background: transparent; color: var(--text);
  border-radius: 12px; padding: 0.65rem 0.7rem; cursor: pointer; width: 100%;
}
.conv-item:hover, .conv-item.active { background: var(--panel-solid); border-color: var(--line); }
.conv-item .t {
  display: block; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item .s {
  display: flex; gap: 0.4rem; align-items: center; font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem;
}
.tag {
  display: inline-block; padding: 0.08rem 0.4rem; border-radius: 999px;
  border: 1px solid var(--line); font-family: var(--mono); font-size: 0.66rem;
}
.tag.desktop { color: var(--accent-hi); border-color: rgba(95, 208, 187, 0.35); }
.tag.web { color: #9eb6d8; }

.chat-main { display: flex; flex-direction: column; min-width: 0; padding: 0.85rem 1rem 0.75rem; min-height: 0; }
.chat-top {
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: center;
  padding-bottom: 0.8rem; border-bottom: 1px solid var(--line);
}
.chat-brand { display: flex; gap: 0.75rem; align-items: center; flex: 1; min-width: 0; }
.title-edit { display: flex; gap: 0.45rem; align-items: center; flex: 1; min-width: 0; }
.title-input {
  font-weight: 650; font-size: 1.02rem; letter-spacing: -0.02em; padding: 0.45rem 0.65rem;
}
.inline-field { grid-template-columns: auto 1fr; align-items: center; gap: 0.45rem; }
.inline-field span { white-space: nowrap; }

/* Message stream: clear left/right */
.msg-stream {
  flex: 1; overflow: auto; padding: 1rem 0.35rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  scroll-behavior: smooth;
}
.msg {
  display: flex; width: 100%; max-width: 920px; margin: 0 auto;
  animation: rise 0.22s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }
.msg.system { justify-content: center; }
.msg .bubble {
  max-width: min(720px, 86%); padding: 0.85rem 0.95rem; border-radius: 16px;
  line-height: 1.55; word-break: break-word;
}
.msg.user .bubble {
  background: var(--user); border: 1px solid rgba(95, 208, 187, 0.22);
  border-bottom-right-radius: 6px;
}
.msg.assistant .bubble {
  background: var(--assistant); border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg.system .bubble {
  max-width: none; color: var(--muted); font-size: 0.88rem; border: none;
  background: transparent; text-align: center; padding: 0.35rem 0.6rem;
}
.msg .role {
  display: block; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.35rem; font-family: var(--mono);
}
.msg.user .role { text-align: right; color: var(--accent-hi); }
.msg .body { white-space: pre-wrap; }
.msg .body code {
  font-family: var(--mono); font-size: 0.86em; background: rgba(255,255,255,0.06);
  padding: 0.08rem 0.35rem; border-radius: 6px;
}
.msg .body pre {
  margin: 0.55rem 0; padding: 0.75rem 0.85rem; overflow: auto; border-radius: 10px;
  background: rgba(0,0,0,0.28); border: 1px solid var(--line);
}
.msg .body pre code { background: none; padding: 0; }
.msg .meta {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
  margin-top: 0.55rem; font-size: 0.74rem; color: var(--muted); font-family: var(--mono);
}
.msg .tools { margin-top: 0.55rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.msg .tools span {
  font-size: 0.72rem; padding: 0.18rem 0.45rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-family: var(--mono);
}
.msg .tools span.ok { color: var(--accent-hi); }
.msg .tools span.bad { color: var(--danger); }
.msg .share-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.72rem; cursor: pointer;
}
.msg .share-btn:hover { color: var(--accent-hi); border-color: rgba(95,208,187,0.4); }

.composer { padding-top: 0.55rem; }
.composer-box {
  border: 1px solid var(--line); background: rgba(10, 16, 28, 0.78);
  border-radius: 18px; padding: 0.65rem 0.75rem 0.55rem; box-shadow: var(--shadow);
}
.composer textarea {
  border: 0; background: transparent; resize: none; min-height: 72px;
  padding: 0.35rem 0.25rem; box-shadow: none; width: 100%;
}
.composer textarea:focus { box-shadow: none; border: 0; }
.composer-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding-top: 0.35rem;
}

.settings-page { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 2rem; overflow: auto; height: 100%; }
.settings-split {
  display: grid; grid-template-columns: 280px 1fr; gap: 1rem; max-width: 1100px; align-items: start;
}
.profile-list-panel {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem;
  background: rgba(6,10,18,0.35); position: sticky; top: 0;
}
.profile-list { display: grid; gap: 0.4rem; margin-top: 0.75rem; }
.profile-item {
  text-align: left; width: 100%; border: 1px solid transparent; background: transparent;
  color: var(--text); border-radius: 12px; padding: 0.7rem 0.75rem; cursor: pointer;
}
.profile-item:hover, .profile-item.active {
  background: var(--panel-solid); border-color: var(--line);
}
.profile-item .t { display: block; font-weight: 600; }
.profile-item .s {
  display: block; margin-top: 0.2rem; font-size: 0.72rem; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-item .badge {
  display: inline-block; margin-top: 0.35rem; font-size: 0.66rem;
  color: var(--accent-hi); border: 1px solid rgba(95,208,187,0.35);
  border-radius: 999px; padding: 0.05rem 0.4rem;
}
.settings {
  padding: 1rem 1.05rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 0.7rem;
  box-shadow: var(--shadow);
}
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.settings-grid .span-2 { grid-column: 1 / -1; }

button {
  border: 0; border-radius: 999px; padding: 0.62rem 1.05rem; cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}
button:hover { transform: translateY(-1px); }
button.small { padding: 0.32rem 0.7rem; font-size: 0.82rem; }
button.primary {
  background: linear-gradient(135deg, #49b79f, var(--accent)); color: #041512; font-weight: 650;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }
select { width: auto; min-width: 140px; }
.hide-desktop { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  z-index: 80; max-width: min(520px, 92vw);
  background: rgba(12, 20, 34, 0.96); border: 1px solid rgba(95,208,187,0.35);
  color: var(--text); padding: 0.7rem 1rem; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 0.9rem;
}

/* Public share page */
.share-page {
  min-height: 100%; display: grid; place-items: center; padding: 2rem 1rem;
}
.share-top-nav {
  width: min(760px, 100%); margin: 0 auto 0.75rem; font-size: 0.85rem;
}
.share-top-nav a { color: var(--accent-hi); text-decoration: none; }
.share-top-nav a:hover { text-decoration: underline; }
.share-card {
  width: min(760px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 1.4rem 1.35rem; box-shadow: var(--shadow);
}
.share-card h1 { margin: 0 0 0.35rem; font-size: 1.35rem; letter-spacing: -0.03em; }
.share-card .share-meta { margin: 0 0 1rem; color: var(--muted); font-size: 0.82rem; font-family: var(--mono); }
.share-qa-block { margin-bottom: 1.1rem; }
.share-q-label, .share-a-label {
  margin: 0 0 0.35rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-family: var(--mono);
}
.share-a-label { color: var(--accent-hi); }
.share-q-body, .share-body { line-height: 1.6; word-break: break-word; }
.share-q-body {
  padding: 0.75rem 0.85rem; border-radius: 12px;
  background: rgba(26, 58, 72, 0.35); border: 1px solid rgba(95, 208, 187, 0.18);
}
.share-body {
  padding: 0.75rem 0.85rem; border-radius: 12px;
  background: rgba(0,0,0,0.22); border: 1px solid var(--line);
}
.share-foot { margin-top: 1.2rem; color: var(--muted); font-size: 0.8rem; }

.shares-page {
  display: block; max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem;
  place-items: stretch;
}
.shares-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  margin-bottom: 1.25rem;
}
.shares-brand { display: flex; gap: 0.75rem; align-items: flex-start; }
.shares-brand h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.03em; }
.shares-back { text-decoration: none; white-space: nowrap; }
.share-list { display: grid; gap: 0.85rem; }
.share-card-link { text-decoration: none; color: inherit; display: block; }
.share-card-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 1rem 1.05rem; transition: border-color 0.15s ease, transform 0.12s ease;
}
.share-card-link:hover .share-card-item {
  border-color: rgba(95, 208, 187, 0.35); transform: translateY(-1px);
}
.share-item-title {
  margin: 0 0 0.55rem; font-size: 1rem; color: var(--accent-hi);
}
.share-card-item .share-q { margin: 0 0 0.65rem; font-weight: 600; line-height: 1.45; }
.share-card-item .share-a { margin: 0 0 0.55rem; line-height: 1.45; font-size: 0.92rem; }
.share-meta-line { margin: 0; font-size: 0.74rem; color: var(--muted); font-family: var(--mono); }

.share-gate-prompt { margin: 0 0 0.65rem; font-weight: 600; line-height: 1.45; }
.share-gate-form label { display: block; margin-bottom: 0.55rem; font-size: 0.88rem; }
.share-gate-form input {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.65rem;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
}
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 10, 20, 0.72); }
.modal-card {
  position: relative; z-index: 1; width: min(480px, 100%); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.15rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.share-modal-grid { margin: 0.85rem 0 1rem; }
.shares-manage-page { max-width: 920px; }
.shares-manage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.shares-manage-list { display: flex; flex-direction: column; gap: 0.75rem; }
.share-manage-card {
  display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start;
  padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.02);
}
.share-manage-q { margin: 0 0 0.35rem; font-weight: 600; line-height: 1.4; }
.share-manage-a { margin: 0 0 0.35rem; line-height: 1.4; }
.share-manage-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; flex-shrink: 0; }
.err-text { color: #f87171; }
.shares-link { text-decoration: none; }
.auth-foot { margin: 0.35rem 0 0; text-align: center; }
.auth-foot a { color: var(--accent-hi); }

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { text-align: center; }
  .auth-brand .lede { max-width: none; margin: 0 auto; }
  .auth-brand .logo-mark { margin: 0 auto; }
  .app { grid-template-rows: auto 1fr var(--mobile-nav-h); }
  .app-nav, .app-bar-right .pill { display: none; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem;
    border-top: 1px solid var(--line); background: rgba(6, 10, 18, 0.92);
    padding: 0.4rem 0.55rem calc(0.4rem + env(safe-area-inset-bottom));
  }
  .library-layout, .chat-layout, .settings-split { grid-template-columns: 1fr; }
  .library-side, .sidebar { max-height: 32vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .browse-body { grid-template-columns: 1fr; }
  .browse-layout { grid-template-columns: 1fr; border-right: 0; border-bottom: 1px solid var(--line); }
  .node-detail { max-height: 28vh; }
  .browse-hint { display: none; }
  .ask-panel {
    position: fixed; inset: auto 0 0 0; height: min(72vh, 560px); z-index: 30;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 40px rgba(0,0,0,0.35); transform: translateY(110%);
    transition: transform 0.22s ease; background: #101827;
  }
  .ask-panel.open { transform: none; }
  .hide-desktop { display: inline-flex; }
  .viewer-head { flex-direction: column; align-items: stretch; }
  .viewer-actions { width: 100%; }
  .viewer-actions .search-field { flex: 1; min-width: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .chat-top { flex-direction: column; align-items: stretch; }
  .profile-list-panel { position: static; }
  .msg .bubble { max-width: 92%; }
}
