/* Inkore Second Brain · light Inkore look, built on ../shared/base.css tokens. */
[hidden] { display: none !important; }
html { scroll-padding-top: 90px; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 6% -12%, rgba(202, 219, 211, 0.62), transparent 62%),
    radial-gradient(900px 560px at 104% -4%, rgba(198, 216, 227, 0.5), transparent 58%),
    var(--page);
  background-attachment: fixed;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 560; color: var(--ink); transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), color var(--fast) var(--ease); }
button:hover:not(:disabled) { border-color: rgba(60, 103, 105, 0.32); }
button.primary { color: var(--on-accent); box-shadow: 0 8px 20px -12px rgba(44, 83, 88, 0.85); }
button.primary svg { stroke: currentColor; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pad { padding: 8px 11px; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(60, 103, 105, 0.35); border-radius: 4px; }
.link-btn:hover { text-decoration-color: currentColor; }
.icon-btn { width: 38px; height: 38px; padding: 0; border-radius: 12px; background: transparent; border: 1px solid transparent; color: var(--ink); }
.icon-btn:hover:not(:disabled) { background: var(--hover); border-color: var(--line); }
.icon-btn.small { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.small-btn { font-size: 12.5px; font-weight: 620; padding: 5px 11px; white-space: nowrap; background: var(--paper); }
.small-btn svg { width: 15px; height: 15px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 10px; }
.inline-error { color: #9a3a32; font-size: 13px; margin: 6px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.inline-error:empty { display: none; }
.inline-error .link-btn { color: #9a3a32; text-decoration-color: rgba(154, 58, 50, 0.4); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 64px; padding: 0 20px;
  background: rgba(233, 235, 234, 0.74);
  -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; border-radius: 12px; padding: 4px 6px 4px 2px; flex: none; }
.brand-mark svg { width: 34px; height: 34px; display: block; stroke: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark .m1 { fill: #fff; }
.brand-mark .m2 { fill: var(--sage-soft); }
.brand-mark .m3 { stroke: #fff; stroke-width: 1.4; opacity: 0.7; fill: none; }
.brand-text { display: grid; line-height: 1.1; white-space: nowrap; }
.brand-text strong { color: var(--ink); font-size: 15px; letter-spacing: -0.01em; }
.brand-text span { color: var(--muted); font-size: 11.5px; }
.search-trigger {
  flex: 0 1 380px; min-width: 0; margin-left: 8px; justify-content: flex-start; gap: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 10px 8px 14px; color: var(--muted); font-weight: 500;
  box-shadow: 0 6px 18px -14px rgba(36, 59, 66, 0.5);
}
.search-trigger:hover { color: var(--ink); }
.search-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger kbd { margin-left: auto; font: 600 11px/1 var(--mono); color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; }
.viewnav { display: flex; gap: 2px; padding: 4px; background: rgba(255, 255, 255, 0.5); border: 1px solid var(--line); border-radius: 999px; }
.viewnav button { border: none; background: transparent; padding: 7px 15px; color: var(--muted); font-weight: 600; font-size: 14px; }
.viewnav button[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 10px -4px rgba(36, 59, 66, 0.35); }
.viewnav button[aria-current="page"] svg { color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.top-right > * { flex: none; }
.top-right > .mode-pill { flex: 0 1 auto; }
.mode-pill { font-size: 13px; padding: 7px 13px; background: var(--paper); gap: 8px; white-space: nowrap; min-width: 0; max-width: 100%; overflow: hidden; }
#aiModeText { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mode-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sand); box-shadow: 0 0 0 3px rgba(182, 161, 126, 0.22); }
.mode-pill[data-mode="own"] .dot { background: #4f9a7e; box-shadow: 0 0 0 3px rgba(79, 154, 126, 0.2); }
.mode-pill[data-mode="inkore"] .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(60, 103, 105, 0.2); }

.banner {
  max-width: 1640px; margin: 14px auto 0; width: calc(100% - 40px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 10px 9px 14px; border-radius: 16px;
  background: linear-gradient(90deg, rgba(231, 220, 198, 0.95), rgba(231, 220, 198, 0.45));
  border: 1px solid rgba(182, 161, 126, 0.38); color: var(--ink); font-size: 14px;
}
.banner p { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banner-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.banner-actions button { font-size: 13px; padding: 6px 13px; }
.banner-actions button:not(.primary):not(.icon-btn) { background: rgba(255, 255, 255, 0.7); }
.banner.alert { background: #f6e3df; border-color: rgba(154, 58, 50, 0.35); color: #5e211b; font-weight: 560; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 20px; padding: 18px 20px 40px; max-width: 1680px; margin: 0 auto; align-items: start; }
main { min-width: 0; outline: none; }
.view-title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }

/* sidebar */
.sidebar { position: sticky; top: 82px; height: calc(100vh - 100px); display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.side-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 8px; }
.side-actions button { padding: 10px 10px; font-weight: 640; font-size: 13.5px; gap: 5px; white-space: nowrap; min-width: 0; }
.side-actions button svg { width: 16px; height: 16px; }
.side-actions button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.side-actions button:not(.primary) { background: var(--paper); }
.side-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; margin: 0 0 9px; display: flex; align-items: center; gap: 6px; }
.side-title .count { font-size: 11px; letter-spacing: 0; color: var(--ink); background: rgba(255, 255, 255, 0.65); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { font-size: 12.5px; padding: 3px 9px; background: rgba(255, 255, 255, 0.55); font-weight: 560; color: var(--text); gap: 5px; }
.tag-chip span { color: var(--muted); font-size: 11px; font-weight: 600; }
.tag-chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.tag-chip[aria-pressed="true"] span { color: rgba(255, 255, 255, 0.82); }
.side-notes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head .side-title { margin: 0; }
.mini-select { width: auto; padding: 4px 10px; font-size: 12.5px; border-radius: 999px; background-color: rgba(255, 255, 255, 0.65); color: var(--ink); }
.filter-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0 0; padding: 6px 10px; font-size: 12.5px; border-radius: 10px; background: rgba(60, 103, 105, 0.08); color: var(--ink); }
.note-list { list-style: none; margin: 10px 0 0; padding: 0 4px 12px 0; overflow: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: rgba(57, 85, 91, 0.2) transparent; }
.note-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t d" "e d"; gap: 1px 10px;
  padding: 9px 11px; border-radius: 13px; text-decoration: none; color: inherit;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.note-item:hover { background: rgba(255, 255, 255, 0.55); }
.note-item[aria-current="page"] { background: var(--paper); box-shadow: inset 3px 0 0 var(--accent), 0 10px 26px -20px rgba(36, 59, 66, 0.5); }
.ni-title { grid-area: t; font-weight: 620; color: var(--ink); font-size: 14px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.ni-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ni-title svg { width: 14px; height: 14px; color: var(--muted); }
.ni-ex { grid-area: e; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni-deg { grid-area: d; align-self: center; font-size: 11.5px; font-weight: 650; color: var(--accent); background: rgba(60, 103, 105, 0.09); border-radius: 999px; padding: 2px 8px; min-width: 26px; text-align: center; }

/* ---------- note view ---------- */
.view-note { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.note-card { padding: 24px 36px 36px; border-radius: var(--r-lg); min-height: calc(100vh - 140px); }
.note-top { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }
.note-meta { margin: 0; font-size: 12.5px; color: var(--muted); }
.note-meta { margin-right: auto; }
.note-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-icons { display: flex; gap: 2px; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button, .seg label { border: none; background: transparent; padding: 5px 13px; font-size: 13px; font-weight: 620; color: var(--muted); border-radius: 999px; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 5px rgba(36, 59, 66, 0.16); }
.ai-btn { font-size: 13.5px; font-weight: 640; color: var(--accent); background: linear-gradient(180deg, #ffffff, var(--surface)); border-color: rgba(60, 103, 105, 0.28); }
.ai-btn:disabled { opacity: 0.7; }
.note-card:focus { outline: none; }
.note-title {
  display: block; resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 0;
  font: 720 34px/1.15 var(--font); letter-spacing: -0.025em; color: var(--ink);
  border: none; background: transparent; padding: 4px 6px; margin: 12px -6px 2px; width: calc(100% + 12px); border-radius: 10px;
}
.note-title:hover { background: rgba(255, 255, 255, 0.5); }
.note-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 20px; }
.note-body { max-width: 74ch; }

/* markdown */
.md { font-size: 16px; line-height: 1.72; color: var(--text); overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--ink); letter-spacing: -0.012em; }
.md h1 { font-size: 25px; margin: 1.4em 0 0.5em; }
.md h2 { font-size: 19px; margin: 1.55em 0 0.45em; }
.md h3 { font-size: 16.5px; margin: 1.3em 0 0.35em; }
.md h4, .md h5, .md h6 { font-size: 15px; margin: 1.2em 0 0.3em; }
.md p { margin: 0 0 0.85em; }
.md ul, .md ol { padding-left: 1.35em; margin: 0 0 0.9em; }
.md li { margin: 0.22em 0; }
.md li::marker { color: var(--sage); }
.md ol li::marker { color: var(--muted); font-weight: 600; font-size: 0.92em; }
.md li.task { list-style: none; margin-left: -1.35em; }
.md li.task label { display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.md li.task input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent); transform: translateY(2px); cursor: pointer; }
.md li.task.done > label > span { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(76, 100, 108, 0.45); }
.md strong { color: var(--ink); font-weight: 680; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md mark { background: rgba(231, 220, 198, 0.95); color: inherit; border-radius: 3px; padding: 0 2px; }
.md code { font: 0.88em var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.08em 0.36em; }
.md pre { background: #1f3b42; color: #e7f2f4; padding: 14px 16px; border-radius: 14px; overflow: auto; font-size: 13.5px; line-height: 1.6; }
.md pre code { background: none; border: none; padding: 0; color: inherit; }
.md blockquote { margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--sage); background: rgba(202, 219, 211, 0.28); border-radius: 0 12px 12px 0; color: var(--ink); }
.md blockquote p { margin: 0; }
.md .callout { margin: 1em 0; padding: 12px 16px; border-radius: 14px; background: rgba(198, 216, 227, 0.4); border: 1px solid rgba(116, 151, 174, 0.3); }
.md .callout p { margin: 0; }
.md .callout-title { font-weight: 680; color: var(--ink); margin-bottom: 4px !important; }
.md .callout-warning, .md .callout-caution { background: rgba(231, 220, 198, 0.55); border-color: rgba(182, 161, 126, 0.4); }
.md .callout-tip, .md .callout-success { background: rgba(202, 219, 211, 0.5); border-color: rgba(135, 166, 154, 0.4); }
.md .table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.55); }
.md table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.5; }
.md th { background: rgba(233, 235, 234, 0.7); text-align: left; font-weight: 660; color: var(--ink); }
.md th, .md td { padding: 9px 13px; border-bottom: 1px solid var(--line); }
.md tr:last-child td { border-bottom: none; }
.md .props { display: grid; gap: 4px; font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 1em; }
.md .props div { display: flex; gap: 10px; }
.md .props dt { color: var(--muted); min-width: 90px; }
.md .props dd { margin: 0; color: var(--ink); }
.wikilink { color: var(--accent); font-weight: 580; text-decoration: none; background: linear-gradient(transparent 64%, rgba(135, 166, 154, 0.3) 0); border-radius: 3px; padding: 0 1px; transition: background var(--fast) var(--ease); }
.wikilink:hover { background: rgba(135, 166, 154, 0.32); }
.wikilink.missing { color: var(--muted); background: none; border-bottom: 1px dashed rgba(76, 100, 108, 0.6); font-weight: 520; border-radius: 0; }
.tag { display: inline-block; font-size: 0.8em; font-weight: 640; color: #2b584e; background: var(--sage-soft); padding: 0.05em 0.6em; border-radius: 999px; text-decoration: none; line-height: 1.55; vertical-align: 0.06em; }
.tag:hover { background: #bcd1c8; }

/* editor */
.editor-wrap { position: relative; max-width: 78ch; }
.editor { display: block; width: 100%; min-height: 320px; border: 1px solid transparent; background: transparent; resize: none; overflow: hidden; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px); font: 16px/1.75 var(--font); color: var(--ink); border-radius: 12px; }
.editor:focus-visible { outline: none; border-color: rgba(60, 103, 105, 0.3); box-shadow: 0 0 0 3px rgba(60, 103, 105, 0.12); background: rgba(255, 255, 255, 0.4); }
.editor-hint { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; border-top: 1px dashed var(--line); padding-top: 10px; }
.saved-state { color: var(--sage-ink); font-weight: 650; margin-left: 6px; }
.saved-state.bad { color: #9a3a32; }
.saved-state.bad .link-btn { color: #9a3a32; font-size: inherit; }
.embed { color: var(--muted); font-style: italic; }
.embed::before { content: "⧉ "; font-style: normal; }
.url-off { color: var(--muted); overflow-wrap: anywhere; }
.link-popup { position: absolute; z-index: 6; min-width: 240px; max-width: 320px; list-style: none; margin: 0; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 22px 44px -20px rgba(36, 59, 66, 0.5); }
.link-popup li { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 9px; font-size: 14px; cursor: pointer; color: var(--ink); }
.link-popup li svg { width: 15px; height: 15px; color: var(--muted); }
.link-popup li[aria-selected="true"] { background: rgba(60, 103, 105, 0.1); }

/* suggestions */
.suggest-panel { margin: 0 0 22px; padding: 14px 16px; border-radius: 18px; background: linear-gradient(180deg, rgba(202, 219, 211, 0.42), rgba(255, 255, 255, 0.45)); border: 1px solid rgba(135, 166, 154, 0.38); max-width: 74ch; }
.sp-head { display: flex; align-items: center; gap: 10px; }
.sp-head h2 { font-size: 14px; margin: 0; display: flex; gap: 7px; align-items: center; flex: 1; }
.sp-head h2 svg { color: var(--accent); }
.sp-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.sp-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; }
.sp-list p { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.pending-line { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; margin: 6px 0; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.15s var(--ease) infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(60, 103, 105, 0.45); } 70% { box-shadow: 0 0 0 10px rgba(60, 103, 105, 0); } 100% { box-shadow: 0 0 0 0 rgba(60, 103, 105, 0); } }

/* context panel */
.context { position: sticky; top: 82px; display: grid; gap: 14px; max-height: calc(100vh - 100px); overflow: auto; scrollbar-width: thin; padding-bottom: 4px; }
.ctx-card { padding: 16px; }
.ctx-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ctx-head h2 { font-size: 13.5px; margin: 0; }
.mini-graph { width: 100%; height: 210px; display: block; margin-top: 10px; border-radius: 14px; cursor: grab; touch-action: none; background-color: var(--surface); background-image: radial-gradient(rgba(57, 85, 91, 0.13) 1px, transparent 1.3px); background-size: 16px 16px; border: 1px solid var(--line); }
.ctx-block + .ctx-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ctx-block h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin: 0; display: flex; align-items: center; gap: 6px; }
.count { font-size: 11px; letter-spacing: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-weight: 650; }
.ctx-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 11px; }
.ctx-title { font-weight: 620; color: var(--ink); text-decoration: none; font-size: 14px; }
.ctx-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.ctx-line { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ctx-list .small-btn { margin-top: 6px; }
.chip-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.note-chip { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; padding: 4px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 560; transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease); }
.note-chip:hover { border-color: rgba(60, 103, 105, 0.45); background: #fff; }
.note-chip.missing { border-style: dashed; color: var(--muted); background: transparent; }
.note-chip small { font-size: 11px; }
.note-chip.ghost { color: var(--muted); }

/* ---------- graph view ---------- */
.graph-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 106px); min-height: 520px; border-radius: var(--r-lg); }
body:has(.banner:not([hidden])) .graph-card { height: calc(100vh - 166px); }
.graph-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.graph-toolbar .view-title { margin-right: auto; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.inline-field input { width: 190px; padding: 6px 12px; border-radius: 999px; font-size: 13.5px; }
.check { display: inline-flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }
.graph-stage { position: relative; flex: 1; min-height: 0; background-color: var(--surface); background-image: radial-gradient(rgba(57, 85, 91, 0.12) 1px, transparent 1.3px), radial-gradient(800px 500px at 50% 45%, rgba(255, 255, 255, 0.85), transparent 70%); background-size: 18px 18px, 100% 100%; }
.graph-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.graph-canvas:focus-visible { outline-offset: -3px; }
.graph-zoom { position: absolute; right: 14px; top: 14px; display: grid; gap: 6px; }
.graph-zoom .icon-btn { background: var(--paper); border-color: var(--line); box-shadow: 0 8px 20px -14px rgba(36, 59, 66, 0.5); }
.graph-info { position: absolute; left: 16px; top: 16px; max-width: 280px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.gi-title { font-weight: 660; font-size: 15px; color: var(--ink); margin: 0; }
.gi-meta { font-size: 12.5px; color: var(--muted); margin: 2px 0 9px; }
.graph-help { position: absolute; left: 16px; bottom: 12px; margin: 0; font-size: 12px; color: var(--muted); background: rgba(246, 248, 247, 0.88); padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); }
.graph-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); pointer-events: none; padding: 24px; text-align: center; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px; border-top: 1px solid var(--line); }
.legend-chip { font-size: 12.5px; padding: 4px 11px; gap: 7px; background: rgba(255, 255, 255, 0.6); font-weight: 560; color: var(--text); }
.legend-chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(57, 85, 91, 0.12); }
.legend-chip span { color: var(--muted); font-size: 11px; }
.legend-chip[aria-pressed="true"] { border-color: var(--accent); background: rgba(60, 103, 105, 0.08); color: var(--ink); }
.legend-chip.static { border: none; background: none; display: inline-flex; align-items: center; color: var(--muted); }

/* ---------- ask view ---------- */
.ask-wrap { max-width: 820px; margin: 0 auto; padding: 8px 0 40px; }
.ask-head { text-align: center; margin: 20px 0 24px; }
.ask-icon { width: 54px; height: 54px; border-radius: 17px; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--accent), #6b9b94); box-shadow: 0 16px 32px -16px rgba(44, 83, 88, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.ask-icon svg { width: 27px; height: 27px; stroke: #fff; }
.ask-head h1 { font-size: 31px; letter-spacing: -0.025em; margin: 14px 0 8px; }
.ask-head p { max-width: 620px; margin: 0 auto; color: var(--muted); }
.ask-form { display: flex; gap: 10px; align-items: flex-end; padding: 10px 10px 10px 20px; border-radius: 22px; transition: box-shadow var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.ask-form:focus-within { border-color: rgba(60, 103, 105, 0.38); box-shadow: 0 0 0 4px rgba(60, 103, 105, 0.12), var(--shadow); }
.ask-form textarea { border: none; background: transparent; resize: none; font-size: 16.5px; padding: 9px 0; min-height: 50px; color: var(--ink); }
.ask-form textarea:focus-visible { outline: none; }
.ask-form button { padding: 12px 22px; font-weight: 660; border-radius: 16px; flex: none; }
.ask-suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 16px 0 26px; }
.q-chip { font-size: 13.5px; padding: 7px 14px; background: rgba(255, 255, 255, 0.62); color: var(--ink); font-weight: 540; }
.q-chip:hover { background: var(--paper); }
.ask-thread { display: grid; gap: 16px; }
.answer { padding: 22px 26px; border-radius: 24px; }
.answer.latest { border-color: rgba(60, 103, 105, 0.3); box-shadow: 0 24px 60px -30px rgba(36, 59, 66, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.62); }
.answer:not(.latest) { opacity: 0.94; }
.answer-head { display: flex; justify-content: space-between; gap: 10px 14px; align-items: flex-start; flex-wrap: wrap; }
.answer-q { font-size: 18px; line-height: 1.35; font-weight: 660; margin: 0; flex: 1 1 300px; }
.answer-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.answer-tags .pill { color: var(--muted); background: var(--surface); }
.answer-body { margin-top: 14px; font-size: 15.5px; }
.answer-used { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.answer-used .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.answer-used .chip-list { margin: 0; }
.answer-sent { margin-top: 10px; font-size: 13px; color: var(--muted); }
.answer-sent summary { cursor: pointer; border-radius: 6px; width: fit-content; }
.answer-sent ol { margin: 8px 0 0; padding-left: 1.4em; columns: 2; column-gap: 28px; }
.answer-sent li { break-inside: avoid; margin: 2px 0; }
.answer-sent a { color: var(--ink); text-decoration: none; }
.answer-sent a:hover { text-decoration: underline; }
.score { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.answer-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.answer.pending .chip-list.sending li { animation: chipIn 0.5s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes chipIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.skeleton { display: grid; gap: 9px; margin-top: 16px; }
.skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface) 0%, #ffffff 50%, var(--surface) 100%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton i:nth-child(1) { width: 94%; } .skeleton i:nth-child(2) { width: 82%; } .skeleton i:nth-child(3) { width: 58%; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* empty state */
.empty-state { text-align: center; padding: 70px 28px; border-radius: var(--r-lg); }
.empty-art { width: 66px; height: 66px; border-radius: 20px; display: inline-grid; place-items: center; background: var(--sage-soft); color: var(--sage-ink); }
.empty-art svg { width: 30px; height: 30px; }
.empty-state h1 { font-size: 24px; margin: 16px 0 8px; }
.empty-state p { color: var(--muted); max-width: 460px; margin: 0 auto; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.row-btns button:not(.primary) { background: var(--paper); }

/* ---------- dialogs ---------- */
.dlg { border: 1px solid var(--line); border-radius: 24px; padding: 0; background: #fbfcfb; color: var(--text); box-shadow: 0 40px 90px -30px rgba(20, 40, 45, 0.5); width: min(620px, calc(100vw - 24px)); max-height: min(88vh, 880px); }
.dlg::backdrop { background: rgba(32, 60, 67, 0.3); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlgIn 0.28s var(--ease); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.settings-dlg[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 16px 24px; border-bottom: 1px solid var(--line); margin: 0; }
.dlg-head h2 { margin: 0; font-size: 19px; }
.dlg-body { overflow: auto; padding: 2px 24px 8px; }
.dlg-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; margin: 0; }
.dlg-foot button { padding: 9px 20px; }
.set-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-section:last-child { border-bottom: none; }
.set-section h3 { font-size: 15px; margin: 0 0 10px; }
.set-section h4 { font-size: 13.5px; color: var(--ink); margin: 18px 0 4px; }
.set-section p { margin: 0 0 8px; font-size: 13.5px; }
.seg label { position: relative; cursor: pointer; color: var(--muted); }
.seg label input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--paper); color: var(--ink); box-shadow: 0 1px 5px rgba(36, 59, 66, 0.16); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.modes { border: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.modes legend { font-size: 13px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.mode-opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 255, 255, 0.65); cursor: pointer; transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease); }
.mode-opt input { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
.mode-opt strong { display: block; color: var(--ink); font-size: 14.5px; }
.mode-opt small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 1px; }
.mode-opt:has(input:checked) { border-color: rgba(60, 103, 105, 0.5); background: rgba(60, 103, 105, 0.06); }
.field { margin-top: 14px; display: grid; gap: 6px; }
.field label { font-weight: 620; font-size: 13.5px; color: var(--ink); }
.field small { color: var(--muted); font-size: 12.5px; }
.field small.warn-note { color: #7a4a14; background: rgba(231, 220, 198, 0.55); border-radius: 9px; padding: 7px 10px; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn button { flex: none; }
.btn-link { display: inline-flex; align-items: center; padding: 0.5em 1em; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--accent); font-weight: 620; white-space: nowrap; font-size: 13.5px; background: var(--paper); }
.btn-link[aria-disabled="true"] { color: var(--muted); cursor: not-allowed; background: var(--surface); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn-grid button { justify-content: flex-start; border-radius: 13px; padding: 9px 12px; font-size: 13.5px; text-align: left; background: var(--paper); }
.btn-grid button svg { color: var(--accent); }
.plain-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.plain-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 13.5px; padding: 6px 8px 6px 12px; background: rgba(255, 255, 255, 0.65); border: 1px solid var(--line); border-radius: 11px; }
.plain-list li.muted { background: none; border: none; padding: 2px 0; }
.confirm-dlg { width: min(460px, calc(100vw - 24px)); padding: 24px 24px 0; }
.confirm-dlg p { font-size: 15px; color: var(--ink); margin: 0; line-height: 1.55; }
.confirm-dlg .dlg-foot { border: none; padding: 18px 0 20px; }

/* search */
.search-dlg { margin-top: 10vh; width: min(640px, calc(100vw - 24px)); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.search-box:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.search-box > svg { color: var(--muted); }
.search-box input { border: none; background: transparent; font-size: 17px; padding: 6px 0; color: var(--ink); }
.search-box input:focus-visible { outline: none; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-hint { margin: 0; padding: 10px 20px 0; font-size: 12px; color: var(--muted); }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 56vh; overflow: auto; }
.search-results li { padding: 10px 12px; border-radius: 13px; cursor: pointer; display: grid; gap: 3px; }
.search-results li[aria-selected="true"] { background: rgba(60, 103, 105, 0.09); }
.sr-title { display: flex; gap: 8px; align-items: center; font-weight: 620; color: var(--ink); }
.sr-title svg { width: 16px; height: 16px; color: var(--muted); }
.sr-snip { font-size: 13px; color: var(--muted); padding-left: 24px; line-height: 1.5; }
.sr-snip mark { background: var(--sand-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.sr-create .sr-title { color: var(--accent); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; justify-items: center; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toasts[popover] { inset: auto auto 24px 50%; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; color: inherit; }
.toasts[popover]:not(:popover-open) { display: grid; }
.toast { pointer-events: auto; background: #203c43; color: #f2f7f6; padding: 10px 12px 10px 18px; border-radius: 15px; box-shadow: 0 18px 40px -18px rgba(20, 40, 45, 0.7); display: flex; gap: 14px; align-items: center; font-size: 14px; animation: toastIn 0.3s var(--ease); transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast button { background: transparent; border: 1px solid rgba(255, 255, 255, 0.32); color: #fff; padding: 4px 12px; font-weight: 640; font-size: 13px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* bottom nav (phones and narrow windows) */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(246, 248, 247, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.bottomnav button { border: none; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11.5px; font-weight: 640; color: var(--muted); padding: 6px 0; border-radius: 12px; }
.bottomnav button svg { width: 22px; height: 22px; }
.bottomnav button[aria-current="page"] { color: var(--accent); background: rgba(60, 103, 105, 0.08); }
.scrim { position: fixed; inset: 0; background: rgba(32, 60, 67, 0.32); z-index: 45; }

/* ---------- responsive ---------- */
@media (min-width: 900px) { .narrow-only { display: none !important; } }
@media (max-width: 1279px) { .pm-model { display: none; } }
/* 900-1099 px: the view tabs are shown, so the brand name, the shortcut and some padding give way to the search box */
@media (min-width: 900px) and (max-width: 1099px) {
  .brand-text, .search-trigger kbd { display: none; }
  .viewnav button { padding: 7px 11px; }
  .topbar { gap: 10px; }
}
@media (max-width: 1239px) {
  .view-note { grid-template-columns: minmax(0, 1fr); }
  .context { position: static; max-height: none; overflow: visible; grid-template-columns: 1fr 1fr; align-items: start; }
  .note-card { min-height: 0; }
}
@media (max-width: 899px) {
  .wide-only { display: none !important; }
  .topbar { padding: 0 10px; gap: 8px; height: 58px; }
  .top-right { flex: 0 1 auto; }
  .search-trigger { flex: 1; margin-left: 0; min-width: 0; }
  .search-trigger kbd { display: none; }
  .search-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 98px; gap: 14px; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: auto; width: min(330px, 88vw); z-index: 50; background: #f2f4f3; padding: 18px 14px 14px; transform: translateX(-105%); visibility: hidden; transition: transform var(--normal) var(--ease), visibility 0s linear var(--normal); box-shadow: 0 30px 60px -20px rgba(20, 40, 45, 0.5); border-right: 1px solid var(--line); }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform var(--normal) var(--ease); }
  .banner { width: calc(100% - 24px); margin-top: 10px; flex-wrap: wrap; font-size: 13.5px; }
  .note-card { padding: 18px 18px 24px; }
  .note-title { font-size: 27px; margin-top: 8px; }
  .context { grid-template-columns: minmax(0, 1fr); }
  .graph-card { height: calc(100vh - 168px); min-height: 420px; }
  body:has(.banner:not([hidden])) .graph-card { height: calc(100vh - 250px); }
  .graph-toolbar { padding: 12px 14px; }
  .graph-toolbar .view-title { width: 100%; }
  .inline-field.grow { flex: 1; }
  .inline-field.grow input { width: 100%; }
  .graph-help { display: none; }
  .ask-head { margin-top: 8px; }
}
@media (max-width: 560px) {
  .brand-text { display: none; }
  .note-meta { order: 1; flex: 1; }
  .note-icons { order: 2; }
  .note-tools { order: 3; }
  .graph-toolbar .view-title { display: none; }
  .graph-info { top: auto; bottom: 12px; left: 12px; right: 64px; max-width: none; display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; padding: 10px 12px; }
  .graph-info .gi-meta { margin: 0; flex: 1; }
  .graph-info .gi-title { width: 100%; }
  .graph-legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .legend-chip { flex: none; }
  .banner { font-size: 13px; padding: 8px 8px 8px 12px; }
  #demoDataFlag { display: none; }
  .search-trigger { flex: 0 0 auto; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .search-label { display: none; }
  .top-right { gap: 6px; }
  .mode-pill { padding: 6px 10px; font-size: 12.5px; }
  .note-top { gap: 8px; }
  .note-tools { width: 100%; }
  .ai-btn { flex: 1; }
  .btn-grid { grid-template-columns: minmax(0, 1fr); }
  .ask-head h1 { font-size: 25px; }
  .ask-form { padding-left: 14px; }
  .answer { padding: 18px 16px; }
  .answer-sent ol { columns: 1; }
  .md { font-size: 15.5px; }
  .dlg-body { padding: 2px 18px 8px; }
  .dlg-head { padding-left: 18px; }
  .search-dlg { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) { .skeleton i { background: var(--surface); } }
