:root {
  --bg: #0d1217;
  --panel: #121922;
  --panel-2: #182230;
  --border: #2c3a4a;
  --text: #dce6f0;
  --muted: #97a8ba;
  --tab-size: 2;
  --split-row: 50%;
  --split-col: 50%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: #0f1620;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-byline {
  font-size: 12px;
  font-weight: 500;
  color: #88a0b8;
  margin-left: 6px;
}

.menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabsize-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tabsize-control select {
  border: 1px solid var(--border);
  background: #132030;
  color: #dce6f0;
  border-radius: 6px;
  padding: 2px 6px;
}

.docs-button {
  border: 1px solid #2f75b3;
  background: #18324b;
  color: #e2f1ff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}

.docs-button:hover {
  background: #20415f;
}

.workspace {
  min-height: 0;
  display: flex;
  gap: 0;
  padding: 10px;
  flex-direction: column;
}

.workspace.is-landscape {
  flex-direction: row;
}

.pane {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr);
}

.pane-code {
  flex: 0 0 var(--split-col);
  min-width: 220px;
}

.pane-preview {
  flex: 1 1 auto;
  min-width: 220px;
}

.workspace.is-portrait .pane-code {
  flex-basis: var(--split-row);
  min-height: 160px;
}

.workspace.is-portrait .pane-preview {
  min-height: 160px;
}

.splitter {
  flex: 0 0 10px;
  border: 1px solid var(--border);
  background: #111a26;
  border-radius: 8px;
  margin: 0 8px;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.workspace.is-portrait .splitter {
  margin: 8px 0;
  cursor: row-resize;
}

.splitter::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, transparent 40%, #2d3d50 40% 60%, transparent 60%);
  opacity: 0.8;
}

.workspace.is-portrait .splitter::before {
  background:
    linear-gradient(0deg, transparent 40%, #2d3d50 40% 60%, transparent 60%);
}

.pane-title {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.editor-shell {
  position: relative;
  min-height: 0;
  height: 100%;
}

#editor-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  border: 0;
  white-space: pre;
  overflow: auto;
  pointer-events: none;
  background: #0f1722;
  color: #dfe8f3;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: var(--tab-size);
}

#editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #dfe8f3;
  -webkit-text-fill-color: transparent;
  tab-size: var(--tab-size);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px;
}

#editor::selection {
  background: rgba(94, 160, 220, 0.35);
}

.tok-kw { color: #7cc6ff; font-weight: 600; }
.tok-screen { color: #ff8fb1; font-weight: 700; }
.tok-view-decl { color: #8df6d8; font-weight: 700; }
.tok-view-use { color: #69d0ff; font-weight: 700; }
.tok-attr-key { color: #ffd580; }
.tok-attr-val { color: #b4f0c0; }
.tok-ref { color: #ffb3e0; font-weight: 600; }
.tok-str { color: #a9d1ff; }
.tok-op { color: #ff9f9f; }
.tok-sym { color: #c7cfe0; }

.preview-host {
  width: 100%;
  height: 100%;
  background: #0b1016;
  overflow: auto;
}

.preview-empty {
  color: #9aa9ba;
  padding: 10px;
  font-size: 13px;
}

@media (max-width: 680px) {
  .topbar {
    padding-inline: 10px;
  }

  .menu {
    gap: 6px;
  }
  .brand-byline {
    display: none;
  }
}
