/* Square Windows 98 chrome, with colors sampled from the game's interface.
   FRM_0101: #397991 to #7FBBCF; FRM_0102: #694169 to #AF8FBF.
   FRM_02A01 control fill: #185868. MessageFrame.tjs text: #FFFFFF.
   See game-palette.json for source coordinates and original/installed text styles. */
:root {
  color-scheme: light;
  --bg: #af8fbf;
  --panel: #ffffff;
  --paper: #ffffff;
  --light: #fff;
  --shadow: #81a6b2;
  --dark: #397991;
  --text: #185868;
  --muted: #397991;
  --accent: #185868;
  --common: #7fbbcf;
  --choice: #185868;
  --ending: #397991;
  --title: #185868;
  --game-text: #ffffff;
  --game-read-text: #d2eaff;
  --game-text-shadow: #004080;
  --raised: inset 1px 1px #fff, inset -1px -1px #81a6b2;
  --sunken: inset 1px 1px #81a6b2, inset -1px -1px #fff;
}
* { box-sizing: border-box; border-radius: 0 !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 12px/1.45 Tahoma, "MS Sans Serif", Arial, sans-serif; }
button, select, input { font: inherit; color: var(--text); }
button, select, .file-button {
  background: var(--panel); border: 1px solid var(--dark); box-shadow: var(--raised);
  padding: 5px 10px; min-height: 26px;
}
button, .file-button { cursor: pointer; background: #397991; color: var(--game-text); text-shadow: 1px 1px var(--game-text-shadow); }
button:hover, .file-button:hover { background: #185868; }
button:active, button.active, button[aria-pressed="true"], .file-button:active {
  box-shadow: var(--sunken); background: #185868;
}
button:disabled { color: var(--game-read-text); cursor: default; opacity: .65; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, #viewport:focus-visible {
  outline: 1px dotted var(--text); outline-offset: -4px;
}
input[type=checkbox] {
  appearance: none; width: 14px; height: 14px; margin: 0 2px 0 0; position: relative;
  background: white; border: 1px solid var(--dark); box-shadow: var(--sunken); flex-shrink: 0;
}
input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 3px; top: 2px; width: 7px; height: 5px;
  border-left: 2px solid var(--text); border-bottom: 2px solid var(--text); transform: rotate(-45deg);
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 8px 8px 0; padding: 5px 8px; background: var(--title); color: var(--game-text); text-shadow: 1px 1px var(--game-text-shadow);
  border: 1px solid var(--dark); box-shadow: var(--raised); min-height: 34px;
}
h1 { display: flex; align-items: center; gap: 9px; font-size: 14px; margin: 0; font-weight: bold; letter-spacing: 0; }
h1::before {
  content: ""; width: 16px; height: 14px; flex-shrink: 0; background: #ffffff;
  border: 1px solid #185868; box-shadow: inset 0 3px #397991, inset 1px 1px white, 1px 1px #d2eaff;
}
h1 span { font-size: 12px; font-weight: normal; color: #ffffff; }
.stats { font-size: 11px; color: #185868; white-space: nowrap; background: #ffffff; padding: 2px 6px; box-shadow: var(--sunken); text-shadow: none; }
.toolbar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 8px 10px;
  margin: 0 8px; background: var(--panel); border: 1px solid var(--dark); border-top: 0;
  box-shadow: var(--raised);
}
.toolbar label { display: flex; align-items: center; gap: 7px; font-size: 11px; }
select { max-width: 210px; background-color: #ffffff; box-shadow: var(--sunken); padding: 4px 7px; }
.tabs { display: flex; gap: 3px; }
.search { margin-left: auto; }
.search input {
  width: 250px; padding: 5px 8px; background: var(--paper); border: 1px solid var(--dark);
  box-shadow: var(--sunken); min-height: 26px;
}
input::placeholder { color: #397991; }
main { display: grid; grid-template-columns: minmax(300px,1fr) minmax(440px,55%); gap: 14px; padding: 12px 8px 16px; }
main.assets-wide { grid-template-columns: minmax(220px,1fr) minmax(440px,72%); }
.map-panel, .assets-panel, .path-panel, .evidence-panel {
  background: var(--panel); border: 1px solid var(--dark); box-shadow: var(--raised); min-width: 0;
}
.map-panel { padding: 3px; overflow: hidden; }
.map-caption {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 7px; min-height: 30px; font-size: 12px; font-weight: bold;
  background: var(--title); color: var(--game-text); text-shadow: 1px 1px var(--game-text-shadow);
}
.map-gesture { display: flex; gap: 10px; align-items: center; font-size: 11px; font-weight: normal; }
#zoom-label { font-variant-numeric: tabular-nums; min-width: 37px; text-align: center; padding: 1px 4px; background: #ffffff; color: #185868; box-shadow: var(--sunken); text-shadow: none; }
#viewport {
  height: calc(100dvh - 185px); min-height: 450px; overflow: clip; position: relative;
  margin-top: 3px; border: 1px solid var(--shadow); background-color: var(--paper);
  background-image: radial-gradient(#e3f0f8 1px,transparent 1px); background-size: 22px 22px;
  cursor: grab; touch-action: none; user-select: none;
}
#viewport.panning, #viewport.panning .node { cursor: grabbing; }
#canvas { position: relative; transform-origin: 0 0; min-width: 0; }
#arrows { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: #5b9ab0; stroke-width: 1.7; opacity: .8; }
.edge.highlight { stroke: #185868; stroke-width: 2.8; opacity: 1; }
.edge.path { stroke: #185868; stroke-width: 2.7; opacity: 1; }
.edge-label { fill: #397991; font: 11px Tahoma,Arial,sans-serif; paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.node {
  position: absolute; width: 250px; min-height: 70px; padding: 10px 12px; text-align: left;
  display: block; white-space: normal; background: #397991; color: var(--game-text);
  border: 1px solid var(--dark); border-left: 4px solid var(--common); box-shadow: var(--raised);
}
.node strong { display: block; font-size: 14px; font-weight: bold; }
.node small { display: block; color: var(--game-read-text); font-size: 11px; margin-top: 4px; }
.node .option { display: block; font-size: 12px; margin-top: 7px; padding-top: 5px; border-top: 1px solid #81a6b2; }
.node.choice { border-left-color: #7fbbcf; background: #397991; }
.node.ending { border-left-color: #7fbbcf; background: #397991; }
.node.condition { border-left-color: #7fbbcf; background: #397991; }
.node.route-Sora { border-left-color: #7fbbcf; }
.node.route-Nao { border-left-color: #7fbbcf; }
.node.route-Akira { border-left-color: #7fbbcf; }
.node.route-Kazuha { border-left-color: #7fbbcf; }
.node.route-Motoka { border-left-color: #7fbbcf; }
.node.dim { opacity: .35; }
.node.related, .node.match { outline: 1px solid #5b9ab0; outline-offset: 1px; }
.node.selected { outline: 2px solid #185868; outline-offset: 2px; }
.node.selected strong { color: var(--game-text); }
.node.onpath { box-shadow: var(--raised), 0 0 0 1px #185868; }
.node.onpath small { color: var(--game-read-text); }
.node.chapter { min-height: 96px; padding: 16px 14px; }
.node.chapter strong { font-size: 15px; line-height: 1.4; }
.node.chapter small { margin-top: 10px; }
.lane-title { position: absolute; width: 250px; text-align: center; font-size: 12px; font-weight: bold; color: var(--muted); }
.legend { padding: 6px 8px; display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 11px; margin-top: 3px; box-shadow: var(--sunken); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { display: block; width: 8px; height: 8px; background: var(--common); border: 1px solid #397991; }
.legend .choice { background: var(--choice); }
.legend .ending { background: var(--ending); }
aside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.assets-panel, .path-panel, .evidence-panel { padding: 12px; }
h2 { font-size: 12px; margin: 0; font-weight: bold; }
.panel-heading, #chapter-title, .evidence-panel > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 28px; padding: 3px 6px; margin: -9px -9px 12px;
  background: var(--title); color: var(--game-text); text-shadow: 1px 1px var(--game-text-shadow);
}
.panel-heading button { font-size: 11px; padding: 2px 8px; min-height: 21px; }
.panel-controls { display: flex; gap: 5px; flex-shrink: 0; }
.route-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.route-buttons button { font-size: 12px; padding: 6px 12px; }
p { color: var(--muted); font-size: 12px; margin: 10px 0; }
.path-choice { border-left: 2px solid var(--choice); padding: 4px 10px; margin: 12px 0; font-size: 12px; }
.path-choice small { display: block; color: var(--muted); margin-top: 3px; }
.evidence-panel { min-height: 0; max-height: 360px; overflow: auto; }
.evidence-panel > summary { display: list-item; cursor: pointer; margin-bottom: -9px; font-size: 12px; }
.evidence-panel[open] > summary { margin-bottom: 12px; }
#details { font-size: 12px; color: #185868; }
.source-label { color: var(--muted); font-size: 11px; margin: 12px 0 5px; overflow-wrap: anywhere; }
.command { font: 11px/1.55 ui-monospace,monospace; background: var(--paper); padding: 8px; box-shadow: var(--sunken); white-space: pre-wrap; overflow-wrap: anywhere; color: #185868; margin: 4px 0; }
.evidence-link { display: block; width: 100%; text-align: left; font-size: 11px; margin: 5px 0; padding: 6px; }
.source-line { color: #397991; margin-right: 8px; }
a { color: #185868; }
.asset-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 13px; background: white; border: 1px solid #81a6b2; box-shadow: var(--sunken); }
.asset-actions.dragging { outline: 2px dotted #185868; background: #e3f0f8; }
.file-button { position: relative; overflow: hidden; display: inline-block; padding: 7px 12px; font-size: 12px; }
.file-button input { position: absolute; width: 100%; height: 100%; inset: 0; opacity: 0; cursor: pointer; }
.drop-hint { color: var(--muted); font-size: 11px; }
.asset-badge { display: inline-block; margin-top: 6px; padding: 2px 6px; font-size: 10px; background: #e3f0f8; color: #185868; box-shadow: var(--sunken); }
#asset-status { padding: 3px 6px; box-shadow: var(--sunken); }
#asset-status:empty { display: none; }
#asset-tabs { display: flex; gap: 3px; margin: 16px 0 12px; padding-bottom: 2px; border-bottom: 1px solid #81a6b2; }
#asset-tabs button { flex: 1; padding: 8px 12px; font-size: 12px; }
#asset-tabs button.active { background: #185868; box-shadow: var(--raised); font-weight: bold; }
#scene-assets { max-height: max(320px,calc(100dvh - 270px)); min-height: 80px; padding-right: 4px; overflow: auto; scrollbar-gutter: stable; }
.asset-card { margin: 0 0 18px; padding: 10px; background: white; border: 1px solid #81a6b2; box-shadow: var(--sunken); }
.asset-card img, .asset-card video { display: block; width: 100%; object-fit: contain; background: #185868; }
.asset-card img { max-height: 65vh; }
.asset-card video { aspect-ratio: 16/9; height: auto; max-height: max(180px,min(52vh,calc(100dvh - 370px),720px)); }
.asset-card audio { width: 100%; height: 42px; }
.asset-card figcaption { font-size: 12px; color: var(--text); margin-top: 10px; overflow-wrap: anywhere; }
.asset-card small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.assets-wide #scene-assets { max-height: max(320px,calc(100dvh - 220px)); }
.assets-wide .asset-card video { max-height: max(180px,min(68vh,calc(100dvh - 300px),860px)); }
#unmatched-assets { margin-top: 12px; }
#unmatched-assets summary { cursor: pointer; font-size: 12px; }
.unmatched-row { display: block; font-size: 11px; overflow-wrap: anywhere; margin: 12px 0; }
.unmatched-row select { display: block; margin-top: 5px; width: 100%; max-width: none; font-size: 11px; }
#chapter-panel[hidden], #filter-wrap[hidden] { display: none; }
#chapter-scenes { display: grid; grid-template-columns: repeat(auto-fit,minmax(110px,1fr)); gap: 7px; max-height: 260px; overflow: auto; }
.chapter-scene { text-align: left; font-size: 12px; }
.chapter-scene small { display: block; color: var(--game-read-text); font-size: 10px; }
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: repeating-conic-gradient(#81a6b2 0 25%,#ffffff 0 50%) 0/2px 2px; }
::-webkit-scrollbar-thumb { background: #e3f0f8; border: 1px solid var(--dark); box-shadow: var(--raised); }
::-webkit-scrollbar-button { display: block; height: 16px; width: 16px; background: #e3f0f8; border: 1px solid var(--dark); box-shadow: var(--raised); }
::-webkit-scrollbar-button:vertical:decrement { background: #e3f0f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23185868' d='M2 8L6 3L10 8Z'/%3E%3C/svg%3E") center/12px no-repeat; }
::-webkit-scrollbar-button:vertical:increment { background: #e3f0f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23185868' d='M2 4L6 9L10 4Z'/%3E%3C/svg%3E") center/12px no-repeat; }
::-webkit-scrollbar-corner { background: var(--panel); }
audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel { border-radius: 0; }
@media (max-width: 950px) {
  main, main.assets-wide { grid-template-columns: 1fr; gap: 14px; }
  #viewport { height: 65vh; }
  .panel-controls #expand-assets { display: none; }
  .search { margin-left: 0; }
  .stats { white-space: normal; max-width: 170px; text-align: right; }
}
@media (max-width: 600px) {
  header { gap: 8px; }
  h1 { flex-wrap: wrap; gap: 5px; font-size: 13px; }
  h1 span { font-size: 11px; }
  .stats { font-size: 10px; max-width: 120px; }
  .toolbar { gap: 9px; }
  .search input { width: 200px; }
  .map-gesture { font-size: 10px; gap: 6px; }
  .legend { gap: 10px; }
  .asset-actions { padding: 10px; gap: 7px; }
  .asset-card { padding: 8px; }
}
