/* The tool page. Colours come from tokens.css only — nothing here writes one.
   The build links tokens.css first, so every custom property is already in
   scope; this file imports nothing and loads no font. */

/* ---------- base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- main ---------- */

.main {
  flex: 1;
  padding-block: var(--space-6) var(--space-6);
}

.lead {
  max-width: 62ch;
  margin: 0 0 var(--space-5);
  color: var(--fg-dim);
  font-size: 1.0625rem;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

.control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.control-label {
  display: block;
  float: none;
  padding: 0;
  margin-bottom: var(--space-2);
  color: var(--fg-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.seg-item { position: relative; display: inline-flex; }

.seg-item input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg-item span {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--fg-dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-item input:not(:checked):hover + span { color: var(--fg); }

.seg-item input:checked + span {
  background: var(--accent-soft);
  color: var(--accent);
}

.seg-item input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- panes ---------- */

.panes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: 34px;
}

.pane-title {
  margin: 0;
  color: var(--fg-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.editor {
  width: 100%;
  min-height: clamp(280px, 44vh, 540px);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  /* Code should scroll, not wrap: a minified file is one very long line. */
  white-space: pre;
  overflow: auto;
  resize: vertical;
  caret-color: var(--accent);
  transition: border-color 0.15s ease;
}

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

/* Code must not wrap, but the hint should — otherwise it is cut off on a phone. */
.editor:placeholder-shown { white-space: pre-wrap; }

.editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

#output { background: var(--bg-sunken); }

/* ---------- run bar ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--fg-dim);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--bg-sunken); color: var(--fg); }

.btn:disabled { cursor: default; opacity: 0.55; }
.btn:disabled:hover { background: var(--bg-raised); color: var(--fg-dim); }

.btn.is-done { color: var(--ok); border-color: var(--ok); }

.btn-run {
  min-width: 170px;
  padding: 13px var(--space-6);
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
}

.btn-run:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
.btn-run:disabled:hover { background: var(--accent); color: var(--accent-ink); filter: none; }

.runbar {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-top: var(--space-5);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0;
}

.stat { display: flex; flex-direction: column; gap: 2px; }

.stats dt {
  color: var(--fg-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- messages ---------- */

.msg {
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--err);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font-size: 14px;
}

.quota {
  margin: var(--space-3) 0 0;
  color: var(--fg-dim);
  font-size: 13px;
}

.quota span:first-child { color: var(--fg-faint); }

.note {
  max-width: 70ch;
  margin: var(--space-4) 0 0;
  color: var(--fg-faint);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- drop overlay ---------- */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--accent-soft);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.dropzone-card {
  padding: var(--space-4) var(--space-5);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-weight: 600;
  text-align: center;
}

/* ---------- narrow screens ---------- */

@media (max-width: 820px) {
  .panes { grid-template-columns: 1fr; }
  .editor { min-height: clamp(200px, 34vh, 380px); }
}

@media (max-width: 640px) {
  .main { padding-block: var(--space-5); }

  .controls { gap: var(--space-4); }

  /* 16px keeps iOS from zooming in when the editor takes focus. */
  .editor { font-size: 16px; }

  .runbar { align-items: stretch; flex-direction: column; gap: var(--space-4); }
  .btn-run { width: 100%; }

  .stats { gap: var(--space-3) var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
