* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}

code, pre, .console, .console input, .input-highlight {
  font-family: Consolas, "Cascadia Mono", Menlo, monospace;
}

.topbar {
  flex: none;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #1e293b;
  color: #fff;
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.button, button {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  text-decoration: none;
}

.topbar .button {
  background: #334155;
  border-color: #475569;
  color: #fff;
}

.views {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.views .calc-page {
  flex: 1 1 auto;
  min-width: 160px;
  overflow: auto;
}

.views .help-page {
  flex: 0 0 0;
  min-width: 0;
  max-width: none;
  overflow: hidden;
}

.views.help-open .help-page {
  min-width: 160px;
  overflow: auto;
}

.splitter {
  flex: none;
  width: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #cbd5e1;
  cursor: col-resize;
}

.splitter:hover,
.splitter:focus,
body.is-resizing .splitter {
  background: #64748b;
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing iframe,
body.is-resizing .help-page,
body.is-resizing .calc-page {
  pointer-events: none;
}

/* Calculator page */

.calc-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
}

.console {
  width: 100%;
  max-width: 860px;
  flex: 1;
  min-height: 260px;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 6px;
  --bg: #0f172a;
  background: var(--bg);
  --text: #cbd1d8;
  color: var(--text);
  font-size: 15px;
  line-height: 24px;
}

.console .line { white-space: pre-wrap; overflow-wrap: anywhere; }
.console .muted { color: #94a3b8; }
.console .in::before { content: "> "; color: #38bdf8; }
.console .out { color: #4ade80; padding-left: 2ch; cursor: pointer; }
.console .out.copied { color: #fde047; }
.console .err { color: #f87171; padding-left: 2ch; }

.prompt {
  display: flex;
  align-items: center;
  margin-top: 4px;
  border-bottom: 1px solid #334155;
}

.prompt label { color: #38bdf8; padding-right: 1ch; }

.input-wrap {
  flex: 1;
  position: relative;
  isolation: isolate;
  min-width: 0;
  align-self: stretch;
}

.input-highlight,
.prompt input {
  font-size: 15px;
  line-height: 24px;
}

.input-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  white-space: pre;
  color: color-mix(in srgb, var(--text) 96%, white);
  pointer-events: none;
}

.input-highlight .fn {
  color: #62c8f8;
}

.console .in .fn { color: #62c8f8; }

.prompt input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #e2e8f0;
}

.console ::selection,
.prompt input::selection {
  color: #d4dae2;
  background: #256eb8;
}

.prompt input::selection {
  -webkit-text-fill-color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  max-width: 860px;
  margin-top: 8px;
  color: #6b7280;
  font-size: 13px;
}

/* Help page */

.help-page {
  display: flex;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
  gap: 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 12px;
  overflow: auto;
  background: #eceef2;
}

.help-page nav {
  flex: none;
  width: 270px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #eceef2;
  font-size: 13px;
}

/* The document title is the single root entry of the generated contents; show its children only. */
.help-page nav > ul > li > a { display: none; }
.help-page nav ul { list-style: none; margin: 0; padding-left: 12px; }
.help-page nav > ul, .help-page nav > ul > li > ul { padding-left: 0; }
.help-page nav a { display: block; padding: 2px 0; color: #2563eb; text-decoration: none; }
.help-page nav > ul > li > ul > li > a { font-weight: 600; margin-top: 6px; }

.help-page main {
  flex: 1;
  min-width: 0;
  min-height: calc(100% - 32px);
  padding: 8px 28px 28px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #eceef2;
}

.help-page main h1 { font-size: 26px; }
.help-page main h2 { margin-top: 32px; padding-bottom: 4px; border-bottom: 1px solid #e5e7eb; font-size: 21px; }
.help-page main h3 { margin-top: 22px; font-size: 17px; }
.help-page main a { color: #2563eb; }
.help-page main code { padding: 1px 4px; border-radius: 3px; background: #e2e5ea; font-size: 0.92em; }
.help-page main pre { padding: 10px 12px; overflow-x: auto; border-radius: 4px; background: #e2e5ea; }
.help-page main pre code { padding: 0; background: none; }
.help-page main table { border-collapse: collapse; margin: 8px 0; }
.help-page main th, .help-page main td { padding: 4px 10px; border: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.help-page main th { background: #e4e7ec; }

.web-note {
  margin: 16px 0 0;
  padding: 8px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  background: #eff6ff;
  font-size: 14px;
}

@media (max-width: 760px) {
  .help-page { flex-direction: column; }
  .help-page nav { position: static; width: auto; max-height: 260px; }
  .help-page main { padding: 4px 14px 16px; }
}
