/* Components: buttons, segmented controls, chips, panes, panels, tables, cards. No inline styles anywhere. */
a {
  color: var(--accent);
}
code,
pre,
.mono {
  font-family: var(--mono);
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  margin: 0;
}
.ico {
  width: 18px;
  height: 18px;
  flex: none;
}

/* ---------------------------------------------------------------- brand and header */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand .tag {
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 18px;
  text-transform: uppercase;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.tabs {
  display: flex;
  gap: 6px;
}
.tab {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--fast),
    border-color var(--fast),
    color var(--fast);
}
.tab:hover {
  border-color: var(--accent);
}
.tab[aria-expanded="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition:
    transform var(--fast) var(--ease),
    border-color var(--fast);
}
.pill:hover {
  border-color: var(--accent);
}
.pill:active {
  transform: scale(0.97);
}
.pill code {
  font-size: 13px;
}
.pill .ico {
  width: 15px;
  height: 15px;
  color: var(--muted);
}
.release {
  white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */
.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  transition:
    transform var(--fast) var(--ease),
    background-color var(--fast),
    border-color var(--fast);
}
.btn {
  padding: 0 16px;
}
.btn.small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.icon-btn {
  width: 38px;
  color: var(--muted);
}
.btn:hover,
.icon-btn:hover {
  background: var(--surface-2);
}
.icon-btn:hover {
  color: var(--fg);
}
.btn:active,
.icon-btn:active {
  transform: scale(0.95);
}
.btn.primary {
  min-width: 112px;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}
#share .i-check {
  display: none;
}
#share[data-done] .i-link {
  display: none;
}
#share[data-done] .i-check {
  display: block;
  color: var(--ok);
}
#play {
  width: 112px;
}
#play .i-pause {
  display: none;
}
#play[data-state="playing"] .i-pause {
  display: block;
}
#play[data-state="playing"] .i-play {
  display: none;
}
.top .icon-btn {
  border-color: transparent;
  background: transparent;
}
.top .icon-btn:hover {
  background: var(--surface-2);
}
.sun {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun {
    display: block;
  }
  :root:not([data-theme="light"]) .moon {
    display: none;
  }
}
:root[data-theme="dark"] .sun {
  display: block;
}
:root[data-theme="dark"] .moon {
  display: none;
}

/* ---------------------------------------------------------------- segmented controls (the pill slides in CSS alone) */
.gl {
  padding-left: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.seg {
  --n: 3;
  --i: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.seg.n9 {
  --n: 9;
}
.seg::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 9px;
  background: var(--pill);
  box-shadow:
    0 1px 3px rgb(0 0 0 / 0.14),
    0 0 0 1px var(--line);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform var(--med) var(--ease);
}
.seg:has(> label:nth-child(2) > input:checked) {
  --i: 1;
}
.seg:has(> label:nth-child(3) > input:checked) {
  --i: 2;
}
.seg:has(> label:nth-child(4) > input:checked) {
  --i: 3;
}
.seg:has(> label:nth-child(5) > input:checked) {
  --i: 4;
}
.seg:has(> label:nth-child(6) > input:checked) {
  --i: 5;
}
.seg:has(> label:nth-child(7) > input:checked) {
  --i: 6;
}
.seg:has(> label:nth-child(8) > input:checked) {
  --i: 7;
}
.seg:has(> label:nth-child(9) > input:checked) {
  --i: 8;
}
.seg label {
  position: relative;
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--fast);
}
.seg label:hover {
  color: var(--fg);
}
.seg label:has(input:checked) {
  color: var(--fg);
}
.seg label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.seg label:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}
.seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

/* ---------------------------------------------------------------- chips and the scrubber */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font: 500 12px / 1.4 var(--mono);
  font-variant-numeric: tabular-nums;
}
.chip b {
  color: var(--fg);
  font-weight: 600;
}
.head-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.state[data-state="open"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.state[data-state="open"]::before {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.state[data-state="done"] {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip.bad {
  background: rgb(185 28 28 / 0.12);
  color: var(--bad);
}
.chip.bad b {
  color: var(--bad);
}
.chip.safe {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip.safe b {
  color: var(--ok);
}
.state[data-state="done"]::before {
  background: var(--ok);
}
@keyframes pulse {
  50% {
    transform: scale(0.55);
  }
}
input[type="range"] {
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}
#pos-out {
  min-width: 7ch;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.pane-head h2,
.panel-head h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-head h2 {
  font-size: 13px;
  color: var(--fg);
}
.hint {
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------- the two panes */
.raw,
.rendered {
  flex: 1;
  min-height: 0;
  margin: 0;
  overflow: auto;
  overflow-anchor: none;
}
.raw {
  padding: 14px 18px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.raw.edit {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  outline-offset: -2px;
  resize: none;
  white-space: pre-wrap;
  font-family: var(--mono);
}
.raw.edit[hidden] {
  display: none;
}
.pane-head .edit-hint {
  margin-left: auto;
}
.pane-head .tg {
  height: 26px;
  margin-left: auto;
  padding: 0 11px;
  font-size: 12px;
}
.tg[hidden] {
  display: none;
}
.chip[hidden] {
  display: none;
}
.raw span {
  transition: background-color var(--med) var(--ease);
}
.raw .c1 {
  background: color-mix(in srgb, var(--fg) 7%, transparent);
}
.raw .new {
  animation: tint 700ms ease-out;
}
.raw.plain .c1 {
  background: transparent;
}
.raw.plain .new {
  animation: none;
}
.raw::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes tint {
  from {
    background-color: color-mix(in srgb, var(--accent) 30%, transparent);
  }
}
.rendered {
  padding: 16px 22px;
  background: var(--surface);
}
.rendered > * {
  margin-top: 0;
}
.rendered .is-open {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}
/* Browsers indent a quote by 40px, so 13 nested quotes leave no width. Keep nesting visible but cheap. */
.rendered blockquote {
  margin: 0.25em 0 0.25em 0.25em;
  padding-left: 0.5em;
  border-left: 2px solid var(--line-strong);
}

@media (prefers-reduced-motion: reduce) {
  .raw::after,
  .raw .new,
  .state[data-state="open"]::before {
    animation: none;
  }
  .raw span,
  .seg::before,
  .btn,
  .icon-btn,
  .pill,
  .tab,
  .filters button {
    transition: none;
  }
}
@media (forced-colors: active) {
  .rendered .is-open {
    outline-color: Highlight;
  }
  .tab[aria-expanded="true"],
  .seg::before {
    outline: 2px solid Highlight;
  }
  .btn.primary {
    border-color: ButtonText;
  }
}
