@import url('/fonts/pretendard-dynamic-subset.css');

/* 5안 디자인. 포털 portal-v5.css 와 같은 값을 쓴다: 흰 바탕, 먹색 글자, 하늘색 강조, 모서리 4px, 1320px 폭. */
:root {
  /* 글자 크기 단계. 다섯 CSS(포털·웹툰·웹소설·영상·비주얼)가 같은 값을 쓴다. */
  --fs-micro: 11px;
  --fs-caption: 12px;
  --fs-small: 13px;
  --fs-body: 14px;
  --fs-lead: 15px;
  --fs-title-sm: 16px;
  --fs-title: 18px;
  --fs-logo: 21px;
  --fs-h3: 22px;
  --fs-h2: 26px;
  --fs-h1-sm: 34px;
  --fs-h1: 46px;
  /* 큰 제목 자간. 더 좁히면 글자가 겹친다. */
  --tracking-title: -0.02em;
  --paper: #fff;
  --sunken: #f2f6f8;
  --ink: #0b1215;
  --ink-2: #4b575e;
  --ink-3: #8a959b;
  --line: #e4eaed;
  --line-2: #c9d3d8;
  --accent: #16d0f0;
  --accent-d: #0084a8;
  --r: 4px;
  --wrap: 1400px; /* 위 메뉴·홈과 같은 너비 [599] */
  --gutter: max(24px, calc((100vw - var(--wrap)) / 2 + 24px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-y: scroll; overflow-x: clip; scrollbar-width: thin; scrollbar-color: var(--line-2) var(--paper); }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-lead);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
/* 일본어·중국어는 공백이 적어 keep-all 이면 줄이 바뀌지 않고 잘린다. */
html:lang(ja) :is(body),
html:lang(zh) :is(body) {
  word-break: normal;
}
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img, svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent-d); outline-offset: 2px; }

/* 포털 헤더와 같은 왼쪽 선에 맞춘다. 스크롤바 폭 때문에 가운데 정렬은 몇 px 어긋난다. */
.wrap {
  width: min(calc(var(--wrap) - 48px), calc(100vw - 2 * var(--gutter)));
  margin-left: var(--gutter);
}

/* 포털 밖 상단 메뉴 */
.header-gnb { height: 68px; border-bottom: 1px solid var(--line); }
.is-embedded .header-gnb { display: none; }
.gnb-inner { display: flex; align-items: center; gap: 44px; height: 100%; }
.brand-name { font-size: var(--fs-logo); font-weight: 800; letter-spacing: 0.04em; }
.gnb-nav { display: flex; gap: 30px; height: 100%; }
.gnb-tab-btn { position: relative; display: flex; align-items: center; font-weight: 600; color: var(--ink-2); }
.gnb-tab-btn.active { color: var(--ink); }
.gnb-tab-btn.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }
.gnb-right-group { display: flex; align-items: center; gap: 20px; margin-left: auto; font-size: var(--fs-body); font-weight: 600; }
.gnb-text-link { color: var(--ink-2); white-space: nowrap; }
.gnb-search-wrap { display: flex; align-items: center; gap: 8px; width: 220px; height: 38px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.search-input-field { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: var(--fs-body); font-weight: 400; }
.search-input-field::placeholder { color: var(--ink-3); }
.search-clear-btn { display: flex; color: var(--ink-3); }

/* 탭과 정렬 */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; min-width: 0; }
.tab { display: flex; flex: none; align-items: center; gap: 5px; height: 32px; font-size: var(--fs-body); font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.tab em { font-style: normal; font-size: var(--fs-caption); color: var(--ink-3); }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.sel { flex: none; }
.sel select {
  appearance: none;
  height: 32px;
  padding: 0 22px 0 4px;
  border: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234b575e' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right center;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  text-align: right;
}

/* 썸네일 위에는 나이 표시와 시간만 둔다 */
.age, .dur {
  position: absolute;
  display: flex;
  align-items: center;
  height: 19px;
  padding: 0 5px;
  border-radius: 2px;
  background: rgba(11, 18, 21, 0.78);
  color: #fff;
  font-size: var(--fs-micro);
  font-weight: 600;
}
.age { left: 6px; top: 6px; }
.dur { right: 6px; bottom: 6px; }

/* 카드: 상자 없이 그림과 글자만 */
.card-title-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 11px; }
.t {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-lead);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em; /* 제목 줄 수와 상관없이 메타 줄 높이를 맞춘다 */
}
.m { margin-top: 3px; display: flex; align-items: center; gap: 8px; font-size: var(--fs-small); color: var(--ink-3); }
.fav { flex: none; padding: 2px; color: var(--ink-3); opacity: 0; }
.fav:focus-visible, .fav.active { opacity: 1; }
.fav.active { color: var(--ink); }
.fav.active svg { fill: currentColor; }
@media (hover: hover) { :is(.video-card, .theme-card):hover .fav { opacity: 1; } .fav:hover { color: var(--ink); } }
@media (hover: none) { .fav { opacity: 1; } }
.price-edit { margin-left: auto; font-size: var(--fs-caption); font-weight: 600; color: var(--accent-d); }

/* 바닥글 */
.foot { margin-top: 56px; padding: 24px 0 28px; border-top: 1px solid var(--line); font-size: var(--fs-small); color: var(--ink-3); }
.foot-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.foot-logo { font-size: var(--fs-title-sm); font-weight: 800; letter-spacing: 0.04em; color: var(--ink); }
.footer-legal-links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-left: auto; color: var(--ink-2); }

/* 비주얼 무대: 흰 화면 위의 어두운 캔버스 */
.stage { position: relative; margin-top: 20px; height: 416px; border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.stage.has-theme { background: var(--ink); }
.is-embedded .stage { margin-top: 16px; }
.stage.dragover { box-shadow: 0 0 0 2px var(--accent); }
.player-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; opacity: 1; transition: opacity 0.22s ease; }
.player-frame.is-fading-out { opacity: 0; transition-duration: 0.15s; }
.stage:fullscreen { height: 100%; border-radius: 0; }
.stage-cap { position: absolute; left: 28px; top: 24px; color: #fff; pointer-events: none; text-shadow: 0 1px 2px rgba(11, 18, 21, 0.75), 0 0 16px rgba(11, 18, 21, 0.55); }
.stage:fullscreen .stage-cap { display: none; }
.eyebrow { font-size: var(--fs-small); font-weight: 700; }
.stage-cap h1 { margin-top: 2px; font-size: var(--fs-h1-sm); line-height: 1.2; font-weight: 700; letter-spacing: var(--tracking-title); }

/* 재생 막대 */
.player-control-bar { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.pb-play { flex: none; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: var(--r); background: var(--accent); color: var(--ink); }
.pb-play .icon-pause { display: none; }
.pb-play.is-playing .icon-pause { display: block; }
.pb-play.is-playing .icon-play { display: none; }
.pb-g { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 28px; white-space: nowrap; }
.pb-g[hidden] { display: none; }
button.pb-g:hover { color: var(--ink); }
a.pb-studio { padding: 0 10px; border-radius: var(--r); background: var(--accent); color: var(--ink); font-weight: 700; transition: background-color 0.15s ease, color 0.15s ease; }
a.pb-studio:hover { background: var(--accent-d); color: #fff; }
button.pb-auto { justify-content: center; width: 72px; height: 28px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--paper); color: var(--ink-2); font-weight: 700; transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
button.pb-auto:hover { border-color: var(--ink-2); color: var(--ink); }
button.pb-auto.is-active { border-color: var(--accent); background: var(--accent); color: var(--ink); box-shadow: 0 0 0 1px rgba(22, 208, 240, 0.28); }
button.pb-auto.is-active:hover { border-color: var(--accent-d); }
.pb-presets { display: flex; gap: 14px; min-width: 0; padding-right: 14px; overflow-x: auto; scrollbar-width: none; }
.pb-presets::-webkit-scrollbar { display: none; }
.pb-preset { flex: none; display: flex; align-items: center; height: 28px; padding: 0 2px; font-weight: 600; white-space: nowrap; }
.pb-preset:hover { color: var(--ink); }
.pb-preset.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.pb-track { flex: 1; min-width: 16px; }
.pb-select { flex: 0 1 190px; min-width: 110px; height: 28px; padding: 0 20px 0 0; border: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234b575e' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right center; appearance: none; font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); cursor: pointer; text-overflow: ellipsis; }
.pb-audio-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }

.viz-page-container > .bar { margin-top: 18px; }

/* 테마 목록: 세 칸 */
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 16px; margin-top: 24px; }
.theme-grid:empty { min-height: 95vh; }
@media (min-width: 701px) {
  html { overflow-y: scroll; scrollbar-gutter: stable both-edges; }
}
@media (min-width: 901px) {
  #themeGrid[data-cards-per-row] { grid-template-columns: repeat(var(--cards-per-row), minmax(0, 1fr)); }
}
.theme-card { display: block; min-width: 0; cursor: pointer; }
.theme-card-preview-wrap { position: relative; aspect-ratio: 16 / 10; border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.theme-card-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.theme-card.active-playing .t { color: var(--accent-d); }
.empty-state { grid-column: 1 / -1; padding: 64px 16px; text-align: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-body); }

@media (max-width: 960px) {
  .bar { gap: 8px; flex-wrap: nowrap; }
  .tabs {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 4px 10px;
    padding-right: 20px;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .sel { flex-shrink: 0; }
  .player-control-bar { flex-wrap: wrap; gap: 5px 12px; padding: 8px 0; }
  .pb-presets {
    order: 5;
    flex: 1 0 100%;
    min-height: 24px;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 22px;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
  }
  .pb-presets::-webkit-scrollbar { display: none; }
  .pb-select { order: 6; flex: 1 1 0; min-width: 120px; height: 28px; }
  a.pb-studio { order: 7; flex: none; height: 26px; font-size: var(--fs-caption); }
  #btnFullscreen { margin-left: auto; }
}

@media (max-width: 700px) {
  :root { --gutter: 16px; }
  .header-gnb { height: 56px; }
  .gnb-nav, .gnb-search-wrap { display: none; }
  .foot { margin-top: 40px; padding: 20px 0 calc(74px + env(safe-area-inset-bottom, 0px)); }
  .footer-legal-links { margin-left: 0; }
}

@media (max-width: 700px) {
  .stage, .is-embedded .stage { margin-top: 10px; height: auto; aspect-ratio: 16 / 9.2; }
  .stage:fullscreen { aspect-ratio: auto; }
  .stage-cap { left: 14px; top: 12px; right: 14px; }
  .eyebrow { font-size: var(--fs-caption); }
  .stage-cap h1 { font-size: var(--fs-h3); }
  .pb-play { width: 34px; height: 34px; }
  .pb-g:not(.pb-auto) { height: 24px; }
  .pb-preset { height: 24px; }
  .pb-track { display: none; }
  .pb-audio-name { max-width: 90px; }
  .viz-page-container > .bar { margin-top: 10px; }
  .tab, .sel select { height: 28px; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 10px; margin-top: 10px; }
  .card-title-row { margin-top: 7px; }
  .t { font-size: var(--fs-body); line-height: 1.3; min-height: 2.6em; }
  .m { margin-top: 2px; font-size: var(--fs-caption); line-height: 1.35; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .stage, .is-embedded .stage { margin-top: 8px; height: min(215px, calc(100dvh - 170px)); aspect-ratio: auto; }
  .stage:fullscreen { height: 100vh; }
  .foot { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}
