:root {
  color-scheme: light;
  --bg: #f7f8f6;
  --ink: #202426;
  --muted: #66706b;
  --line: #dfe4df;
  --panel: #ffffff;
  --panel-soft: #eef5f1;
  --accent: #087f6b;
  --accent-strong: #056553;
  --warm: #d86f20;
  --danger: #b64035;
  --shadow: 0 18px 50px rgba(20, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(238, 245, 241, 0.92), rgba(247, 248, 246, 0) 42%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 127, 107, 0.28);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  min-height: calc(100vh - 48px);
}

.control-panel {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 22px;
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: 2.15rem;
  line-height: 1;
  letter-spacing: 0;
}

.status-pill {
  width: fit-content;
  min-width: 98px;
  border: 1px solid rgba(8, 127, 107, 0.22);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 10px 14px;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.input-band {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.input-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 238px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 14px;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

textarea::placeholder {
  color: #98a39d;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.primary-btn,
.ghost-btn,
.layout-btn,
.icon-btn {
  min-height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.layout-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  grid-column: 1 / -1;
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn,
.layout-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.ghost-btn.danger {
  color: var(--danger);
}

.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.4;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--accent-strong);
}

.grid-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.layout-btn {
  min-width: 0;
  padding: 0 10px;
  color: var(--muted);
}

.layout-btn.active {
  border-color: rgba(8, 127, 107, 0.38);
  background: var(--panel-soft);
  color: var(--accent-strong);
}

.player-pane {
  min-width: 0;
  padding: 2px 0 18px;
}

.pane-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.pane-header h2 {
  font-size: 1.35rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: start;
}

.player-grid[data-size="large"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr));
}

.player-grid[data-size="compact"] {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.player-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.video-frame {
  aspect-ratio: var(--video-ratio, 16 / 9);
  background:
    linear-gradient(135deg, rgba(8, 127, 107, 0.12), rgba(216, 111, 32, 0.12)),
    #111816;
  transition: aspect-ratio 180ms ease;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  background: #111816;
  object-fit: contain;
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.video-meta {
  min-width: 0;
}

.video-meta h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.video-meta a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.video-meta a:hover {
  text-decoration: underline;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(182, 64, 53, 0.22);
  background: #fff8f7;
  color: var(--danger);
  font-size: 1.4rem;
  line-height: 1;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 420px;
  border: 1px dashed #b8c4bd;
  border-radius: 8px;
  display: grid;
  place-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  padding: 36px 20px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state h2 {
  color: var(--ink);
  font-size: 1.35rem;
  letter-spacing: 0;
}

.empty-state p {
  line-height: 1.5;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .control-panel {
    position: static;
    height: auto;
  }

  .grid-tools {
    margin-top: 0;
  }

  .pane-header {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1440px);
    padding: 14px 0 24px;
  }

  .control-panel {
    padding: 18px;
  }

  h1 {
    font-size: 1.72rem;
  }

  textarea {
    min-height: 180px;
  }

  .toolbar,
  .grid-tools {
    grid-template-columns: 1fr;
  }

  .player-grid,
  .player-grid[data-size="large"],
  .player-grid[data-size="compact"] {
    grid-template-columns: 1fr;
  }

  .empty-state {
    min-height: 260px;
  }
}
