:root {
  --bg: #faf9f5;
  --panel: #f4f2eb;
  --line: #ece8df;
  --fg: #2c271e;
  --dim: #9a9285;
  --accent: #bf982f;
  --accent-ink: #2c271e;
  --sel: #ecddb0;
  --ok: #589a64;
  --warn: #c0822f;
  --err: #c2605a;
  --tok-keyword: #9d0006;
  --tok-type: #b57614;
  --tok-string: #79740e;
  --tok-number: #8f3f71;
  --tok-comment: #a89984;
  --tok-func: #af3a03;
  --tok-attr: #427b58;
}

:root[data-theme="dark"] {
  --bg: #1b1813;
  --panel: #232019;
  --line: #2c2820;
  --fg: #e9e4d8;
  --dim: #968e7d;
  --accent: #ddb454;
  --accent-ink: #1b1813;
  --sel: #463c22;
  --ok: #80bd88;
  --warn: #d6a559;
  --err: #dd8b85;
  --tok-keyword: #fb4934;
  --tok-type: #fabd2f;
  --tok-string: #b8bb26;
  --tok-number: #d3869b;
  --tok-comment: #928374;
  --tok-func: #fe8019;
  --tok-attr: #8ec07c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

body {
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--sel);
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  font-family: system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--accent);
}

.version {
  margin-left: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--dim);
}

.version:not(:empty)::before {
  content: "v";
}

.opts {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--dim);
}

.opts label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.opts select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 12px;
  padding: 2px 6px;
}

.opts input[type="checkbox"] {
  accent-color: var(--accent);
}

.theme {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 11px;
  cursor: pointer;
}

.theme:hover {
  color: var(--fg);
  border-color: var(--accent);
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  min-height: 0;
}

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

.pane:last-child {
  border-right: none;
}

.pane:first-child .pane-head,
.pane:first-child .view {
  padding-left: 16px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 12px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
}

.view {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}

.editor {
  caret-color: var(--fg);
}

#out {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

::highlight(yuku-src) {
  background-color: var(--sel);
}

.tree {
  white-space: normal;
  line-height: 1.75;
}

.tree details {
  width: max-content;
  min-width: 100%;
}

.tree summary {
  list-style: none;
  cursor: pointer;
  white-space: pre;
  border-radius: 4px;
  padding-block: 1px;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  content: "\25B8";
  display: inline-block;
  width: 1.1em;
  color: var(--dim);
  transition: transform 0.15s ease;
}

.tree details[open] > summary::before {
  transform: rotate(90deg);
}

.tree summary:hover {
  background: var(--panel);
}

.tree details.ast-hit {
  background: color-mix(in srgb, var(--sel) 32%, transparent);
  border-radius: 4px;
}

.tree details.ast-hit > summary {
  background: var(--sel);
}

.tree .ast-body {
  margin-left: 0.65em;
  padding-left: 0.95em;
  border-left: 1px solid var(--line);
}

.tree .ast-row {
  white-space: pre;
  padding-left: 1.1em;
  padding-block: 1px;
}

.ast-type {
  color: var(--accent);
}

.ast-key {
  color: var(--tok-attr);
}

.ast-str {
  color: var(--tok-string);
}

.ast-num {
  color: var(--tok-number);
}

.ast-bool,
.ast-null {
  color: var(--tok-keyword);
}

.ast-span,
.ast-meta {
  color: var(--dim);
}

.hljs-keyword,
.hljs-literal {
  color: var(--tok-keyword);
}

.hljs-built_in,
.hljs-title.class_,
.hljs-type {
  color: var(--tok-type);
}

.hljs-string,
.hljs-regexp,
.hljs-template-tag {
  color: var(--tok-string);
}

.hljs-number {
  color: var(--tok-number);
}

.hljs-comment {
  color: var(--tok-comment);
}

.hljs-title,
.hljs-title.function_ {
  color: var(--tok-func);
}

.hljs-attr,
.hljs-property {
  color: var(--tok-attr);
}

.hljs-subst {
  color: var(--fg);
}

.tabs {
  display: flex;
  gap: 6px;
}

.tabs button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 9px;
  cursor: pointer;
}

.tabs button.active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

#status {
  padding: 7px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

#status.ok {
  color: var(--ok);
}

#status.warn {
  color: var(--warn);
}

#status.err {
  color: var(--err);
}
