/* 나중에 볼 영상 — 유튜브 느낌의 다크 테마 (Figma 시안 "나중에 볼 영상 — 유튜브 스타일 시안") */
:root {
  --bg: #0f0f0f;
  --raised: #181818;
  --surface: #212121;
  --chip: #272727;
  --chip-hover: #3f3f3f;
  --text: #f1f1f1;
  --muted: #aaaaaa;
  --inverse: #0f0f0f;
  --line: #3f3f3f;
  --red: #ff3d3d;
  --red-soft: rgba(255, 61, 61, 0.18);
  --radius: 12px;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.warn { color: #ff6b6b; }

/* ── 위쪽 바 ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
}
.topbar .logo { border-radius: 7px; flex-shrink: 0; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .link { color: var(--muted); text-decoration: none; padding: 8px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
}
.icon-btn:hover { background: var(--chip); }
.icon-btn svg { width: 24px; height: 24px; }

.avatar-btn, .ch-avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  border: 0;
}
.avatar-btn { width: 32px; height: 32px; margin-left: 4px; background: #5c6bc0; font-size: 14px; overflow: hidden; padding: 0; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.ch-avatar { width: 36px; height: 36px; font-size: 15px; }

main {
  max-width: 1280px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}

/* ── 공통 버튼 / 칩 ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.chip:hover { background: var(--chip-hover); }
.chip[aria-pressed='true'], .chip.white { background: var(--text); color: var(--inverse); }
.chip.red[aria-pressed='true'] { background: var(--red-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--red); }
.chip.ghost { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.chip.ghost[aria-pressed='true'] { background: var(--chip); color: var(--text); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  background: var(--chip);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.pill:hover { background: var(--chip-hover); }
.pill.white { background: var(--text); color: var(--inverse); }
.pill.white:hover { background: #d9d9d9; }
.pill svg { width: 18px; height: 18px; }

.btn-red {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 26px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.btn-red:disabled { opacity: 0.6; }

.text-btn { border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 500; padding: 6px 0; }

/* 개인정보처리방침 등 보조 페이지용 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 20px;
  background: var(--chip); color: var(--text); text-decoration: none; font-weight: 500;
}
.link { background: none; border: 0; color: var(--muted); padding: 4px; }

.chip-row {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .label { align-self: center; flex-shrink: 0; color: var(--muted); font-size: 13px; font-weight: 500; margin-right: 2px; }

/* ── 알림/안내 띠 ── */
.notice {
  margin: 12px 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.notice p { margin: 0 0 10px; }
.notice p:last-child { margin-bottom: 0; }
.notice ol { margin: 6px 0 0; padding-left: 20px; }
.notice.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.notice.row p, .notice.row span { margin: 0; }

/* ── 영상 추가 ── */
.add-hero { display: grid; gap: 12px; padding: 24px 16px 8px; max-width: 640px; }
.add-hero h2 { margin: 0 0 4px; font-size: 26px; line-height: 1.3; letter-spacing: -0.5px; }
.link-input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 8px 0 18px;
  border-radius: 26px;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
}
.link-input:focus-within { box-shadow: inset 0 0 0 1px #3ea6ff; }
.link-input svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted); }
.link-input input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 16px; }
.link-input input::placeholder { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

.section-block { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 12px; }
.section-head h3 { margin: 0; font-size: 17px; }

.bookmarklet-card { margin: 28px 16px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); max-width: 608px; }
.bookmarklet-card summary { cursor: pointer; font-weight: 500; }
.bookmarklet-card ol { margin: 12px 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; }
.bookmarklet {
  display: inline-block; padding: 10px 18px; border-radius: 20px; background: var(--red); color: #fff;
  font-weight: 700; text-decoration: none; cursor: grab;
}
kbd { padding: 1px 6px; border-radius: 4px; background: var(--chip); font-size: 12px; }

/* ── 내 영상 ── */
.search-pill {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 16px 4px; height: 40px; padding: 0 16px;
  border-radius: 20px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line);
}
.search-pill:focus-within { box-shadow: inset 0 0 0 1px #3ea6ff; }
.search-pill svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.search-pill input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 15px; }
.search-pill input::placeholder { color: var(--muted); }

.tabs { display: flex; gap: 24px; padding: 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab {
  padding: 12px 0 9px; border: 0; background: none; color: var(--muted);
  font-size: 15px; font-weight: 500; border-bottom: 3px solid transparent;
}
.tab[aria-selected='true'] { color: var(--text); font-weight: 700; border-bottom-color: var(--text); }

.filters { display: grid; gap: 10px; margin-bottom: 12px; }
.cleanup-notice { margin-top: 0; margin-bottom: 12px; }

.cat-manager { margin: 0 16px 12px; padding: 4px 14px 14px; border-radius: var(--radius); background: var(--surface); }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-row .actions { display: flex; gap: 6px; }
.cat-manager > .chip { margin-top: 12px; }
.cat-manager p { margin: 10px 0 0; }

.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty a { color: var(--text); font-weight: 500; }

/* ── 영상 카드 (피드) ── */
.feed { display: grid; grid-template-columns: 1fr; gap: 4px; }
.vcard { cursor: pointer; padding-bottom: 20px; }
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, #2a2a3a, #3a2a2a);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute;
  bottom: 8px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(15, 15, 15, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
.badge.dur { right: 8px; }
.badge.status { left: 8px; }
.badge.warn { background: rgba(194, 40, 40, 0.92); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--red); }
.progress.done { height: 4px; }

.vmeta { display: flex; gap: 12px; padding: 12px 4px 0 12px; }
.vtexts { flex: 1; min-width: 0; }
.vtitle {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.vsub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.kebab { width: 32px; height: 32px; margin-top: -4px; flex-shrink: 0; }



/* ── 아래에서 올라오는 창 ── */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet[open] { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

.sheet-body { display: grid; gap: 16px; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); }
.handle { justify-self: center; width: 36px; height: 4px; border-radius: 2px; background: #5a5a5a; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-top: -6px; }
.sheet-head .muted { font-size: 13px; }
.sheet .thumb { border-radius: 12px; }
.play {
  position: absolute; inset: 0; margin: auto; width: 56px; height: 56px;
  display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.55);
}
.play svg { width: 26px; height: 26px; margin-left: 3px; }
.sheet-title { margin: 0; font-size: 18px; line-height: 1.4; overflow-wrap: anywhere; }
.ch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ch-row .ch-avatar { width: 28px; height: 28px; font-size: 13px; }
.pill-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }

.rcard { display: grid; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--chip); }
.rcard .chip { background: var(--surface); }
.rcard .chip[aria-pressed='true'] { background: var(--text); color: var(--inverse); }
.rrow { display: flex; align-items: center; gap: 12px; }
.rrow > svg { width: 22px; height: 22px; flex-shrink: 0; }
.rrow .texts { flex: 1; min-width: 0; display: grid; }
.rrow .texts span { color: var(--muted); font-size: 13px; }
.rinput { display: flex; gap: 8px; }
.rinput input {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 8px;
  background: var(--surface); color-scheme: dark;
}
.rcard .chip-row, .sheet .chip-row { padding: 0; }

.cat-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cat-line > span { color: var(--muted); font-size: 14px; }
.chip-select {
  height: 32px; padding: 0 30px 0 12px; border: 0; border-radius: 8px; background-color: var(--chip);
  font-size: 14px; font-weight: 500; max-width: 60%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f1f1f1' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select { color-scheme: dark; }

.review { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--chip); }
.review .label { font-weight: 700; font-size: 14px; }
.stars { display: flex; gap: 2px; }
.star { font-size: 30px; line-height: 1; padding: 2px 4px; border: 0; background: none; color: #555; }
.star.on { color: #ffc83d; }
.review form { display: flex; gap: 8px; }
.review input {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--surface);
}

.account { display: grid; gap: 14px; }
.account .me { display: flex; align-items: center; gap: 12px; }
.account .me .avatar-btn { width: 44px; height: 44px; margin: 0; font-size: 18px; }
.account .list { display: grid; border-radius: var(--radius); background: var(--chip); overflow: hidden; }
.account .list > * {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border: 0; background: none; text-align: left; text-decoration: none; font-size: 15px;
  border-bottom: 1px solid var(--surface);
}
.account .list > *:last-child { border-bottom: 0; }
.account .danger { color: #ff6b6b; }

/* ── 내 관심사 ── */
.insights { display: grid; gap: 12px; padding: 12px 16px 0; max-width: 720px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: grid; justify-items: center; gap: 2px; padding: 14px 6px; border-radius: var(--radius); background: var(--surface); }
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; }
.card { padding: 16px; border-radius: var(--radius); background: var(--surface); }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.insight-summary ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 14px; }
.insight-summary li { position: relative; padding-left: 16px; }
.insight-summary li::before { content: ''; position: absolute; left: 0; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(64px, 28%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--red); }
.bar-value { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.keywords { display: flex; flex-wrap: wrap; gap: 8px; }
.kw { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 8px; background: var(--chip); font-size: 14px; font-weight: 500; }
.kw .muted { margin-left: 4px; }

.digest .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.digest .row { display: flex; gap: 8px; margin-top: 12px; }
.digest select { flex: 1; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--chip); }
.switch {
  appearance: none; position: relative; flex-shrink: 0; width: 40px; height: 24px; margin: 0;
  border-radius: 12px; background: #555; cursor: pointer; transition: background 0.15s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.switch:checked { background: var(--red); }
.switch:checked::after { transform: translateX(16px); }

/* ── 로그인 ── */
.login { display: grid; justify-items: center; gap: 14px; padding: 72px 24px 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.login .big-logo { width: 72px; height: 72px; border-radius: 18px; }
.login h2 { margin: 8px 0 0; font-size: 24px; line-height: 1.35; letter-spacing: -0.4px; }
.login p { margin: 0; color: var(--muted); }
.google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  height: 48px; margin-top: 16px; border: 0; border-radius: 24px; background: var(--text); color: var(--inverse);
  font-size: 15px; font-weight: 700;
}
.google-btn svg { width: 20px; height: 20px; }

/* ── 아래 메뉴 ── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.bottom-nav[hidden] { display: none; }
.bottom-nav a {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text);
  opacity: 0.6;
  text-decoration: none;
  font-size: 10.5px;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a[aria-current='page'] { opacity: 1; font-weight: 700; }
.bottom-nav .count { font-weight: inherit; }
.bottom-nav .count:empty { display: none; }

/* ── 알림 메시지 ── */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  z-index: 10;
  transform: translateX(-50%) translateY(16px);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 8px;
  background: #f1f1f1;
  color: #0f0f0f;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 보조 페이지(개인정보처리방침) */
body > main:not(#app) { padding: 0 16px 48px; max-width: 760px; }

/* 격자 안 입력칸이 화면보다 넓어지지 않게 */
.add-hero, .sheet-body, .insights, .rcard, .review, .account { grid-template-columns: minmax(0, 1fr); }
/* 창이 열릴 때 썸네일에 생기는 포커스 테두리는 키보드로 움직일 때만 */
.sheet :focus:not(:focus-visible) { outline: none; }
.rcard .chip.white { background: var(--text); color: var(--inverse); }
.handle:focus { outline: none; }

/* ── PC·태블릿: 휴대폰 앱처럼 가운데 좁은 화면으로 ── */
@media (min-width: 600px) {
  :root { --app-w: 480px; }
  html { background: #000; }
  body {
    max-width: var(--app-w);
    min-height: 100vh;
    margin: 0 auto;
    box-shadow: 0 0 0 1px #222, 0 0 60px rgba(0, 0, 0, 0.6);
  }
  .bottom-nav { max-width: var(--app-w); margin: 0 auto; }
  .sheet { max-width: var(--app-w); margin: auto auto 0; border-radius: 20px 20px 0 0; }
  .thumb { border-radius: 12px; }
  .feed { padding: 0 16px; }
  .vmeta { padding-left: 0; }
  .section-block .vcard { padding: 0 16px 20px; }
}
.import-card { margin-top: 0; }
