:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2228;
  --muted: #65717f;
  --line: #dce1e7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(34, 44, 56, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

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

h2 {
  font-size: 18px;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.ghost-link {
  color: var(--accent-dark);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--panel);
}

.import-panel,
.library,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.import-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.import-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 11px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #edf5f4;
  color: var(--accent-dark);
  border: 1px solid #b7d8d4;
}

button.secondary:hover {
  background: #dff0ee;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.status {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
}

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

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.library {
  min-height: 620px;
  overflow: hidden;
}

.library-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.library-head h2 {
  margin-bottom: 10px;
}

.video-list {
  display: grid;
  gap: 0;
  max-height: 72vh;
  overflow: auto;
}

.video-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: white;
}

.video-card:hover,
.video-card.active {
  background: #f1f8f7;
}

.video-card img {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #d9dee5;
}

.video-title {
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
}

.video-meta {
  color: var(--muted);
  font-size: 13px;
}

.detail {
  min-height: 620px;
  overflow: hidden;
}

.detail.empty {
  display: grid;
  place-items: center;
}

.empty-state {
  color: var(--muted);
}

.detail-hero {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #d9dee5;
}

.detail-title {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.tab.active {
  background: #edf5f4;
  color: var(--accent-dark);
}

.content {
  padding: 22px;
  max-height: 68vh;
  overflow: auto;
}

.markdown {
  line-height: 1.68;
  white-space: pre-wrap;
}

.markdown h2,
.markdown h3 {
  margin-top: 22px;
}

.muted {
  color: var(--muted);
}

@media (max-width: 920px) {
  .shell {
    width: min(100% - 24px, 760px);
    padding-top: 18px;
  }

  .layout,
  .detail-hero,
  .import-form {
    grid-template-columns: 1fr;
  }

  .library,
  .detail {
    min-height: auto;
  }

  .topbar {
    display: block;
  }

  .ghost-link {
    display: inline-block;
    margin-top: 14px;
  }
}
