/* Design refinement guided by unslop by Damir Sokolovsky (@heydamir).
   https://heydamir.design/unslop · CC BY 4.0 */
:root {
  color-scheme: dark;
  --bg: #141415;
  --sidebar: #111112;
  --surface: #19191b;
  --raised: #232325;
  --line: rgb(237 237 237 / 8%);
  --line-strong: rgb(237 237 237 / 16%);
  --text: #ededed;
  --secondary: #a1a1a6;
  --muted: #898990;
  --accent: #99f7bc;
  --danger: #e9a9a2;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Pretendard", "Noto Sans KR", "Noto Sans CJK KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-family: var(--font);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { display: flex; flex-direction: column; min-height: 100svh; margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
input { min-width: 0; }
input::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"] { flex-shrink: 0; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.icon { display: block; flex-shrink: 0; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; z-index: 5; top: 8px; left: 24px; padding: 12px 16px; border-radius: 8px; background: var(--text); color: var(--bg); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.topbar { flex-shrink: 0; height: 64px; padding-inline: max(32px, calc((100vw - 1472px) / 2)); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 600; }
.brand-mark { position: relative; width: 20px; height: 20px; border: 1.5px solid currentColor; border-radius: 50%; }
.brand-mark::after { content: ""; position: absolute; width: 8px; height: 8px; inset: 0; margin: auto; background: currentColor; border-radius: 50%; }
.text-link { display: inline-flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 12px; min-height: 32px; }
main { display: flex; flex: 1; flex-direction: column; width: 100%; max-width: 1536px; margin-inline: auto; padding-inline: 32px; }
.intro { padding-block: 32px; }
.eyebrow { margin-bottom: 8px; color: var(--secondary); font-size: 12px; }
.intro h1 { font-size: 32px; line-height: 1.25; font-weight: 500; }
.intro-description { margin-top: 8px; color: var(--secondary); font-size: 14px; line-height: 1.5; }

.workspace { display: grid; flex: 1; grid-template-columns: 264px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-height: 560px; }
.sidebar { padding: 24px 16px; border-right: 1px solid var(--line); background: var(--sidebar); }
.section-heading { display: flex; align-items: baseline; gap: 8px; padding-inline: 8px; }
.section-heading h2 { font-size: 16px; font-weight: 500; }
.count { font: 12px/1.5 var(--mono); font-variant-numeric: tabular-nums; color: var(--secondary); }
.section-description { margin: 8px 8px 20px; color: var(--secondary); font-size: 12px; }
.search-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); }
.search-box:focus-within { border-color: var(--secondary); }
.search-box input { width: 100%; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 13px; outline-offset: 4px; }
.selection-actions { display: flex; align-items: center; gap: 16px; padding-inline: 8px; margin-block: 12px 8px; }
.selection-actions button { min-height: 28px; padding: 0; border: 0; background: transparent; color: var(--secondary); font-size: 12px; }
.selection-actions button:hover { color: var(--text); }
.channel-list { display: grid; gap: 4px; max-height: 384px; overflow-y: auto; scrollbar-width: thin; }
.channel-list > .section-description { margin-block: 12px; }
.channel-row { display: flex; align-items: center; gap: 4px; min-width: 0; min-height: 44px; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px; }
.channel-row.selected { background: var(--raised); border-color: var(--line); }
.channel-row:hover { background: var(--raised); }
.channel-row label { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.avatar { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--raised); color: var(--secondary); font-size: 14px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.channel-row .avatar { width: 28px; height: 28px; font-size: 12px; }
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.remove-channel { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.remove-channel:hover { background: rgb(237 237 237 / 5%); color: var(--text); }
.add-form { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.add-form > label { display: block; padding-inline: 8px; font-weight: 500; font-size: 13px; }
.add-form > p { margin: 8px 8px 12px; color: var(--secondary); font-size: 12px; }
.add-row { display: flex; gap: 8px; }
.add-row input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: transparent; color: var(--text); font-size: 12px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--raised); color: var(--text); }
.icon-button:hover { background: #2c2c2f; }
.add-form .form-feedback { margin-top: 8px; margin-bottom: 0; color: var(--secondary); }
.form-feedback:empty { display: none; }
.form-feedback.is-error { color: var(--danger); }
.storage-note { margin: 24px 8px 0; font-size: 12px; line-height: 1.75; color: var(--muted); }

.dashboard { padding: 24px 28px; min-width: 0; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dashboard-header h2 { font-size: 20px; font-weight: 500; }
.refresh-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; background: var(--text); color: var(--bg); font-weight: 500; font-size: 13px; }
.refresh-button:hover { background: #d9d9dc; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-block: 24px; padding-block: 20px; border-block: 1px solid var(--line); }
.summary-item { padding-inline: 24px; }
.summary-item:first-child { padding-left: 0; }
.summary-item + .summary-item { border-left: 1px solid var(--line); }
.summary-item > span { display: block; font-size: 12px; color: var(--secondary); }
.summary-item strong { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font: 500 32px/1 var(--mono); font-variant-numeric: tabular-nums; }
.summary-item strong span { font: 400 12px/1.5 var(--font); color: var(--secondary); }
.summary-item.has-live strong { color: var(--accent); }
.board-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.filter-tabs { display: flex; align-items: center; gap: 24px; }
.filter-tabs button { position: relative; min-height: 36px; padding: 0 0 12px; border: 0; background: transparent; color: var(--secondary); font-size: 13px; }
.filter-tabs button.active { color: var(--text); }
.filter-tabs button.active::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--text); }
.auto-refresh { display: flex; align-items: center; gap: 8px; min-height: 36px; padding-bottom: 12px; color: var(--secondary); font-size: 12px; white-space: nowrap; cursor: pointer; }
.auto-refresh input { accent-color: #dedee0; }
.notice { margin-bottom: 16px; color: var(--secondary); font-size: 13px; }
.notice:empty { display: none; }
.notice.error { color: var(--danger); }
.stream-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 16px; }
.stream-card { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stream-card.is-live { border-color: var(--line-strong); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-identity .avatar { width: 40px; height: 40px; font-size: 16px; }
.card-identity h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; color: var(--secondary); font-size: 12px; white-space: nowrap; }
.status-badge::before { content: ""; width: 8px; height: 8px; border: 1px solid var(--muted); border-radius: 50%; }
.is-live .status-badge { color: var(--accent); }
.is-live .status-badge::before { border-color: var(--accent); background: var(--accent); }
.is-error .status-badge { color: var(--danger); }
.is-error .status-badge::before { border-color: var(--danger); }
.live-title { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 18px; line-height: 1.5; font-weight: 400; }
.offline-title { color: var(--secondary); font-size: 14px; line-height: 1.5; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--secondary); font-size: 12px; }
.card-meta:empty { display: none; }
.category { color: var(--secondary); }
.card-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.stream-date { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.stream-date time { font: 12px/1.5 var(--mono); font-variant-numeric: tabular-nums; }
.watch-link { display: inline-flex; align-items: center; gap: 8px; min-height: 24px; color: var(--secondary); font-size: 12px; white-space: nowrap; }
.watch-link:hover { color: var(--text); }
.empty-state { grid-column: 1 / -1; padding: 48px 24px; border: 1px solid var(--line); border-radius: 12px; color: var(--secondary); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 16px; font-weight: 500; }
.empty-state p { font-size: 13px; }
.board-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.board-footer span:first-child { font-variant-numeric: tabular-nums; }
.page-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding-block: 20px; color: var(--muted); font-size: 12px; }
.noscript { padding: 24px; text-align: center; }

@media (min-width: 1360px) {
  .stream-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-top { align-items: flex-start; flex-direction: column; }
  .status-badge { margin-left: 52px; }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 248px minmax(0, 1fr); }
  .dashboard { padding: 24px; }
  .card-top { align-items: flex-start; flex-direction: column; }
  .status-badge { margin-left: 52px; }
}
@media (max-width: 800px) {
  .topbar { padding-inline: 24px; }
  main { padding-inline: 24px; }
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .stream-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-item { padding-inline: 12px; }
  .summary-item strong { font-size: 28px; }
  .board-toolbar { flex-wrap: wrap; gap: 8px; }
  .auto-refresh { min-height: 32px; }
}
@media (max-width: 640px) {
  .topbar { height: 56px; padding-inline: 20px; }
  .brand { font-size: 18px; }
  main { padding-inline: 16px; }
  .intro { padding-block: 24px; }
  .intro h1 { font-size: 28px; }
  .intro-description { max-width: 30ch; font-size: 13px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 20px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .channel-list { max-height: 264px; }
  .channel-row { min-height: 44px; }
  .channel-name { font-size: 14px; }
  .remove-channel { width: 36px; height: 36px; }
  .selection-actions button { min-height: 36px; }
  .add-form { margin-top: 20px; padding-top: 20px; }
  .add-row input, .icon-button { height: 44px; }
  .icon-button { width: 44px; }
  .storage-note { margin-top: 16px; }
  .storage-note br { display: none; }
  .dashboard { padding: 24px 16px; }
  .refresh-button { min-height: 40px; }
  .summary { margin-block: 20px; }
  .summary-item { padding-inline: 16px; }
  .board-toolbar { flex-wrap: nowrap; gap: 12px; }
  .filter-tabs { gap: 24px; }
  .auto-refresh { min-height: 36px; }
  .stream-card { padding: 20px; }
  .card-top { flex-direction: row; align-items: center; }
  .status-badge { margin-left: 0; }
  .board-footer span:last-child { display: none; }
  .page-footer { padding-block: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, a, .channel-row { transition: color 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease); }
}
