:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #151515;
  --muted: #5c6370;
  --line: #d2d5da;
  --accent: #ee0000;
  --ok-bg: #e6f4ea;
  --ok-fg: #14532d;
  --block-bg: #fde8e8;
  --block-fg: #8a1111;
  --err-bg: #eceef1;
  --err-fg: #3b4250;
  font-family: "Red Hat Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --panel: #1f2329;
    --text: #f0f1f3;
    --muted: #a3a9b3;
    --line: #363c46;
    --ok-bg: #12301e;
    --ok-fg: #9be3b3;
    --block-bg: #3a1616;
    --block-fg: #ffb3b3;
    --err-bg: #2a2f38;
    --err-fg: #c9ced6;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.top {
  padding: 20px 16px 12px;
  border-bottom: 4px solid var(--accent);
  background: var(--panel);
}

h1 {
  margin: 0;
  font-size: 1.5rem;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.sub,
.muted,
.hint,
footer {
  color: var(--muted);
}

.sub {
  margin: 4px 0 0;
}

main {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.side {
  display: grid;
  gap: 16px;
  align-content: start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.step {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  text-align: center;
  line-height: 1.6em;
  font-size: 0.85rem;
}

.group-title {
  margin: 14px 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.group-title:first-child {
  margin-top: 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.tile img {
  width: 100%;
  height: 78px;
  object-fit: cover;
  object-position: top;
  border-radius: 3px;
  background: #fff;
}

.tile strong {
  font-size: 0.85rem;
}

.tile.audio {
  padding: 8px;
}

.tile span {
  font-size: 0.75rem;
  color: var(--muted);
}

.tile[aria-pressed="true"] {
  border-color: var(--accent);
}

.tile:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.modes {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.modes label {
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  font-size: 0.9rem;
}

select,
textarea {
  display: block;
  width: 100%;
  margin: 4px 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button#send {
  padding: 10px 22px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button#send:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
}

.compare {
  display: grid;
  gap: 12px;
}

.preview {
  margin: 0;
}

.preview audio {
  display: block;
  width: 100%;
}

.preview audio[hidden] {
  display: none;
}

.tabs {
  display: inline-flex;
  gap: 0;
  margin-top: 10px;
}

.tabs[hidden] {
  display: none;
}

.tab {
  padding: 6px 18px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tab:first-child {
  border-radius: 6px 0 0 6px;
}

.tab:last-child {
  border-radius: 0 6px 6px 0;
  border-left: 0;
}

.tab[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.tab[aria-pressed="true"]:last-child {
  border-left: 2px solid var(--accent);
}

.zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.zoom[hidden] {
  display: none;
}

.preview img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.zoom:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#lightbox {
  max-width: 96vw;
  max-height: 96vh;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

#lightbox::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

#lightbox img {
  display: block;
  max-width: calc(96vw - 32px);
  max-height: calc(96vh - 72px);
  background: #fff;
  cursor: zoom-out;
}

#lightbox .close {
  margin: 0 0 8px auto;
  display: block;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.preview figcaption {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 140px;
}

.card.empty {
  border-style: dashed;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.allowed {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.badge.blocked {
  background: var(--block-bg);
  color: var(--block-fg);
}

.badge.error {
  background: var(--err-bg);
  color: var(--err-fg);
}

.meta {
  margin-left: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.answer {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow: auto;
}

details {
  margin-top: 10px;
  font-size: 0.85rem;
}

details ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.error {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--block-bg);
  color: var(--block-fg);
}

footer {
  padding: 8px 16px 24px;
  text-align: center;
  font-size: 0.8rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    max-height: none;
  }
}
