:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #64748b;
  --line: #d7dde7;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --warn: #9a3412;
  --shadow: 0 14px 34px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
}

button,
textarea,
input {
  font: inherit;
}

.topbar {
  align-items: center;
  background: #111827;
  color: #f8fafc;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 84px;
  padding: 18px clamp(16px, 4vw, 42px);
}

.eyebrow {
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

h3 {
  font-size: 13px;
  line-height: 1.2;
}

p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin-top: 4px;
}

.status {
  border: 1px solid rgba(248, 250, 252, 0.24);
  border-radius: 999px;
  color: #dbeafe;
  font-size: 13px;
  padding: 7px 10px;
  white-space: nowrap;
}

.status.ready {
  background: #064e3b;
  border-color: #10b981;
  color: #d1fae5;
}

.status.warn {
  background: #7c2d12;
  border-color: #fb923c;
  color: #ffedd5;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 360px) minmax(260px, 360px) minmax(
      420px,
      1fr
    );
  padding: 18px clamp(12px, 3vw, 32px) 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

textarea {
  background: #fbfdff;
  border: 0;
  color: var(--ink);
  display: block;
  height: 260px;
  line-height: 1.45;
  min-width: 0;
  outline: 0;
  padding: 14px;
  resize: vertical;
  width: 100%;
}

textarea:focus {
  box-shadow: inset 0 0 0 2px #38bdf8;
}

.actions {
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
}

.actions.compact {
  border: 0;
  padding: 0;
}

.panel-head .actions.compact {
  flex: 0 0 auto;
}

button,
.file-action {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover,
.file-action:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button.secondary,
.file-action {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

button.secondary:hover,
.file-action:hover {
  background: #eef6f5;
  border-color: #94a3b8;
  color: var(--ink);
}

.file-action input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.scanner-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
}

.scanner-panel[hidden] {
  display: none;
}

.scanner-panel video {
  aspect-ratio: 4 / 3;
  background: #111827;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.scanner-footer {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.scanner-footer p {
  margin: 0;
}

.examples-block {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
}

.examples-list {
  display: grid;
  gap: 8px;
}

.example-button {
  align-items: flex-start;
  background: #f8fafc;
  border-color: var(--line);
  color: var(--ink);
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 0;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.example-button:hover {
  background: #eef6f5;
  border-color: #94a3b8;
  color: var(--ink);
}

.example-button span {
  font-size: 14px;
}

.example-button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
}

.shelf-list {
  display: grid;
  gap: 8px;
  max-height: 336px;
  min-height: 336px;
  overflow: auto;
  padding: 12px;
}

.shelf-empty {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  justify-content: center;
  min-height: 120px;
  padding: 18px;
  text-align: center;
}

.shelf-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr auto;
  padding: 10px;
}

.shelf-name {
  font-size: 14px;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-meta {
  color: var(--muted);
  font-size: 12px;
}

.player-panel {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

iframe {
  background: #ffffff;
  border: 0;
  flex: 1;
  min-height: 440px;
  width: 100%;
}

.toast {
  background: #111827;
  border-radius: 8px;
  bottom: 16px;
  color: #ffffff;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 10px 12px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 10;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .player-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .actions {
    flex-wrap: wrap;
  }

  .actions button,
  .file-action {
    flex: 1 1 110px;
  }
}
