/*
 * The panel's stylesheet.
 *
 * One file, no framework, no build. It is compiled into the binary, so
 * every kilobyte here is a kilobyte in `lexd` — which is a good reason to
 * keep it plain, and a good reason it looks the way it does.
 */

:root {
  --ink: #14161a;
  --ink-soft: #5b626e;
  --ink-faint: #8b929e;
  --line: #e4e6ea;
  --paper: #ffffff;
  --ground: #f7f8fa;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --good: #17803d;
  --bad: #cf2f26;
  --warn: #a86a00;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eceef2;
    --ink-soft: #99a1ae;
    --ink-faint: #6d7480;
    --line: #262a31;
    --paper: #16191e;
    --ground: #0e1114;
    --accent: #6f96ff;
    --accent-ink: #0e1114;
    --good: #3ecf72;
    --bad: #ff6b60;
    --warn: #e0a33a;
  }
}

* {
  box-sizing: border-box;
}

/*
 * `hidden` has to win.
 *
 * The attribute only sets `display: none` through the browser's own
 * stylesheet, so any author rule setting `display` beats it — and both the
 * gate and the app below set `display: grid`. Without this line the sign-in
 * screen stays on top of the panel it just opened, which looks exactly
 * like a button that does nothing.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

h1,
h2,
h3 {
  letter-spacing: -0.01em;
}

/* ── the gate ────────────────────────────────────────────────────── */

.gate {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.gate__card {
  width: min(420px, 100%);
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.gate__card h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.gate__lead {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

.gate__error {
  margin: 0 0 12px;
  color: var(--bad);
  font-size: 14px;
}

.gate__note {
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
}

/* ── form parts ──────────────────────────────────────────────────── */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 9px 12px;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  resize: vertical;
  min-height: 40px;
  field-sizing: content;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.button--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button--primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button--quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.button--quiet:hover:not(:disabled) {
  color: var(--ink);
}

.button--danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--bad) 40%, var(--line));
  color: var(--bad);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ── chrome ──────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar__scope {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 13px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

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

.tab {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab--on {
  background: var(--ground);
  color: var(--ink);
  font-weight: 550;
}

.pill {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
}

/* ── views ───────────────────────────────────────────────────────── */

.view {
  padding: 24px;
  overflow-y: auto;
}

.stack {
  display: grid;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0;
  font-size: 17px;
}

.card__note {
  color: var(--ink-soft);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat {
  padding: 14px 16px;
  background: var(--ground);
  border-radius: 8px;
}

.stat__value {
  font-size: 24px;
  font-weight: 620;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ── tables ──────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: start;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 550;
  font-size: 13px;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

/* Cells holding an unpublished edit. */
td.edited textarea {
  border-color: var(--accent);
}

td.edited::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--accent);
}

/* ── small parts ─────────────────────────────────────────────────── */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.tag--on {
  border-color: transparent;
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
}

.tag--off {
  border-style: dashed;
}

.tag--warn {
  border-color: transparent;
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}

.tag--accent {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

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

.row--tight {
  gap: 6px;
}

.spacer {
  margin-inline-start: auto;
}

.muted {
  color: var(--ink-soft);
}

.faint {
  color: var(--ink-faint);
}

.empty {
  padding: 28px 0;
  text-align: center;
  color: var(--ink-soft);
}

.error {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bad) 12%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
  color: color-mix(in srgb, var(--bad) 75%, var(--ink));
  font-family: var(--mono);
  font-size: 13px;
}

pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--ground);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

/* ── the split panes some views use ──────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.bar__track {
  height: 10px;
  border-radius: 999px;
  background: var(--ground);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.bar__value {
  text-align: end;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* ── toast ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--ink);
  color: var(--ground);
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  z-index: 20;
}

@media (max-width: 980px) {
  .split {
    grid-template-columns: 1fr;
  }
  .tabs {
    overflow-x: auto;
  }
  .topbar {
    flex-wrap: wrap;
  }
}

/* ── the shapes the rewritten screens use ────────────────────────── */

/* A first screen with one thing to do, rather than six empty counters. */
.card--welcome {
  padding: 40px;
  text-align: center;
}

.card--welcome h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

/* One sentence under a title, saying what the screen is for. */
.lead {
  max-width: 62ch;
  margin: 0 0 18px;
  color: var(--ink-soft);
}

.card--welcome .lead {
  margin-inline: auto;
}

.mini-title {
  margin: 0 0 10px;
  font-size: 15px;
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar input[type="search"] {
  flex: 2;
}

.toolbar input:not([type="search"]) {
  flex: 1;
}

.hint {
  margin: 14px 0 0;
}

.grow {
  flex: 1;
}

/* The text grid: names on the left, one column per language. */
.grid-table th:first-child,
.grid-table td.cell-key {
  width: 22%;
  min-width: 180px;
}

.grid-table td.cell-key code {
  color: var(--ink-soft);
  word-break: break-all;
}

.grid-table textarea {
  min-height: 38px;
}

/* A preview: the name above, the sentence a visitor reads below. */
.preview {
  margin: 0;
  display: grid;
  gap: 2px;
}

.preview dt {
  color: var(--ink-faint);
  font-size: 12px;
}

.preview dd {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.preview dd:last-child {
  border-bottom: 0;
}

.log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.log li {
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}

/* A share of traffic, as a percentage — nobody types 500 meaning 5%. */
.share {
  min-width: 4ch;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.variant {
  margin-bottom: 8px;
}

.variant input:first-child {
  flex: 2;
}

.variant .weight {
  flex: 0 0 88px;
}

details.aside {
  padding: 16px 20px;
}

details.aside summary {
  cursor: pointer;
  font-weight: 550;
}

details.aside p {
  margin: 12px 0 0;
  max-width: 70ch;
}

/* ── the Start screen ────────────────────────────────────────────── */

.address {
  padding: 8px 14px;
  background: var(--ground);
  border-radius: 8px;
  font-size: 14px;
  word-break: break-all;
}

.platforms {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* The snippet, with its copy button in the corner. */
.code-block {
  position: relative;
}

.code-block pre {
  padding-inline-end: 90px;
  max-height: 460px;
  overflow: auto;
  line-height: 1.6;
}

.code-block .copy {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  background: var(--paper);
}

/* Three short facts, each a term and its explanation. */
.facts {
  margin: 0;
  display: grid;
  gap: 4px;
}

.facts dt {
  font-weight: 600;
  margin-top: 12px;
}

.facts dt:first-child {
  margin-top: 0;
}

.facts dd {
  margin: 0;
  max-width: 72ch;
  color: var(--ink-soft);
}

/* Ticking the texts a screen needs. */
.pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px 16px;
  max-height: 280px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pick__item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.pick__item input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

button.mono {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 10px;
}
