:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #6b6258;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e3d9cc;
  --sidebar: #1c1915;
  --sidebar-text: #f6f1e8;
  --sidebar-muted: #b7aa9b;
  --accent: #c2410c;
  --accent-ink: #fff7ed;
  --new: #9a3412;
  --new-bg: #ffedd5;
  --ok: #3f6212;
  --ok-bg: #ecfccb;
  --shadow: 0 16px 40px rgba(28, 25, 21, 0.08);
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button, input, select { font: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}

.mark {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
}

.sidebar h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 650;
}

.sidebar h2 {
  margin: 18px 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

#search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#search-form label {
  font-size: 0.85rem;
  color: var(--sidebar-muted);
}

#channel {
  border: 0;
  border-radius: 10px;
  padding: 12px 12px;
  background: #2a2622;
  color: var(--sidebar-text);
}

.mode {
  display: flex;
  gap: 6px;
}

.mode button, #open-settings, #settings-close, .play-hit, .inline-close,
#search-button, #download, .filters button, #modal-close, .library button {
  border: 0;
  cursor: pointer;
}

.mode button {
  background: #2a2622;
  color: var(--sidebar-muted);
  border-radius: 999px;
  padding: 7px 10px;
}

.mode button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.mode-light button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.mode-light button.is-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

#open-settings, .ghost {
  align-self: flex-start;
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid #3a342e;
  border-radius: 10px;
  padding: 8px 12px;
}

.play-hit {
  position: relative;
  padding: 0;
  background: none;
  border-radius: 12px;
}

.play-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.6rem;
  background: rgba(28, 25, 21, 0.28);
  border-radius: 12px;
}

.card.is-playing {
  grid-template-columns: auto minmax(200px, 280px) 1fr;
  align-items: start;
}

.inline-player,
#modal-player {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 70vh;
  border: 0;
  border-radius: 12px;
  background: #111;
  object-fit: contain;
}

.inline-close {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  margin-right: 8px;
}

.settings-card {
  width: min(440px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.settings-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-card h2 {
  margin: 8px 0 0;
  font-size: 1rem;
}

.settings-card input, .settings-card select, .settings-card textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font: inherit;
}

.switch {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  color: var(--ink) !important;
  font-weight: 650;
}

.hint { margin: 0; color: var(--muted); font-size: 0.85rem; }

#save-proxy {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 650;
  cursor: pointer;
}

#search-button, #download {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 650;
  cursor: pointer;
}

#analyze, #save-analysis {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 650;
  cursor: pointer;
}

#search-button:disabled, #download:disabled, #analyze:disabled {
  opacity: 0.45;
  cursor: default;
}

.status-line {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.library {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.library button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 10px;
  padding: 10px 10px;
}

.library button:hover, .library button.is-on {
  background: #2a2622;
}

.library small {
  display: block;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.stage-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 32px 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.stage-head h2 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 650;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filters button {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
}

.filters button.is-on {
  background: var(--ink);
  color: var(--paper);
}

.notice, .progress {
  margin: 0 32px;
  color: var(--muted);
}

.feed {
  flex: 1;
  padding: 12px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 860px;
}

.card {
  display: grid;
  grid-template-columns: auto 112px 1fr;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.card input {
  width: 18px;
  height: 18px;
  margin-left: 6px;
}

.thumb {
  width: 112px;
  height: 148px;
  border-radius: 12px;
  object-fit: cover;
  background: linear-gradient(160deg, #2a2622, #c2410c);
}

.thumb.placeholder {
  display: block;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 650;
}

.badge.new { background: var(--new-bg); color: var(--new); }
.badge.have { background: var(--ok-bg); color: var(--ok); }

.watch {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  padding: 24px 0;
}

.bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 32px;
  background: rgba(243, 239, 230, 0.94);
  border-top: 1px solid var(--line);
}

.bar label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.bar select {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 10px;
}

#selected-count { margin: 0; color: var(--muted); }

.progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, 0.62);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-top h3 { margin: 0; }

#modal-close {
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
}

#modal-player {
  width: min(100%, 420px);
  margin-inline: auto;
}

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .stage-head, .bar { padding-left: 16px; padding-right: 16px; }
  .feed, .notice, .progress { margin-left: 16px; margin-right: 16px; padding-left: 0; padding-right: 0; }
  .card { grid-template-columns: auto 88px 1fr; }
  .card.is-playing { grid-template-columns: auto 1fr; }
  .card.is-playing .inline-player { grid-column: 1 / -1; max-width: 280px; }
  .thumb { width: 88px; height: 116px; }
  .bar { flex-wrap: wrap; }
}
