/* DockEcho app -- design system unified on the Bear reference (bear.app).
   Every font-size / weight / color / radius here traces to the Bear token table
   (round 6). Brand exceptions: accent is our blue (Bear uses red) and the rail
   logo stays our dock-echo mark. */

:root {
  color-scheme: light;
  /* surfaces: rail (darkest warm gray) -> sidebar -> editor (white) */
  --bg: #efefed;
  --rail-bg: #efefed;
  --sidebar-bg: #f5f5f4;
  --surface: #f5f5f4;
  --card: #ffffff;
  --card-sunk: #ececea;
  --text: #3e3e3e;
  --muted: #8a8a88;
  --faint: #8a8a88;
  --blue: #0a84ff;
  --blue-ink: #0060d0;
  --blue-wash: rgba(10, 132, 255, 0.1);
  --red: #c6403f;
  --hairline: #e5e5e3;
  --hairline-strong: #dcdcda;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.16);
  /* Bear seven-step type scale */
  --t-11: 11px;
  --t-xs: 13px;
  --t-sm: 13px;
  --t-base: 15px;
  --t-lg: 17px;
  --t-xl: 20px;
  --t-2xl: 28px;
  --t-hero: 44px;
  /* three line-heights */
  --lh-body: 1.7;
  --lh-ui: 1.4;
  --lh-title: 1.25;
  /* three radii: controls / cards / pills */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 10px;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #2c2c2f;
  --rail-bg: #2c2c2f;
  --sidebar-bg: #252528;
  --surface: #252528;
  --card: #1c1c1e;
  --card-sunk: #2f2f32;
  --text: #d8d8d6;
  --muted: #8a8a88;
  --faint: #8a8a88;
  --blue: #4c9dff;
  --blue-ink: #7bb8ff;
  --blue-wash: rgba(76, 157, 255, 0.14);
  --red: #e05a58;
  --hairline: #38383a;
  --hairline-strong: #454547;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.34);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family:
    -apple-system, "SF Pro Text", "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

p,
h1,
h2 {
  margin: 0;
}

/* ---------- shell grid ---------- */

.app {
  display: grid;
  grid-template-columns: 64px 240px minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--rail-bg);
}

.brand {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border-radius: var(--r);
  color: #fff;
  background: var(--blue);
}

.brand svg {
  width: 22px;
  height: 22px;
  display: block;
}

.rail-btn,
.icon-btn {
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
  background: transparent;
  transition: color 140ms ease, background 140ms ease;
}

.rail-btn {
  width: 40px;
  height: 40px;
}

.icon-btn {
  width: 32px;
  height: 32px;
}

/* Lucide inline icons: 18px UI, 20px in the rail, currentColor */
.icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.rail-btn .icon {
  width: 20px;
  height: 20px;
}

.rail-btn:hover,
.icon-btn:hover {
  color: var(--text);
  background: var(--card-sunk);
}

.rail-btn.active {
  color: var(--blue);
  background: var(--blue-wash);
}

.rail-btn.bottom {
  margin-top: auto;
}

/* ---------- sidebar ---------- */

.sidebar,
.main-pane {
  min-width: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}

.sidebar {
  background: var(--sidebar-bg);
}

.main-pane {
  background: var(--card);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--hairline);
}

/* Two rows: eyebrow + actions on top, full-width subtitle + status below. */
.sidebar-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  padding: 16px;
  border-bottom: 1px solid var(--hairline);
}

.sidebar-eyebrow {
  grid-column: 1;
  color: var(--faint);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-head-btns {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.sidebar-head h1 {
  grid-column: 1 / -1;
  overflow: hidden;
  font-size: var(--t-base);
  font-weight: 600;
  line-height: var(--lh-title);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-head .vault-status {
  grid-column: 1 / -1;
}

.vault-status {
  display: block;
  margin-top: 6px;
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: var(--t-xs);
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  cursor: default;
}

.vault-status.active {
  color: var(--blue);
}

.vault-status.action {
  color: var(--blue);
  cursor: pointer;
}

.vault-status.warn {
  color: var(--red);
}

.search-box {
  padding: 12px 16px;
}

.search-box input,
.title-input,
.note-editor {
  width: 100%;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  background: var(--card-sunk);
  outline: none;
}

.search-box input {
  height: 36px;
  padding: 0 12px;
  font-size: var(--t-sm);
}

.search-box input:focus,
.title-input:focus,
.note-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-wash);
}

.nav-list,
.note-list,
.tag-list,
.mini-list,
.connection-list,
.theme-review {
  display: grid;
  gap: 4px;
}

.nav-list {
  padding: 0 12px 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  background: transparent;
  font-size: var(--t-sm);
  text-align: left;
}

.nav-item > span:first-child {
  color: var(--faint);
}

.nav-item:hover {
  background: var(--card-sunk);
}

.nav-item.active {
  color: var(--blue);
  background: var(--blue-wash);
}

.nav-item.active > span:first-child {
  color: var(--blue);
}

.nav-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--card-sunk);
  font-size: var(--t-xs);
  text-align: center;
}

.nav-item.active .nav-count {
  color: var(--blue);
  background: transparent;
}

.side-section {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--hairline);
}

.side-section.grow {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 8px;
  color: var(--faint);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-title.flat {
  padding: 0 0 10px;
}

.plain-btn {
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: var(--t-xs);
  font-weight: 600;
}

.tag-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tag-pill {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: var(--t-xs);
}

.tag-pill:hover {
  border-color: var(--hairline-strong);
  color: var(--text);
}

.tag-pill.active {
  color: var(--blue);
  border-color: transparent;
  background: var(--blue-wash);
}

.note-list {
  padding-bottom: 8px;
}

.note-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  background: transparent;
  text-align: left;
}

.note-item:hover {
  background: var(--card-sunk);
}

.note-item.active {
  background: var(--blue-wash);
}

.note-item strong,
.library-card strong,
.mini-note strong,
.suggestion strong,
.connection-row strong {
  overflow: hidden;
  font-size: var(--t-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item span,
.note-item small,
.library-card p,
.library-card span,
.mini-note span,
.suggestion span,
.connection-row span,
.insight-card p,
.review-card p,
.cluster-card p,
.cluster-card span,
.theme-row span {
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: var(--lh-body);
}

.note-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item small {
  color: var(--faint);
}

/* ---------- main pane ---------- */

.main-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-head {
  min-height: 64px;
  flex-wrap: wrap;
  row-gap: 8px;
}

.pane-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.pane-title h2 {
  flex-shrink: 0;
  font-size: var(--t-lg);
  font-weight: 600;
  line-height: var(--lh-title);
  white-space: nowrap;
}

#viewMeta {
  overflow: hidden;
  color: var(--faint);
  font-size: var(--t-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.soft-btn,
.primary-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease;
}

.soft-btn {
  border: 1px solid var(--hairline-strong);
  color: var(--text);
  background: transparent;
}

.soft-btn:hover {
  background: var(--card-sunk);
}

.primary-btn {
  border: 1px solid transparent;
  color: #fff;
  background: var(--blue);
}

.primary-btn:hover {
  background: var(--blue-ink);
}

.write-view,
.library-view,
.network-view,
.review-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

/* ---------- write / editor ---------- */

.editor-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 520px;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--card);
}

.title-input {
  min-height: 44px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--faint);
  font-size: var(--t-xs);
}

.meta-chip {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: var(--t-xs);
  font-weight: 600;
}

.meta-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.meta-chip.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.note-editor {
  min-height: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  font-size: var(--t-base);
  line-height: 1.7;
  resize: none;
}

/* ---------- library ---------- */

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.library-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  color: var(--text);
  background: var(--card);
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.library-card:hover {
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-card);
}

/* ---------- network ---------- */

.network-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.network-card,
.review-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--card);
}

.network-card.wide {
  grid-column: 1 / -1;
}

.cluster-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.cluster-card,
.connection-row,
.mini-note,
.suggestion {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text);
  background: transparent;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.cluster-card:hover,
.connection-row:hover,
.mini-note:hover,
.suggestion:hover {
  border-color: var(--hairline-strong);
  background: var(--card-sunk);
}

.cluster-card {
  min-height: 96px;
}

.cluster-card strong,
.suggestion strong {
  color: var(--text);
  font-size: var(--t-sm);
}

.cluster-card strong {
  color: var(--blue);
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}

.theme-row strong {
  font-size: var(--t-sm);
  font-weight: 600;
}

/* ---------- review view: 12-col grid ---------- */

.review-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: stretch;
}

.hero-review {
  grid-column: 3 / span 8;
}

.review-card:not(.hero-review) {
  grid-column: span 4;
}

.hero-review {
  gap: 8px;
  padding: 28px;
  text-align: center;
  align-content: center;
  justify-items: center;
}

.hero-review > span {
  color: var(--blue);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-review strong {
  display: block;
  margin-top: 4px;
  font-size: var(--t-xl);
  font-weight: 600;
  line-height: var(--lh-title);
}

.hero-review p {
  max-width: 60ch;
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.hero-review .echo-why {
  color: var(--muted);
}

.hero-review .primary-btn {
  margin-top: 8px;
}

/* humble empty state for the review hero */
.echo-empty {
  grid-column: 3 / span 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--card);
  text-align: center;
}

.echo-empty .echo-empty-icon {
  color: var(--faint);
  line-height: 1;
}

.echo-empty .echo-empty-icon .icon {
  width: 24px;
  height: 24px;
}

.icon-inline {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: -1px;
}

.echo-empty p {
  max-width: 48ch;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.weekly-digest {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--card);
}

.weekly-digest.hidden {
  display: none;
}

.digest-list {
  display: grid;
  gap: 6px;
}

.digest-row {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.digest-row:hover {
  background: var(--card-sunk);
}

.digest-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-sm);
  font-weight: 600;
}

.digest-row span {
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: var(--lh-body);
}

.digest-mark {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--blue-wash);
  color: var(--blue);
  font-size: var(--t-xs);
  font-weight: 600;
}

.echo-stats {
  display: grid;
  gap: 8px;
}

.stat-days {
  margin-bottom: 4px;
  color: var(--faint);
  font-size: var(--t-xs);
  font-weight: 600;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: var(--t-sm);
}

.stat-row strong {
  color: var(--text);
  font-size: var(--t-sm);
  font-weight: 600;
}

.stat-row.north {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  color: var(--blue);
}

.stat-row.north strong {
  color: var(--blue);
}

/* ---------- echo card (the ritual) ---------- */

.echo-card {
  position: relative;
  gap: 8px;
  margin: 0 auto 20px;
  max-width: 760px;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-card);
  animation: echo-in 240ms ease-out;
}

@keyframes echo-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .echo-card,
  .importer-echo {
    animation: none;
  }
}

.echo-card.hidden {
  display: none;
}

.echo-tag {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.echo-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.echo-why {
  margin: 0 0 6px;
  color: var(--text);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.echo-snippet {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.echo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.echo-actions .soft-btn,
.echo-actions .primary-btn {
  min-height: 32px;
  padding: 0 14px;
  font-size: var(--t-sm);
}

.echo-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: var(--t-sm);
  cursor: pointer;
}

.echo-close:hover {
  color: var(--text);
}

/* ---------- insight pane: a quiet slide-out, collapsed by default ---------- */

.insight-toggle {
  color: var(--muted);
}

.insight-toggle:hover,
.insight-toggle.active {
  color: var(--blue);
  background: var(--blue-wash);
}

.insight-pane {
  position: fixed;
  /* Sit below the (possibly wrapped) header so the pane never covers header
     actions at any width. --insight-top is measured from .pane-head in app.js;
     the fallback clears a single-row header before JS runs. */
  top: var(--insight-top, 88px);
  right: 16px;
  bottom: 16px;
  z-index: 40;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-pop);
  transform: translateX(340px);
  transition: transform 240ms ease;
}

.insight-pane.open {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .insight-pane {
    transition: none;
  }
}

.insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.insight-head .section-title {
  padding: 0;
}

.insight-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--card);
}

.insight-card.ownership {
  background: var(--blue-wash);
  border-color: transparent;
}

.ownership > span {
  color: var(--blue);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ownership strong {
  display: block;
  margin-top: 4px;
  font-size: var(--t-base);
  font-weight: 600;
  line-height: var(--lh-title);
}

.empty-mini {
  padding: 12px;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-sm);
  color: var(--faint);
  font-size: var(--t-xs);
  line-height: var(--lh-body);
}

/* ---------- overlays: onboarding + importer ---------- */

.onboarding,
.importer,
.settings {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 24, 34, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.onboarding.hidden,
.importer.hidden,
.settings.hidden {
  display: none;
}

.onboarding-card,
.importer-card,
.settings-card {
  position: relative;
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.settings-card h2 {
  margin: 0 0 20px;
  font-size: var(--t-lg);
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.settings-label {
  flex: 1;
  min-width: 0;
}

.settings-label strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-base);
  font-weight: 600;
}

.settings-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-wash);
  color: var(--blue);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.settings-label p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.settings-privacy {
  color: var(--blue) !important;
}

.settings-cdn {
  color: var(--faint) !important;
  font-size: var(--t-xs) !important;
}

.settings-status {
  color: var(--faint) !important;
  font-size: var(--t-xs) !important;
}

.settings-status.warn {
  color: var(--red) !important;
}

.switch {
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--hairline-strong);
  transition: background 140ms ease;
}

.switch.on {
  background: var(--blue);
}

.switch-knob {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  transition: transform 140ms ease;
}

.switch.on .switch-knob {
  transform: translateX(18px);
}

.importer-card {
  max-height: 86vh;
  overflow-y: auto;
}

.onboarding-card {
  text-align: center;
}

.onboarding-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
}

.onboarding-card h2,
.importer-card h2 {
  margin: 0 0 8px;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.onboarding-tagline,
.importer-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: var(--lh-body);
}

.onboarding-actions,
.importer-actions {
  display: grid;
  gap: 8px;
}

.onboarding-actions .primary-btn,
.onboarding-actions .soft-btn,
.importer-actions .soft-btn {
  width: 100%;
  min-height: 44px;
}

.importer-actions .soft-btn {
  justify-content: flex-start;
  text-align: left;
}

.import-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 32px 24px;
  border: 1.5px dashed var(--hairline-strong);
  border-radius: var(--r);
  background: var(--card-sunk);
  color: var(--text);
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease;
}

.import-drop:hover,
.import-drop.dragover {
  border-color: var(--blue);
  background: var(--blue-wash);
}

.import-drop-icon {
  color: var(--blue);
  line-height: 1;
}

.import-drop-icon .icon {
  width: 24px;
  height: 24px;
}

.import-drop strong {
  font-size: var(--t-base);
  font-weight: 600;
}

.import-drop-hint {
  color: var(--faint);
  font-size: var(--t-xs);
  line-height: var(--lh-body);
}

.onboarding-hint {
  margin: 0 0 12px;
  color: var(--faint);
  font-size: var(--t-xs);
  line-height: var(--lh-body);
}

.onboarding-hint.warn {
  color: var(--red);
}

.onboarding-hint.hidden {
  display: none;
}

.importer-msg {
  margin: 16px 0 0;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--blue);
}

.importer-msg.error {
  color: var(--red);
}

.importer-msg.hidden {
  display: none;
}

.importer-echo {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--shadow-card);
  animation: echo-in 240ms ease-out;
}

.importer-echo.hidden {
  display: none;
}

.importer-echo strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--t-base);
  font-weight: 600;
}

.importer-quiet {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-sm);
}

.hidden {
  display: none !important;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    height: auto;
    min-height: 100vh;
  }

  body {
    overflow: auto;
  }

  .rail {
    position: sticky;
    top: 12px;
    height: calc(100vh - 24px);
  }

  .sidebar {
    grid-column: 2;
    max-height: 52vh;
    position: static;
  }

  .main-pane {
    grid-column: 2;
  }

  /* mobile: a bottom-sheet drawer — slides fully off-screen when closed */
  .insight-pane {
    top: auto;
    width: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-height: 80vh;
    transform: translateY(calc(100% + 24px));
  }

  .insight-pane.open {
    transform: translateY(0);
  }

  .write-view,
  .library-view,
  .network-view,
  .review-view {
    padding: 16px;
  }

  .editor-shell {
    padding: 20px;
  }

  .network-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .hero-review,
  .review-card:not(.hero-review),
  .echo-empty {
    grid-column: auto;
  }
}

/* phones: keep every view readable and tappable, no horizontal scroll */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .rail {
    top: 8px;
    height: calc(100vh - 16px);
    gap: 4px;
    padding: 8px 4px;
  }

  .rail-btn,
  .brand {
    width: 36px;
    height: 36px;
  }

  .pane-head {
    flex-wrap: wrap;
    min-height: 0;
    gap: 8px;
  }

  .head-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .head-actions .soft-btn,
  .head-actions .primary-btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: var(--t-xs);
  }

  .write-view,
  .library-view,
  .network-view,
  .review-view {
    padding: 12px;
  }

  .editor-shell {
    padding: 16px;
    min-height: 60vh;
  }

  .title-input {
    font-size: var(--t-lg);
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .cluster-board {
    grid-template-columns: 1fr 1fr;
  }

  .echo-card,
  .editor-shell {
    max-width: 100%;
  }

  .settings-card,
  .onboarding-card,
  .importer-card {
    padding: 24px 20px;
  }
}
