:root {
  --bg: #090b0f;
  --bg-2: #10141b;
  --surface: #151a22;
  --surface-2: #1b222d;
  --border: #2a3341;
  --text: #f4f7fb;
  --muted: #9aa7b6;
  --soft: #d6dce5;
  --accent: #ff3153;
  --accent-2: #27d6b3;
  --warning: #ffcc66;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(39, 214, 179, 0.12), transparent 30rem),
    linear-gradient(135deg, #090b0f 0%, #111821 52%, #0a0d12 100%);
  color: var(--text);
  font-family:
    Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.top-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(340px, 0.72fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  position: relative;
  width: 48px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff3153, #d80032);
  box-shadow: 0 18px 34px rgba(255, 49, 83, 0.2);
}

.brand-mark::after {
  position: absolute;
  top: 50%;
  left: 52%;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid #fff;
  content: "";
  transform: translate(-50%, -50%);
}

.brand h1,
.brand p,
.section-title-row h2,
.section-title-row p,
.now-playing h3,
.now-playing p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.98rem;
}

.quota-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.88);
  box-shadow: var(--shadow);
}

.quota-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.quota-head h2,
.quota-head p,
.quota-message {
  margin: 0;
}

.quota-head h2 {
  font-size: 1rem;
}

.quota-head p,
.quota-message {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

.quota-head strong {
  color: var(--accent-2);
  font-size: 1.12rem;
}

.quota-meter {
  overflow: hidden;
  height: 10px;
  margin: 12px 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.quota-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 220ms ease, background 160ms ease;
}

.quota-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.quota-grid strong {
  color: var(--soft);
}

.quota-message {
  margin-top: 10px;
}

.quota-reset-button {
  min-height: 34px;
  margin-top: 12px;
  padding: 0 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.quota-reset-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.quota-card.is-warning .quota-meter span,
.quota-card.is-warning .quota-head strong {
  background: var(--warning);
  color: var(--warning);
}

.quota-card.is-danger {
  border-color: rgba(255, 107, 107, 0.4);
}

.quota-card.is-danger .quota-meter span,
.quota-card.is-danger .quota-head strong {
  background: var(--danger);
  color: var(--danger);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.88);
  box-shadow: var(--shadow);
}

.search-form:focus-within {
  border-color: rgba(39, 214, 179, 0.7);
  box-shadow: 0 0 0 4px rgba(39, 214, 179, 0.1), var(--shadow);
}

.search-form input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.18rem;
  padding: 16px 18px;
}

.search-form input::placeholder {
  color: #728092;
}

.search-form button {
  min-width: 112px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.search-form button:hover {
  background: #ff4d69;
  transform: translateY(-1px);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.65fr);
  grid-template-areas:
    "player library"
    "results results";
  gap: 24px;
}

.player-section,
.library-panel,
.discovery-section,
.list-section {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(16, 20, 27, 0.84);
  box-shadow: var(--shadow);
}

.player-section {
  grid-area: player;
  padding: 18px;
}

.library-panel {
  grid-area: library;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.list-section {
  min-height: 260px;
  padding: 16px;
  background: rgba(21, 26, 34, 0.78);
}

.discovery-section {
  grid-area: results;
  padding: 18px;
}

.tab-bar {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.tab-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.is-active {
  background: var(--accent);
  color: #fff;
}

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

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-size: 1.05rem;
}

.panel-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.section-title-row h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

.section-title-row p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.section-title-row span {
  min-width: 34px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(39, 214, 179, 0.12);
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.player-frame-wrap,
.player-wrapper {
  position: relative;
}

.player-frame-wrap {
  overflow: visible;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 49, 83, 0.13), transparent 40%),
    #05070a;
}

.player-host {
  width: 100%;
  height: 100%;
}

.player-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-placeholder {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 92px;
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-align: center;
}

.player-placeholder strong {
  color: var(--text);
  font-size: clamp(1.5rem, 4vw, 3rem);
  line-height: 1.05;
}

.player-placeholder.is-hidden {
  display: none;
}

.player-frame-wrap:fullscreen {
  overflow: visible;
  border: 0;
  border-radius: 0;
}

.now-playing {
  padding-top: 16px;
}

.now-playing h3 {
  color: var(--soft);
  font-size: 1.16rem;
  line-height: 1.4;
}

.now-playing p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.channel-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.channel-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.channel-card:hover,
.channel-card:focus-visible {
  border-color: rgba(39, 214, 179, 0.58);
  background: var(--surface-2);
  transform: translateY(-2px);
  outline: 0;
}

.channel-card img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: #05070a;
}

.channel-card-title,
.channel-card-description {
  margin: 0;
}

.channel-card-title {
  font-size: 1rem;
  line-height: 1.35;
}

.channel-card-description {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.channel-card-favorite {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(5, 7, 10, 0.78);
  color: var(--text);
  font-size: 1.02rem;
}

.channel-card-favorite:hover,
.channel-card-favorite.is-active {
  border-color: rgba(255, 204, 102, 0.76);
  color: var(--warning);
}

.channel-detail {
  margin-top: 18px;
}

.channel-detail[hidden] {
  display: none;
}

.channel-profile {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.78);
}

.channel-profile img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  background: #05070a;
}

.channel-profile h3,
.channel-profile p {
  margin: 0;
}

.channel-profile h3 {
  font-size: 1.45rem;
  line-height: 1.25;
}

.channel-profile p {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.channel-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.channel-stats span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(39, 214, 179, 0.12);
  color: var(--accent-2);
  font-size: 0.83rem;
  font-weight: 800;
}

.channel-favorite-button {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 6px;
  background: rgba(255, 204, 102, 0.12);
  color: var(--warning);
  font-weight: 900;
}

.channel-favorite-button.is-active {
  background: var(--warning);
  color: #17130a;
}

.channel-upload-title {
  margin-top: 20px;
}

.load-more-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid rgba(255, 204, 102, 0.24);
  border-radius: 8px;
  background: rgba(255, 204, 102, 0.07);
}

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

.load-more-panel p {
  margin: 0;
  color: #ffd992;
  font-size: 0.92rem;
  line-height: 1.5;
}

.load-more-panel button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.load-more-panel button:hover:not(:disabled) {
  background: #ff4d69;
  transform: translateY(-1px);
}

.load-more-panel button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.video-card,
.compact-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.video-card {
  overflow: hidden;
  min-width: 0;
}

.video-card:hover,
.video-card:focus-visible,
.compact-card:hover,
.compact-card:focus-visible {
  border-color: rgba(39, 214, 179, 0.58);
  background: var(--surface-2);
  transform: translateY(-3px);
  outline: 0;
}

.thumb-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #05070a;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.favorite-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(5, 7, 10, 0.78);
  color: var(--text);
  font-size: 1.08rem;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.favorite-button:hover,
.favorite-button.is-active {
  border-color: rgba(255, 204, 102, 0.76);
  color: var(--warning);
  transform: scale(1.05);
}

.card-body {
  padding: 13px;
}

.video-title,
.compact-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  -webkit-box-orient: vertical;
}

.video-title {
  min-height: 2.7em;
  -webkit-line-clamp: 2;
}

.meta-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.description {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 10px;
  color: #b7c0cc;
  font-size: 0.88rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  cursor: pointer;
  text-align: left;
}

.compact-card img {
  width: 88px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  background: #05070a;
}

.compact-channel-card img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.compact-title {
  -webkit-line-clamp: 2;
  font-size: 0.92rem;
}

.compact-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.remove-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  font-size: 1rem;
  font-weight: 900;
  transition: background 160ms ease, transform 160ms ease;
}

.remove-button:hover {
  background: rgba(255, 107, 107, 0.2);
  transform: scale(1.05);
}

.empty-state,
.error-state,
.loading-state {
  min-height: 108px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
  padding: 20px;
}

.error-state {
  border-color: rgba(255, 107, 107, 0.36);
  color: #ffb2b2;
}

.loading-state {
  border-color: rgba(39, 214, 179, 0.36);
  color: var(--accent-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1180px) {
  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .channel-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 18px;
  }

  .top-bar,
  .main-layout {
    grid-template-columns: 1fr;
  }

  .main-layout {
    grid-template-areas:
      "player"
      "library"
      "results";
  }

  .library-panel {
    grid-template-columns: 1fr 1fr;
  }

  .channel-profile {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .channel-profile img {
    width: 86px;
    height: 86px;
  }

  .channel-favorite-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand p {
    font-size: 0.9rem;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-form button {
    min-height: 48px;
  }

  .library-panel {
    grid-template-columns: 1fr;
  }

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

  .channel-results {
    grid-template-columns: 1fr;
  }

  .channel-card {
    grid-template-columns: 58px minmax(0, 1fr) auto;
  }

  .channel-card img {
    width: 58px;
    height: 58px;
  }

  .compact-card {
    grid-template-columns: 96px minmax(0, 1fr) auto;
  }

  .compact-channel-card {
    grid-template-columns: 58px minmax(0, 1fr) auto;
  }

  .channel-profile {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .channel-profile img {
    margin: 0 auto;
  }

  .channel-stats {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
