/* INFO: Top input, left text, right inspector. The page fills the window; each pane scrolls on its own. Dark only. */
:root {
  color-scheme: dark;
  --ink: #d9d7d2;
  --dim: #8b8b92;
  --line: #34363c;
  --paper: #16171a;
  --panel: #1f2125;
  --pick: #e0a800;
  --pick-ink: #16171a;
  --pick-edge: #ffd24a;
  --range: rgba(224, 168, 0, 0.18);
  --match: rgba(90, 160, 255, 0.35);
  --unknown: #e06a6a;
  --call: #8fb4ff;
  --name: #84c98a;
  --note-bg: #2a2416;
  --note-edge: #6a5520;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  scrollbar-color: var(--line) var(--paper);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  font: 16px/1.5 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button, input, textarea { font: inherit; color: inherit; background: var(--panel); }

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25em 0.7em;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

#entry { display: flex; gap: 0.5em; align-items: center; padding: 0.6em 0.8em; border-bottom: 1px solid var(--line); }
#source {
  flex: 1;
  min-width: 0;
  resize: none;
  font-family: Georgia, serif;
  padding: 0.3em 0.6em;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.samples { white-space: nowrap; color: var(--dim); cursor: pointer; }
#sample-count { width: 4.5em; padding: 0.25em 0.3em; border: 1px solid var(--line); border-radius: 6px; }
.open {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25em 0.7em;
  background: var(--panel);
  cursor: pointer;
  white-space: nowrap;
}

#main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
}

#text-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}

#passage {
  flex: 1;
  overflow: auto;
  padding: 1em 1.2em;
  font: 1.15em/1.9 Georgia, serif;
  white-space: pre-wrap;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.w { cursor: pointer; border-radius: 3px; padding: 0 1px; }
.w.unknown { text-decoration: underline dotted var(--unknown); text-underline-offset: 3px; }
.w.inrange { background: var(--range); }
#passage.all { background: var(--range); }
#passage .w.match { background: var(--match); }
/* NOTE: After matches, so the selected word stays readable inside one. An inset shadow, not an outline: in Firefox
   an outline made a long text lay out again, 110 ms for a book. */
#passage .w.selected { background: var(--pick); color: var(--pick-ink); box-shadow: inset 0 0 0 2px var(--pick-edge); }

#search-bar {
  display: flex;
  gap: 0.4em;
  align-items: center;
  padding: 0.5em 0.8em;
  border-top: 1px solid var(--line);
}
#search { flex: 1; min-width: 0; padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; }
#search-count { color: var(--dim); font-size: 0.85em; white-space: nowrap; }

#inspector { display: flex; flex-direction: column; min-height: 0; }

#word { margin: 0; padding: 0.5em 1em 0; font: 1.5em Georgia, serif; min-height: 1.5em; }

#views { display: flex; gap: 0.3em; align-items: center; padding: 0.5em 1em; border-top: 1px solid var(--line); }
#views button.on, .bindings button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

#view { flex: 1; overflow: hidden auto; touch-action: pan-y; overflow-wrap: anywhere; padding: 0.8em 1em 2em; }

.record {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.6em 0.8em; margin-bottom: 0.8em;
  background: var(--panel);
}
.meaning { font-weight: 600; }
.meta { color: var(--dim); font-size: 0.88em; }
.entry { margin-top: 0.4em; }
.reading { display: grid; grid-template-columns: 1.6em 8em 1fr; gap: 0.5em; margin-top: 0.5em; }
.reading .n { color: var(--dim); text-align: right; }
.split { font-family: var(--mono); }
.none { color: var(--dim); }
.internal {
  background: var(--note-bg); border: 1px solid var(--note-edge); border-radius: 6px; padding: 0.4em 0.7em;
  font-size: 0.9em;
}

.group-head { font: 1.2em Georgia, serif; margin: 1.2em 0 0.4em; border-bottom: 1px solid var(--line); }
.group-head .count { color: var(--dim); font-size: 0.8em; }
.more { color: var(--dim); padding: 1em 0; }
.instances { line-height: 1.7; }

.block-head { font-family: var(--mono); font-size: 0.9em; margin: 1em 0 0.2em; font-weight: 600; }
.block-head.sub { margin-left: 1.2em; }
.block-head.call { color: var(--call); }
.call-line { font: 0.85em/1.5 var(--mono); margin: 0.2em 0 0 1.4em; color: var(--call); }
.block-head .type, .block-head .n { color: var(--dim); font-weight: normal; }

table.rows {
  border-collapse: collapse; font: 0.85em/1.5 var(--mono); margin-left: 1.2em; max-width: calc(100% - 1.2em);
}
table.rows td { padding: 0 1em 0 0; white-space: nowrap; vertical-align: top; }
table.rows td.value { white-space: normal; }
table.rows .type { color: var(--dim); }
table.rows .name { color: var(--name); }
table.rows.api { width: min(90ch, calc(100% - 1.2em)); }
table.rows.api td.value { white-space: normal; overflow-wrap: anywhere; }

table.rows tr.dim td { color: var(--dim); }
table.rows td.bar { color: var(--pick); letter-spacing: -1px; }
table.rows td.path-line { overflow-wrap: normal; color: var(--dim); padding-bottom: 0.5em; }
table.counts td.value { white-space: normal; max-width: none; line-height: 1.9; }
button.value { font: inherit; padding: 0 0.4em; margin: 0 0.2em 0.2em 0; border-radius: 4px; }

@media (max-width: 700px) {
  #main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 2fr) minmax(0, 3fr); }
  #text-pane { border-right: none; border-bottom: 1px solid var(--line); }
}
