/* Shared MAIN / SUB rhythm and palette. */
:root {
  --jy-radius: 16px;
}
.sub-workspace-tabs {
  display: flex;
  gap: 6px;
  margin-left: 24px;
  align-items: center;
}
.sub-workspace-tabs button {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}
.knowledge-window .topbar {
  border-radius: var(--jy-radius);
}
.knowledge-window .note-browser.graph-view {
  grid-template-columns: minmax(190px, var(--note-left, 25%)) 8px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
}
.graph-view #note-editor,
.graph-view #knowledge-context {
  display: none !important;
}
.graph-view .note-list,
.graph-view #note-splitter {
  grid-row: 1 !important;
}
#note-graph {
  grid-column: 3;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 32px 20px;
  overflow: hidden;
  color: var(--ink);
  /* The graph is a work surface, one step darker than the list card. */
  --graph-surface: var(--bg);
  background: var(--graph-surface);
}
#note-graph[hidden] {
  display: none;
}
.graph-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}
.graph-toolbar h1 {
  font-size: 24px;
  letter-spacing: -1px;
  margin: 8px 0;
}
.graph-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.graph-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.graph-stage {
  flex: 1;
  position: relative;
  min-height: 150px;
  background-image: radial-gradient(var(--line) 0.7px, transparent 0.7px);
  background-size: 24px 24px;
}
#note-graph svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
/* Graph marks keep a constant on-screen weight at every zoom level. */
#note-graph svg line {
  stroke: var(--line);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}
#note-graph svg line.is-near {
  stroke: var(--accent);
  stroke-width: 2;
}
#note-graph svg circle {
  fill: var(--node-color);
  stroke: var(--graph-surface);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
#note-graph svg text {
  fill: var(--ink);
  font-family: inherit;
  font-size: var(--graph-font, 13px);
  paint-order: stroke;
  stroke: var(--graph-surface);
  stroke-width: 3.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
#note-graph svg g {
  cursor: pointer;
  outline: 0;
}
/* Titles that do not fit stay hidden until the note is pointed at or focused. */
#note-graph svg g.label-hidden text {
  visibility: hidden;
}
#note-graph svg g.label-hidden:hover text,
#note-graph svg g.label-hidden:focus-visible text {
  visibility: visible;
}
#note-graph svg.has-focus g:not(.is-focus):not(.is-near):not(:hover):not(:focus-visible) {
  opacity: 0.5;
}
#note-graph svg.has-focus line:not(.is-near) {
  opacity: 0.55;
}
#note-graph svg g:hover circle,
#note-graph svg g.is-focus circle {
  stroke: var(--accent);
  stroke-width: 3;
}
#note-graph svg g.is-focus text {
  font-weight: 600;
}
#note-graph svg g:focus-visible circle {
  stroke: var(--accent);
  stroke-width: 3;
}
.graph-center {
  margin-top: 6px !important;
  color: var(--ink) !important;
}
.graph-center strong {
  color: var(--accent-ink);
  font-weight: 600;
}
.graph-scope-set,
.note-view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.graph-scope-set button,
.note-view-switch button {
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--muted) !important;
}
.graph-scope-set button + button,
.note-view-switch button + button {
  border-left: 1px solid var(--line) !important;
}
.graph-scope-set button[aria-pressed="true"],
.note-view-switch button[aria-pressed="true"] {
  color: var(--accent-ink) !important;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.graph-scope-set button:disabled {
  opacity: 0.45;
  cursor: default;
}
/* Secondary buttons are one family everywhere in SUB: the header's "별도 창",
   the memo list, graph actions, reader tools and vault actions share height,
   type, radius, hover and focus. The unit is the local --frame-unit. */
.sub {
  --btn-font: calc(13px * var(--frame-unit, 1));
  --btn-pad: calc(6px * var(--frame-unit, 1)) calc(12px * var(--frame-unit, 1));
  --btn-radius: calc(7px * var(--frame-unit, 1));
  --btn-min: calc(28px * var(--frame-unit, 1));
}
#zettel-panel .md-actions button,
#zettel-panel .reader-toolbar button,
#note-graph .graph-actions button,
.note-view-switch button,
.memo-head #sticky-menu {
  font: inherit;
  font-size: var(--btn-font);
  line-height: 1.2;
  min-height: var(--btn-min);
  padding: var(--btn-pad);
  border: 1px solid var(--line);
  border-radius: var(--btn-radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
#zettel-panel .md-actions button:hover:not(:disabled),
#zettel-panel .reader-toolbar button:hover:not(:disabled),
#note-graph .graph-actions button:hover:not(:disabled),
.note-view-switch button:hover,
.memo-head #sticky-menu:hover {
  border-color: var(--ink); /* hover = 잉크 테두리 (주황은 현재·주요 행동·초점 전용) */
  color: var(--ink) !important;
}
#zettel-panel button:disabled {
  opacity: 0.45;
  cursor: default;
}
#zettel-panel button:focus-visible,
#zettel-panel select:focus-visible,
#zettel-panel input:focus-visible,
.note-view-switch button:focus-visible,
.memo-head #sticky-menu:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
/* Vault fields: one rounded field style instead of underline + rounded mixes. */
#zettel-panel .note-list :is(#note-search, #note-filter, #area-filter, #md-source) {
  font-size: 13px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--btn-radius);
  background: var(--panel2, #e1ddd6);
  color: var(--ink);
}

/* Right-hand display switch: one fixed spot for both graph and reading. */
.note-browser {
  position: relative;
}
.note-view-switch {
  position: absolute;
  top: 14px;
  right: 20px;
  z-index: 7;
  background: var(--panel);
}
#note-graph .graph-actions {
  padding-top: 44px;
}
.note-browser:not(.graph-view) #knowledge-context {
  padding-top: 60px;
}
@media (max-width: 1000px) {
  .note-browser:not(.graph-view) #note-editor {
    padding-top: 56px;
  }
}
#note-search-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
#note-search-hint button {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  font: inherit;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}
#note-toc .toc-note {
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.graph-footer {
  padding-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.graph-footer > div {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}
.graph-footer i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}
.graph-empty {
  position: absolute;
  inset: 40% 12%;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}
@media (max-width: 1000px) {
  #note-graph {
    padding: 20px 16px;
  }
  .graph-toolbar {
    flex-direction: column;
  }
  .graph-toolbar h1 {
    font-size: 24px;
  }
  .sub-workspace-tabs {
    margin-left: 10px;
  }
  .topbar__right > .label {
    display: none;
  }
  /* Small windows reflow: the project rail gets two more grid columns and keeps
     whole words, instead of the type shrinking until it breaks per letter. */
  body:not(.knowledge-window) .project-sidebar {
    grid-column: 1 / 6;
  }
  body:not(.knowledge-window) .work-shell > .workspace {
    grid-column: 6 / -1;
  }
  .project-sidebar,
  .project-sidebar * {
    word-break: keep-all;
    overflow-wrap: normal;
  }
  .project-sidebar button,
  .project-sidebar strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
#note-graph svg g {
  pointer-events: bounding-box;
}
#note-graph .graph-stage svg {
  position: absolute;
  inset: 0;
}
.sub-knowledge .sub {
  height: 100vh !important;
  max-height: 100vh !important;
}
/* SUB header — one rule set for Canvas, ZETTEL and the separate window.
   Outer box follows MAIN (shell unit); everything inside uses the head unit, so
   switching mode never changes the logo, tab or button size. */
/* Canvas keeps MAIN's bottom margin (36.375); only the vault view uses 16. */
.sub {
  padding: calc(32px * var(--shell-unit, 1)) calc(40px * var(--shell-unit, 1))
    calc(36.375px * var(--shell-unit, 1)) !important;
}
.knowledge-window .sub {
  padding-bottom: calc(16px * var(--shell-unit, 1)) !important;
}
.sub {
  grid-template-rows:
    max(44px, calc(48px * var(--shell-unit, 1))) minmax(0, 1fr)
    calc(28px * var(--frame-unit));
}
.knowledge-window .sub {
  gap: calc(16px * var(--shell-unit, 1));
  grid-template-rows:
    max(44px, calc(48px * var(--shell-unit, 1)))
    minmax(0, 1fr) !important;
}
/* The in-place ZETTEL view occupies the same shell as Canvas.  The separate
   ZETTEL window keeps its compact two-row frame above. */
.sub-knowledge .sub {
  padding: calc(32px * var(--shell-unit, 1)) calc(40px * var(--shell-unit, 1))
    calc(36.375px * var(--shell-unit, 1)) !important;
  gap: var(--bento-gap) !important;
  grid-template-rows:
    max(44px, calc(48px * var(--shell-unit, 1))) minmax(0, 1fr)
    calc(28px * var(--frame-unit)) !important;
}
.sub > .topbar {
  --frame-unit: var(--head-unit, 1);
  display: flex !important;
  align-items: center;
  gap: calc(20px * var(--head-unit, 1));
  padding: 0 calc(20px * var(--head-unit, 1));
  font-size: calc(13px * var(--head-unit, 1));
  border-radius: calc(16px * var(--shell-unit, 1));
}
.sub > .topbar .topbar__brand {
  border: 0;
  padding: 0;
  flex: none;
  gap: calc(12px * var(--head-unit, 1));
}
.sub > .topbar .sub-workspace-tabs {
  flex: none;
  margin: 0;
  gap: calc(6px * var(--head-unit, 1));
  white-space: nowrap;
}
/* Tabs and the header's secondary button are one family: same height, type,
   radius and focus ring. Only the pressed tab carries the orange stroke. */
.sub > .topbar .sub-workspace-tabs button,
.sub > .topbar #knowledge-detached {
  font: inherit;
  font-size: calc(13px * var(--head-unit, 1));
  line-height: 1.2;
  min-height: calc(28px * var(--head-unit, 1));
  padding: calc(6px * var(--head-unit, 1)) calc(12px * var(--head-unit, 1));
  border: 1px solid transparent !important;
  border-radius: calc(7px * var(--head-unit, 1));
  background: transparent;
  color: var(--ink) !important;
  white-space: nowrap;
  cursor: pointer;
}
.sub > .topbar .sub-workspace-tabs button[aria-pressed="true"] {
  /* 현재 탭 = 홈 면 + 주황 밑줄. 테두리(outline 모양)는 키보드 초점만 쓴다 */
  border-color: transparent !important;
  color: var(--ink) !important;
  font-weight: 500;
  background: var(--panel2);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.sub > .topbar #knowledge-detached {
  border-color: var(--line) !important;
}
.sub > .topbar .sub-workspace-tabs button:not([aria-pressed="true"]):hover,
.sub > .topbar #knowledge-detached:hover {
  border-color: var(--ink) !important;
  color: var(--ink) !important;
}
.sub > .topbar .sub-workspace-tabs button:focus-visible,
.sub > .topbar #knowledge-detached:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sub > .topbar #knowledge-heading {
  font-size: calc(13px * var(--head-unit, 1));
}
.sub > .topbar .topbar__work {
  flex: 1;
  min-width: 0;
}
.sub > .topbar .topbar__right {
  flex: none;
  padding: 0;
  margin-left: auto;
}
.reference-pane,
.thinking-workspace,
#capture-panel {
  position: relative;
}
.reference-pane.pane-active,
.thinking-workspace.pane-active,
#capture-panel.pane-active {
  outline: 0 !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
}
.reference-pane.pane-active::after,
.thinking-workspace.pane-active::after,
#capture-panel.pane-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: inherit;
  pointer-events: none;
  z-index: 30;
}
.reference-item.selected {
  outline: calc(2px / var(--zoom, 1)) solid var(--accent) !important;
  outline-offset: 0;
  box-shadow: none !important;
}
.reference-text,
.reference-text[contenteditable="true"],
.reference-text:focus,
.reference-text:focus-visible {
  box-sizing: border-box;
  padding: 6px;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}
.reference-item.text-only,
.reference-item.text-only .media-content {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.reference-item.text-box,
.reference-item.text-box .media-content {
  background: var(--panel2) !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px;
  box-shadow: none !important;
}
.reference-text {
  line-height: 1.45;
  white-space: pre-wrap;
  overflow: hidden;
  overflow-wrap: anywhere;
  background: transparent !important;
}
.reference-text[contenteditable="true"] {
  overflow: auto;
  background: transparent !important;
}
/* Reserve a real toolbar lane below the floating graph/reader switch.  This
   remains stable under Windows DPI scaling and prevents the theme button from
   slipping underneath the segmented control. */
#note-graph {
  padding-top: 64px;
}
#note-graph .graph-actions {
  padding-top: 0;
}
.note-browser:not(.graph-view) #note-editor {
  padding-top: 64px;
}
.selection-marquee {
  position: absolute;
  z-index: 25;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  pointer-events: none;
}
#viewport,
#r-viewport {
  cursor: crosshair;
}
.os > .topbar > .topbar__right {
  display: flex;
  align-items: center;
  gap: 18px;
}

@media (max-width: 1100px) {
  .sub > .topbar {
    gap: 10px;
  }
  .sub > .topbar .topbar__brand .label {
    display: none;
  }
  .sub > .topbar .topbar__right > .label {
    display: none;
  }
}
.reference-item.text-only { border:0; }
/* Right-click menu rows: label left, shortcut right. */
.sheet-menu button { display:flex; justify-content:space-between; gap:24px; align-items:center; }
.sheet-menu button:disabled { opacity:.4; cursor:default; background:transparent; }
.sheet-menu kbd { font:inherit; font-size:11px; color:var(--muted); }
.sheet-menu hr { border:0; border-top:1px solid var(--soft, var(--line)); margin:4px 6px; }
/* Quick memo list inside the memo card. */
#sticky-panel { flex:1; min-height:0; display:flex; flex-direction:column; gap:calc(8px * var(--frame-unit,1)); }
#sticky-panel[hidden] { display:none; }
#sticky-panel #sticky-search { font:inherit; font-size:var(--btn-font); padding:var(--btn-pad); border:1px solid var(--line); border-radius:var(--btn-radius); background:var(--panel2); color:var(--ink); }
#sticky-panel #sticky-list { margin-top:0; overflow:auto; min-height:0; align-content:start; gap:6px; }
#sticky-panel #sticky-list > button { padding:8px 10px; gap:2px; }
#sticky-panel #sticky-list > button small { font-size:11px; }
