/* The study workspace shares the homepage palette while prioritizing reading. */
:root { --header-height: 78px; }
body { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; flex-shrink: 0; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--panel); z-index: 10; }
header .brand { font-size: 15px; gap: 10px; margin-right: 12px; }
header .brand-mark { font-size: 32px; width: 39px; }
header .brand small { font-size: 9px; letter-spacing: 1px; }
.tabs { display: flex; background: var(--panel2); padding: 4px; gap: 4px; border-radius: 6px; }
.tab { font-size: 13px; color: var(--dim); background: transparent; border: 0; border-radius: 4px; padding: 10px 17px; min-height: 40px; transition: background-color .2s, color .2s; }
.tab:hover { color: var(--accent); }
.tab.active { background: var(--panel); color: var(--accent); box-shadow: 0 1px 4px #1c315112; font-weight: 600; }
.search { flex: 1; min-width: 150px; max-width: 390px; margin-left: auto; }
.search input { width: 100%; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--border); border-radius: 5px; height: 44px; padding: 10px 14px; }
.search input:focus-visible { outline-offset: 2px; }
.toolbtn { font-size: 12px; color: var(--dim); background: transparent; border: 1px solid var(--border); border-radius: 5px; min-height: 44px; padding: 8px 12px; }
.toolbtn:hover { color: var(--accent); border-color: var(--accent); }
.ann-count { display: inline-block; color: var(--accent); background: var(--accent-soft); border-radius: 3px; padding: 1px 5px; font-size: 10px; margin-left: 3px; }
main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; overflow: auto; }
.view.active { display: block; }
#view-guided { padding: 44px clamp(24px, 4vw, 64px) 70px; scroll-behavior: smooth; }
.study-intro { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 30px; }
.study-intro .eyebrow { margin: 0 0 15px; color: var(--accent); }
.study-intro h1 { font-size: 36px; letter-spacing: -1px; margin: 0 0 13px; }
.study-intro h1 span { color: var(--accent); }
.study-intro p { font-size: 14px; line-height: 1.9; color: var(--dim); margin: 0; }
.study-stats { display: flex; gap: 26px; flex-shrink: 0; padding-bottom: 5px; }
.study-stats div { font-size: 11px; color: var(--faint); }
.study-stats strong { display: block; font: italic 30px Georgia, serif; color: var(--accent); margin-bottom: 8px; }
.study-path { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding-block: 16px; border-block: 1px solid var(--border); margin-bottom: 20px; }
.study-path a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-size: 13px; gap: 9px; }
.study-path a:hover { color: var(--accent); }
.study-path a span { color: var(--faint); font: 10px var(--font-mono); }
.study-path > span { color: #929ba9; margin-inline: 10px; }
.overview { margin: 0 0 32px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.overview summary { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; cursor: pointer; min-height: 44px; font-size: 13px; color: var(--dim); list-style: none; }
.overview summary::-webkit-details-marker { display: none; }
.overview summary::before { content: '+'; font-size: 23px; color: var(--accent); width: 16px; }
.overview[open] summary::before { content: '−'; }
.overview summary span { color: var(--faint); font-size: 11px; }
.overview img { width: 100%; height: auto; display: block; margin-top: 16px; background: var(--panel); }
.overview .ov-cap { color: var(--faint); font-size: 12px; margin-block: 12px; line-height: 1.8; }
.layer-group { margin-bottom: 35px; scroll-margin-top: 20px; }
.layer-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 17px; }
.layer-badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 3px; }
.layer-head h2 { margin: 0; }
.layer-desc { color: var(--faint); font-size: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 15px; }
.mini-card { border: 1px solid var(--border); border-radius: 5px; padding: 21px; background: var(--panel); cursor: pointer; position: relative; transition: border-color .2s, transform .2s; }
.mini-card:hover { border-color: var(--layer-color); transform: translateY(-3px); }
.mini-card::after { content: '↗'; position: absolute; bottom: 19px; right: 20px; color: var(--faint); font-size: 17px; }
.mini-card:hover::after { color: var(--layer-color); }
.mini-card h3 { font-size: 16px; line-height: 1.6; margin: 0 0 10px; font-weight: 600; }
.mini-card p { color: var(--dim); font-size: 13px; line-height: 1.9; margin: 0 0 13px; }
.cov { font-size: 10px; padding: 4px 7px; border-radius: 3px; display: inline-block; }
.cov.ok { background: #edf5f0; color: #2e7057; }
.cov.partial { background: #fbf2df; color: #896016; }
.search-status { font-size: 13px; color: var(--dim); margin: 0 0 22px; line-height: 1.8; }
.search-status:empty { display: none; }
.searching .study-intro, .searching .overview, .searching .study-path { display: none; }
#view-graph { overflow: hidden; background-image: radial-gradient(#b9c3d2 0.65px, transparent 0.65px); background-size: 22px 22px; }
#graph-svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#graph-svg:active { cursor: grabbing; }
.g-edge { fill: none; stroke: #9aa8bc; stroke-width: 1.2; opacity: .42; transition: stroke .2s, opacity .2s; }
.g-edge.hot { stroke: var(--accent); stroke-width: 2; opacity: 1; }
.g-edge-label { fill: var(--dim); font-size: 10px; pointer-events: none; opacity: 0; }
.g-edge-label.hot { opacity: 1; fill: var(--accent); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.g-node { cursor: pointer; }
.g-node text { fill: var(--ink); font-size: 14px; font-weight: 500; pointer-events: auto; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.g-node:hover text { fill: var(--accent); }
.g-node.dim { opacity: .18; }
.graph-hint { position: absolute; bottom: 20px; left: 24px; color: var(--dim); font-size: 11px; line-height: 1.8; background: var(--bg); padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; max-width: calc(100% - 48px); pointer-events: none; }
.graph-legend { position: absolute; top: 20px; right: 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 12px 16px; font-size: 11px; pointer-events: none; }
.graph-legend div { display: flex; align-items: center; gap: 8px; margin: 7px 0; color: var(--dim); }
.graph-legend .sw { width: 7px; height: 7px; border-radius: 50%; }
.graph-controls { position: absolute; bottom: 90px; left: 24px; display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; }
.graph-controls button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--accent); font-size: 20px; }
.graph-controls button + button { border-left: 1px solid var(--border); }
#drawer, #ann-panel { position: fixed; top: var(--header-height); right: 0; width: min(610px, 95vw); height: calc(100dvh - var(--header-height)); background: var(--panel); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .22s, visibility .22s; visibility: hidden; overflow-y: auto; z-index: 40; box-shadow: -20px 0 70px #25365212; overscroll-behavior: contain; }
#drawer.open, #ann-panel.open { transform: translateX(0); visibility: visible; }
.drawer-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--border); padding: 25px 30px 20px; z-index: 2; }
.drawer-head .layer-badge { margin: 0 9px 14px 0; }
.drawer-head h2 { font-size: 24px; line-height: 1.5; margin: 0; padding-right: 28px; }
.drawer-head .oneline { color: var(--dim); font-size: 14px; margin-top: 10px; line-height: 1.9; }
.drawer-close { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--dim); font-size: 20px; border-radius: 4px; }
.drawer-close:hover { color: var(--accent); background: var(--accent-soft); }
.drawer-body { padding: 16px 30px 60px; }
.drawer-body h4 { font-size: 16px; color: var(--accent); margin: 25px 0 12px; }
.drawer-body p, .drawer-body li { font-size: 15px; line-height: 1.95; color: var(--ink); margin: 0 0 12px; }
.drawer-body ul { padding-left: 20px; margin-bottom: 18px; }
.drawer-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 12px; line-height: 1.8; display: block; overflow-x: auto; }
.drawer-body th { background: var(--accent-soft); color: var(--accent); text-align: left; padding: 10px; border: 1px solid var(--border); }
.drawer-body td { padding: 10px; border: 1px solid var(--border); vertical-align: top; }
.drawer-body code { background: var(--panel2); padding: 2px 5px; border-radius: 3px; font: 12px var(--font-mono); color: var(--electric); }
.drawer-body blockquote { border-left: 2px solid var(--accent); padding: 9px 16px; margin: 18px 0; color: var(--dim); font-size: 14px; line-height: 1.9; }
.drawer-body mjx-container { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.sec-title { font-size: 12px; color: var(--faint); margin: 26px 0 14px; border-top: 1px solid var(--border); padding-top: 20px; }
.links a { display: block; color: var(--electric); font-size: 13px; text-decoration: none; padding: 12px 0; }
.links a:hover { text-decoration: underline; }
.links a::before { content: '↗ '; }
.edges-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.edge-chip { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; min-height: 44px; cursor: pointer; color: var(--ink); text-align: left; }
.edge-chip:hover { border-color: var(--accent); }
.edge-chip .etype { color: var(--faint); margin-right: 7px; }
#ann-toolbar { position: fixed; display: none; z-index: 60; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; padding: 4px; gap: 3px; box-shadow: 0 5px 24px #25365225; max-width: calc(100vw - 16px); }
#ann-toolbar.show { display: flex; }
#ann-toolbar button { font-size: 12px; color: var(--accent); background: transparent; border: 0; border-radius: 4px; min-height: 40px; padding: 8px 10px; }
#ann-toolbar button:hover { background: var(--accent-soft); }
.hl { background: #fff0b3; border-bottom: 1px dashed #a37315; cursor: help; }
.hl.q { background: #ffe4ce; border-bottom: 1px dashed #b76b34; }
#ann-panel { width: min(450px, 95vw); z-index: 45; }
#ann-panel .drawer-head h2 { font-size: 20px; }
.ann-item { border: 1px solid var(--border); border-radius: 4px; padding: 16px; margin: 15px 24px; background: var(--bg); }
.ann-item .quote { font-size: 13px; color: var(--dim); line-height: 1.9; margin-bottom: 8px; }
.ann-item .txt { font-size: 14px; line-height: 1.8; }
.ann-item .meta { font-size: 11px; color: var(--faint); margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ann-item .del { color: var(--magnetic); min-height: 44px; padding: 8px; border: 0; background: transparent; flex-shrink: 0; }
.ann-empty { color: var(--dim); font-size: 14px; padding: 26px; line-height: 1.9; }
@media (max-width: 1050px) {
  header { gap: 12px; padding: 12px 20px; }
  header .brand { margin-right: auto; }
  .search { order: 2; max-width: none; flex-basis: 100%; }
  .study-intro h1 { font-size: 31px; }
}
@media (max-width: 620px) {
  header { gap: 10px; padding: 10px 16px; }
  header .brand { font-size: 14px; }
  header .brand small { display: none; }
  header .brand-mark { width: 32px; font-size: 28px; }
  .tabs { order: 2; flex: 1; }
  .tab { flex: 1; padding-inline: 12px; }
  .search { order: 3; flex-basis: 100%; }
  .search input { font-size: 16px; }
  .toolbtn { font-size: 11px; padding: 8px; }
  #view-guided { padding: 28px 20px 50px; }
  .study-intro { display: block; margin-bottom: 20px; }
  .study-intro .eyebrow { font-size: 9px; }
  .study-intro h1 { font-size: 29px; }
  .study-intro p { font-size: 13px; }
  .study-stats { gap: 25px; margin-top: 20px; }
  .study-stats div { display: flex; align-items: center; gap: 9px; font-size: 10px; }
  .study-stats strong { font-size: 25px; margin: 0; }
  .study-path { gap: 5px 12px; padding-block: 9px; }
  .study-path a { font-size: 12px; gap: 6px; }
  .study-path > span { display: none; }
  .overview summary { font-size: 12px; gap: 10px; }
  .overview summary span { display: none; }
  .layer-desc { font-size: 11px; }
  .layer-head { gap: 8px; }
  .mini-card { padding: 20px; }
  .mini-card p { font-size: 14px; }
  #drawer, #ann-panel { width: 100%; }
  .drawer-head { padding: 20px; }
  .drawer-head h2 { font-size: 22px; }
  .drawer-body { padding: 12px 20px 50px; }
  .drawer-body p, .drawer-body li { font-size: 16px; }
  .graph-legend { top: 12px; right: 12px; font-size: 10px; padding: 5px 10px; }
  .graph-hint { left: 12px; bottom: 12px; max-width: calc(100% - 24px); font-size: 10px; }
  .graph-controls { left: 12px; bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) { #view-guided { scroll-behavior: auto; } }

.highlight-label { color: #896016; }

/* Cloud controls stay inside the notebook, with a compact status in the header. */
.sync-indicator { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); margin-left: 6px; vertical-align: middle; }
.sync-indicator[data-status="synced"] { background: #2e7057; }
.sync-indicator[data-status="pending"] { background: #a37315; }
.sync-indicator[data-status="syncing"] { background: var(--accent); }
.sync-box { margin: 20px 24px 8px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.sync-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.sync-heading h3 { font-size: 14px; margin: 0; }
#sync-status { color: var(--accent); font-size: 11px; }
.sync-box p { color: var(--dim); font-size: 12px; line-height: 1.85; margin: 10px 0; overflow-wrap: anywhere; }
.sync-box details { margin-top: 12px; }
.sync-box summary { font-size: 12px; color: var(--accent); cursor: pointer; padding-block: 12px; }
.sync-box label { display: block; font-size: 12px; color: var(--dim); margin: 14px 0 8px; }
.sync-box input { width: 100%; min-width: 0; height: 44px; padding: 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--ink); font-size: 14px; }
.sync-actions { display: flex; gap: 8px; margin-top: 8px; }
.sync-box form > button { margin-top: 10px; }
.sync-box button:disabled { opacity: .55; cursor: wait; }
@media (max-width: 620px) { .sync-box { margin-inline: 20px; } .sync-box input { font-size: 16px; } }
