:root {
  --bg: #ffffff;
  --bg-soft: #f2f2f2;
  --bg-hover: #e5e5e5;
  --text: #0f0f0f;
  --text-sub: #606060;
  --border: #d9d9d9;
  --accent: #10b981;
  --skeleton: #e8e8e8;
  --topbar-h: 56px;
  --sidebar-w: 220px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --bg-soft: #222222;
    --bg-hover: #333333;
    --text: #f1f1f1;
    --text-sub: #aaaaaa;
    --border: #303030;
    --skeleton: #262626;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-soft: #222222;
  --bg-hover: #333333;
  --text: #f1f1f1;
  --text-sub: #aaaaaa;
  --border: #303030;
  --skeleton: #262626;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* 상단 바 */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px; background: var(--bg);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn[hidden] { display: none; }
.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 19px; letter-spacing: -0.5px; }
.logo-mark { width: 30px; height: 22px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.logo-mark svg { width: 16px; height: 16px; fill: #fff; stroke: none; }

.search { flex: 1; max-width: 640px; display: flex; }
.search-box { position: relative; flex: 1; }
.search input {
  width: 100%; height: 40px; padding: 0 16px; font-size: 16px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-right: 0; border-radius: 20px 0 0 20px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search-btn { width: 64px; height: 40px; border: 1px solid var(--border); border-radius: 0 20px 20px 0; background: var(--bg-soft); display: grid; place-items: center; }
.search-btn svg { width: 20px; height: 20px; }
.suggestions {
  position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 8px 0; list-style: none;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 24px rgba(0, 0, 0, .15);
}
.suggestions li { padding: 6px 16px; cursor: pointer; font-size: 15px; }
.suggestions li:hover, .suggestions li.active { background: var(--bg-hover); }

/* 사이드바 */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  padding: 12px; overflow-y: auto; background: var(--bg); z-index: 15;
}
.sidebar a { display: flex; align-items: center; gap: 20px; padding: 10px 12px; border-radius: 10px; }
.sidebar a:hover { background: var(--bg-hover); }
.sidebar a.active { background: var(--bg-soft); font-weight: 600; }
body.sidebar-collapsed .sidebar { display: none; }

.content { padding: calc(var(--topbar-h) + 8px) 24px 40px calc(var(--sidebar-w) + 24px); min-height: 100vh; }
body.sidebar-collapsed .content { padding-left: 24px; }

/* 카테고리 칩 */
.chips { position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg); display: flex; gap: 12px; padding: 12px 0; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 6px 12px; border-radius: 8px; background: var(--bg-soft); font-weight: 500; white-space: nowrap; }
.chip:hover { background: var(--bg-hover); }
.chip.active { background: var(--text); color: var(--bg); }

/* 영상 카드 그리드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 40px 16px; padding-top: 12px; }
.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--skeleton); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.03); }
.duration { position: absolute; right: 6px; bottom: 6px; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 12px; font-weight: 500; }
.duration:empty { display: none; }
.card-popup {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 8px;
  display: none; place-items: center; background: rgba(0, 0, 0, .7); color: #fff; cursor: pointer;
}
.card-popup svg { width: 18px; height: 18px; }
.card-popup:hover { background: rgba(0, 0, 0, .9); }
@media (hover: hover) and (min-width: 801px) {
  .card:hover .card-popup { display: grid; }
}
.feed-note { margin: 4px 0 0; color: var(--text-sub); font-size: 13px; }

/* 이어보기 */
.card-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .45); }
.card-progress > div { height: 100%; background: #ff0033; }
.card-progress ~ .duration { bottom: 10px; }
.continue { margin: 8px 0 20px; }
.continue .section-title { margin: 4px 0 12px; font-size: 18px; }
.continue-row { display: grid; grid-auto-flow: column; grid-auto-columns: 260px; gap: 14px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.continue-row .card-title { font-size: 14px; }
.resume-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 8px 8px 8px 14px;
  border-radius: 12px; background: var(--bg-soft); font-size: 14px; color: var(--text-sub);
}
.resume-bar button { padding: 6px 14px; border-radius: 16px; background: var(--bg); font-weight: 600; color: var(--text); }

/* 댓글 */
.comments { margin-top: 24px; }
.comments-title { font-size: 18px; margin: 0 0 16px; }
.comment-list { display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 12px; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--skeleton); }
.comment-avatar.placeholder { display: grid; place-items: center; font-weight: 700; color: var(--text-sub); }
.comment-body { min-width: 0; flex: 1; }
.comment-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time { color: var(--text-sub); font-size: 12px; }
.comment-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.comment-text a { color: #3ea6ff; }
.comment-stats { margin-top: 6px; color: var(--text-sub); font-size: 12px; white-space: pre; }
.comments-empty { color: var(--text-sub); margin: 0; }
.feed-status { min-height: 1px; }
.feed-loading, .feed-end { padding: 32px 0; text-align: center; color: var(--text-sub); }
.feed-end { margin: 0; }
.card-body { display: flex; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--skeleton); }
.avatar[hidden] { display: none !important; }
.card-text { display: flex; flex-direction: column; min-width: 0; }
.card-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-channel, .card-meta { color: var(--text-sub); font-size: 14px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-channel:hover { color: var(--text); }

/* 가로형 카드 (관련 영상, 검색 결과) */
.list { display: flex; flex-direction: column; gap: 12px; }
.list .card { flex-direction: row; gap: 10px; }
.list .thumb { width: 168px; flex-shrink: 0; border-radius: 8px; }
.list .avatar { display: none; }
.list .card-title { font-size: 14px; }
.list .card-channel, .list .card-meta { font-size: 12px; }

.search-results { max-width: 1100px; padding-top: 16px; gap: 16px; }
.search-results .thumb { width: min(360px, 45%); border-radius: 12px; }
.search-results .card { gap: 16px; }
.search-results .card-title { font-size: 18px; }
.search-results .avatar { display: block; width: 24px; height: 24px; }
.search-results .card-body { flex-direction: column; gap: 8px; }

/* 시청 페이지 */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; padding-top: 16px; max-width: 1700px; }
.player { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.watch-title { margin: 12px 0 8px; font-size: 20px; font-weight: 700; line-height: 1.4; }
.owner { display: flex; align-items: center; gap: 12px; }
.watch-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.popup-btn { height: 36px; padding: 0 16px; border-radius: 18px; background: var(--bg-soft); font-weight: 600; }
.popup-btn:hover { background: var(--bg-hover); }
.watch-buttons { display: flex; align-items: center; gap: 12px; }
.autoplay-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; user-select: none; }
.autoplay-toggle input {
  appearance: none; width: 36px; height: 20px; margin: 0; border-radius: 10px; background: var(--border);
  position: relative; cursor: pointer; transition: background .15s;
}
.autoplay-toggle input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.autoplay-toggle input:checked { background: var(--accent); }
.autoplay-toggle input:checked::after { transform: translateX(16px); }
.unmute-btn {
  position: absolute; left: 12px; bottom: 56px; z-index: 2; padding: 8px 14px; border-radius: 18px;
  background: rgba(0, 0, 0, .75); color: #fff; font-weight: 600;
}
.owner img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--skeleton); }
.owner-name { font-weight: 600; font-size: 16px; }
.owner-subs { color: var(--text-sub); font-size: 12px; }
.description { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--bg-soft); white-space: pre-wrap; word-break: break-word; line-height: 1.6; max-height: 120px; overflow: hidden; cursor: pointer; }
.description.open { max-height: none; cursor: auto; }
.description-meta { font-weight: 600; margin-bottom: 4px; }
.description a { color: #3ea6ff; }

/* 채널 페이지 */
.channel-banner { aspect-ratio: 6 / 1; border-radius: 16px; background: var(--bg-soft) center / cover no-repeat; margin-top: 8px; }
.channel-head { display: flex; align-items: center; gap: 20px; padding: 20px 0; }
.channel-head img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; background: var(--skeleton); }
.channel-head h1 { margin: 0 0 6px; font-size: 32px; }
.channel-head p { margin: 0; color: var(--text-sub); max-width: 700px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.section-title { font-size: 20px; margin: 16px 0 0; }

/* 로딩/오류 */
.skeleton .thumb, .skeleton .avatar, .skeleton .line { background: var(--skeleton); animation: pulse 1.2s ease-in-out infinite; }
.skeleton .line { height: 14px; border-radius: 4px; margin-bottom: 8px; }
@keyframes pulse { 50% { opacity: .5; } }
.message { padding: 80px 16px; text-align: center; color: var(--text-sub); font-size: 16px; }
.message button { margin-top: 16px; padding: 8px 18px; border-radius: 18px; background: var(--bg-soft); font-weight: 500; }

@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
}

/* 단축키 설정 창 */
.settings {
  max-height: calc(100vh - 32px); overflow-y: auto;
  width: min(380px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 16px;
  background: var(--bg); color: var(--text); box-shadow: 0 8px 40px rgba(0, 0, 0, .3);
}
.settings::backdrop { background: rgba(0, 0, 0, .5); }
.settings h2 { margin: 0 0 6px; font-size: 18px; }
.settings p { margin: 0 0 16px; color: var(--text-sub); line-height: 1.5; }
.settings .hint { margin: 16px 0 0; font-size: 12px; }
.settings .section-gap { margin-top: 24px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings kbd {
  min-width: 40px; padding: 4px 10px; border: 1px solid var(--border); border-bottom-width: 3px; border-radius: 8px;
  background: var(--bg-soft); font: 600 15px/1.4 ui-monospace, monospace; text-align: center;
}
.settings button { width: 100%; height: 40px; border-radius: 20px; background: var(--bg-soft); font-weight: 600; }
.settings button:hover { background: var(--bg-hover); }
.settings button.primary { background: var(--accent); color: #fff; }
.settings button.primary.recording { animation: pulse 1s ease-in-out infinite; }
.settings-actions { display: flex; gap: 8px; margin-top: 8px; }
.settings .close { margin-top: 16px; background: none; border: 1px solid var(--border); }

.account-section { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.account-section h2 { margin-bottom: 12px; }
.history-section { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.disguise-section { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.disguise-section h2 { margin-bottom: 6px; }
/* 미리보기: 브라우저 탭처럼 */
.disguise-preview {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; margin-bottom: 10px; max-width: 240px;
  border-radius: 10px 10px 0 0; background: var(--bg-soft); border-bottom: 2px solid var(--accent); font-size: 13px;
}
.disguise-preview img { width: 16px; height: 16px; flex-shrink: 0; }
.disguise-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings select, .disguise-custom input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.disguise-custom { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.disguise-custom[hidden] { display: none; }
.disguise-custom .hint { margin: 0; }
.settings-link[hidden] { display: none; }
.settings-link {
  display: flex; align-items: center; justify-content: center; height: 40px; margin-bottom: 8px;
  border-radius: 20px; background: var(--accent); color: #fff; font-weight: 600;
}

/* 로그인 / 가입 화면 */
body.auth-mode .apps-btn, body.auth-mode #topLogoutBtn, body.auth-mode .sidebar, body.auth-mode .search, body.auth-mode .search-open-btn, body.auth-mode .logo { display: none !important; }
body.auth-mode .topbar { background: transparent; }
body.auth-mode .content { padding: 0; }
:root { --auth-glow-1: rgba(16, 185, 129, .22); --auth-glow-2: rgba(59, 130, 246, .18); --auth-glow-3: rgba(236, 72, 153, .12); --auth-card: rgba(255, 255, 255, .82); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --auth-glow-1: rgba(16, 185, 129, .20); --auth-glow-2: rgba(59, 130, 246, .16); --auth-glow-3: rgba(236, 72, 153, .10); --auth-card: rgba(28, 28, 30, .78); }
}
:root[data-theme="dark"] { --auth-glow-1: rgba(16, 185, 129, .20); --auth-glow-2: rgba(59, 130, 246, .16); --auth-glow-3: rgba(236, 72, 153, .10); --auth-card: rgba(28, 28, 30, .78); }
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 72px 16px 40px;
  background:
    radial-gradient(600px 400px at 15% 20%, var(--auth-glow-1), transparent 70%),
    radial-gradient(520px 420px at 85% 30%, var(--auth-glow-2), transparent 70%),
    radial-gradient(500px 380px at 50% 95%, var(--auth-glow-3), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%); padding: 32px 28px 24px; border-radius: 24px; background: var(--auth-card);
  border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: auth-in .35s ease-out;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.auth-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 22px; }
.auth-logo {
  width: 56px; height: 56px; border-radius: 18px; margin-bottom: 14px; position: relative;
  background: linear-gradient(135deg, #34d399, #10b981 55%, #0ea5e9); box-shadow: 0 8px 24px rgba(16, 185, 129, .35);
}
.auth-logo::after {
  content: ''; position: absolute; left: 22px; top: 17px; border-style: solid; border-width: 11px 0 11px 17px;
  border-color: transparent transparent transparent #fff;
}
.auth-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.auth-subtitle { margin: 6px 0 0; color: var(--text-sub); font-size: 14px; }

.auth-tabs { position: relative; display: flex; padding: 4px; margin-bottom: 22px; border-radius: 14px; background: var(--bg-soft); }
.auth-tabs::before {
  content: ''; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 10px;
  background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); transition: transform .25s cubic-bezier(.3, .7, .4, 1);
}
.auth-tabs.signup::before { transform: translateX(100%); }
.auth-tab { position: relative; flex: 1; height: 38px; border-radius: 10px; font-weight: 700; color: var(--text-sub); transition: color .2s; }
.auth-tab.active { color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 700; font-size: 13px; }
.field-box {
  display: flex; align-items: center; height: 48px; padding: 0 6px 0 14px; border-radius: 14px;
  background: var(--bg); border: 1.5px solid var(--border); transition: border-color .15s, box-shadow .15s;
}
.field-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(16, 185, 129, .15); }
.field.invalid .field-box { border-color: #e5484d; box-shadow: 0 0 0 4px rgba(229, 72, 77, .12); }
.field-box input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16px; padding: 0 8px 0 10px; }
.field-box input::placeholder { color: var(--text-sub); opacity: .7; }
.auth-icon, .field-eye { display: grid; place-items: center; color: var(--text-sub); flex-shrink: 0; }
.auth-icon svg { width: 20px; height: 20px; }
.field-box:focus-within .auth-icon { color: var(--accent); }
.field-eye { width: 36px; height: 36px; border-radius: 10px; }
.field-eye:hover { background: var(--bg-soft); color: var(--text); }
.field-eye svg { width: 20px; height: 20px; }
.field-hint { font-size: 12px; color: var(--text-sub); padding-left: 4px; }
.field-hint:empty { display: none; }
.field.valid .field-hint { color: var(--accent); }
.field.valid .field-hint::before { content: '✓ '; font-weight: 700; }
.field.invalid .field-hint { color: #e5484d; }

.auth-message { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; color: #c9373c; background: rgba(229, 72, 77, .1); }
.auth-message:empty { display: none; }
.auth-message.ok { color: #0f8a62; background: rgba(16, 185, 129, .12); font-weight: 600; }
.auth-message.blocked { white-space: pre-line; font-weight: 600; }
.auth-message.wait { color: #a86700; background: rgba(245, 158, 11, .14); }
.auth-submit {
  position: relative; height: 50px; border-radius: 16px; margin-top: 4px; color: #fff; font-weight: 800; font-size: 16px;
  background: linear-gradient(135deg, #34d399, #10b981 50%, #059669); box-shadow: 0 8px 20px rgba(16, 185, 129, .3);
  transition: transform .1s, box-shadow .2s, filter .2s;
}
.auth-submit:hover { filter: brightness(1.05); box-shadow: 0 10px 24px rgba(16, 185, 129, .38); }
.auth-submit:active { transform: scale(.98); }
.auth-submit:disabled { cursor: default; filter: saturate(.7); }
.auth-submit.loading span { visibility: hidden; }
.auth-submit.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-foot { margin: 2px 0 0; text-align: center; font-size: 12px; color: var(--text-sub); }

.auth-done { display: flex; flex-direction: column; align-items: stretch; text-align: center; gap: 8px; }
.auth-done-badge {
  align-self: center; display: grid; place-items: center; width: 64px; height: 64px; margin: -6px 0 6px; border-radius: 50%;
  background: rgba(16, 185, 129, .14); color: var(--accent); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1);
}
.auth-done-badge svg { width: 34px; height: 34px; stroke-width: 2.6; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.auth-done-text { margin: 0; font-size: 17px; font-weight: 700; }
.auth-done-sub { margin: 0 0 8px; color: var(--text-sub); font-size: 14px; line-height: 1.5; }
.auth-done-id { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-radius: 14px; background: var(--bg-soft); font-size: 14px; margin-bottom: 8px; }
.auth-done-id span { color: var(--text-sub); }

@media (max-width: 480px) {
  .auth { align-items: flex-start; padding-top: 72px; }
  .auth-card { padding: 28px 20px 20px; border-radius: 22px; }
}

/* 관리자 화면 */
.admin { max-width: 720px; margin: 0 auto; padding: 16px 0 40px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-head h1 { margin: 0; font-size: 22px; }
.admin-refresh { padding: 8px 16px; border-radius: 18px; background: var(--bg-soft); font-weight: 600; }
.admin-section h2 { margin: 28px 0 10px; font-size: 16px; }
.admin-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.admin-row + .admin-row { border-top: 1px solid var(--border); }
.admin-user { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-user strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.admin-user span { font-size: 12px; color: var(--text-sub); }
.admin-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-actions button { padding: 7px 14px; border-radius: 16px; background: var(--bg-soft); font-weight: 600; font-size: 13px; }
.admin-actions button.approve { background: var(--accent); color: #fff; }
.admin-actions button.danger { color: #e5484d; }
.admin-actions button:disabled { opacity: .5; }
.admin-empty { margin: 0; color: var(--text-sub); }
.admin-row { flex-wrap: wrap; }
.temp-password {
  flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 4px; padding: 12px 14px;
  border-radius: 12px; background: rgba(245, 158, 11, .12); border: 1px dashed rgba(245, 158, 11, .6);
}
.temp-password span { display: block; font-size: 12px; color: var(--text-sub); }
.temp-password code { font: 700 20px/1.3 ui-monospace, monospace; letter-spacing: 2px; }
.temp-password button { padding: 7px 14px; border-radius: 16px; background: var(--bg); font-weight: 600; font-size: 13px; }
.temp-password p { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--text-sub); }
.admin-message { padding: 12px 16px; }
.admin-message + .admin-message { border-top: 1px solid var(--border); }
.admin-message.read { opacity: .65; }
.admin-message-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-message-head strong { color: var(--text); }
.admin-message:not(.read) .admin-message-head strong { color: var(--accent); }
.admin-message-text { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 14px; }
.auth-link { display: block; text-align: center; font-size: 13px; color: var(--text-sub); text-decoration: underline; text-underline-offset: 3px; }
.auth-link:hover { color: var(--accent); }
.auth-link.as-button { width: 100%; background: none; }
.auth-submit.as-link { display: grid; place-items: center; }
.auth-form textarea {
  min-height: 120px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; resize: vertical; outline: none;
}
.auth-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(16, 185, 129, .15); }
.field-box input:disabled { color: var(--text-sub); }
.settings-button {
  flex: 1; display: grid; place-items: center; height: 40px; border-radius: 20px; background: var(--bg-soft); font-weight: 600; font-size: 14px;
}
.settings-button:hover { background: var(--bg-hover); }
.settings-button[hidden] { display: none; }
.account-section .settings-actions { margin: 0 0 8px; }
.reply-banner {
  display: flex; align-items: center; gap: 10px; margin: -8px 0 18px; padding: 12px 14px; border-radius: 14px;
  background: rgba(16, 185, 129, .12); color: var(--text); font-weight: 700; font-size: 14px; animation: pop .35s ease-out;
}
.reply-banner-go { margin-left: auto; color: var(--accent); }
.reply-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.reply-item { padding: 14px; border-radius: 14px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.reply-mine span { font-size: 12px; color: var(--text-sub); }
.reply-mine p { margin: 4px 0 0; font-size: 13px; color: var(--text-sub); white-space: pre-wrap; word-break: break-word; }
.reply-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 10px; }
.reply-text .temp-password { white-space: normal; }
.reply-waiting { margin: 0; font-size: 13px; color: var(--text-sub); }
.reply-dismiss { align-self: flex-end; padding: 6px 12px; border-radius: 14px; background: var(--bg-soft); font-size: 12px; font-weight: 600; }
.admin-reply { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.admin-reply textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; font-size: 14px; resize: vertical;
}
.admin-reply.sent { padding: 10px 12px; border-radius: 10px; background: rgba(16, 185, 129, .1); }
.admin-reply.sent span { font-size: 12px; color: var(--text-sub); }
.admin-reply.sent p { margin: 4px 0 0; white-space: pre-wrap; font-size: 14px; }
.admin-reply-note { font-size: 12px; color: var(--text-sub); }

.search-back, .search-open-btn { display: none; }

/* 쇼츠: 세로로 한 개씩 */
body.shorts-mode .content { padding-bottom: 0; }
.shorts {
  height: calc(100dvh - var(--topbar-h) - 8px); overflow-y: auto; scroll-snap-type: y mandatory;
  scrollbar-width: none; outline: none;
}
.shorts::-webkit-scrollbar { display: none; }
.short { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; align-items: center; justify-content: center; padding: 8px 0; }
.short-frame { position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; }
.short-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.short-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 2; }
.short-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 16px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
.short-title { font-weight: 600; font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.short-meta { margin-top: 4px; font-size: 12px; opacity: .85; }
.shorts .message { padding-top: 120px; }

/* 가리기: 아무것도 없는 빈 화면 */
.cover { position: fixed; inset: 0; z-index: 1000; background: var(--decoy-bg); color: var(--decoy-text); cursor: default; }
:root { --decoy-bg: #fff; --decoy-text: #202124; --decoy-border: #dfe1e5; --decoy-btn: #f8f9fa; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --decoy-bg: #202124; --decoy-text: #e8eaed; --decoy-border: #5f6368; --decoy-btn: #303134; }
}
:root[data-theme="dark"] { --decoy-bg: #202124; --decoy-text: #e8eaed; --decoy-border: #5f6368; --decoy-btn: #303134; }
.decoy { display: flex; flex-direction: column; align-items: center; padding: 0 16px; margin-top: max(120px, 22vh); font-family: Arial, sans-serif; }
.decoy-logo { font-size: clamp(56px, 12vw, 92px); letter-spacing: -0.04em; font-weight: 500; user-select: none; margin-bottom: 26px; }
.decoy-c0, .decoy-c3 { color: #4285f4; }
.decoy-c1, .decoy-c5 { color: #ea4335; }
.decoy-c2 { color: #fbbc05; }
.decoy-c4 { color: #34a853; }
.decoy-search {
  position: relative; display: flex; align-items: center; width: min(584px, 100%); height: 46px;
  border: 1px solid var(--decoy-border); border-radius: 24px; background: var(--decoy-bg);
}
.decoy-search:hover, .decoy-search:focus-within { box-shadow: 0 1px 6px rgba(32, 33, 36, .28); border-color: transparent; }
.decoy-icon {
  width: 14px; height: 14px; margin: 0 12px 0 18px; border: 2px solid #9aa0a6; border-radius: 50%; position: relative; flex-shrink: 0;
}
.decoy-icon::after { content: ''; position: absolute; width: 2px; height: 7px; background: #9aa0a6; right: -4px; bottom: -6px; transform: rotate(-45deg); }
.decoy-search input { flex: 1; height: 100%; border: 0; outline: none; background: transparent; color: var(--decoy-text); font-size: 16px; padding-right: 18px; }
.decoy-buttons { display: flex; gap: 12px; margin-top: 28px; }
.decoy-buttons button {
  height: 36px; padding: 0 16px; border: 1px solid var(--decoy-btn); border-radius: 4px; background: var(--decoy-btn);
  color: var(--decoy-text); font: 14px Arial, sans-serif;
}
.decoy-buttons button:hover { border-color: var(--decoy-border); }
.cover[hidden] { display: none; }

/* ---------- 휴대폰 ---------- */
@media (max-width: 800px) {
  :root { --topbar-h: 48px; --bottom-h: 56px; }

  .topbar { padding: 0 4px 0 12px; gap: 4px; }
  #menuBtn, .shortcut-section, .popup-btn, body.auth-mode .settings-btn { display: none; }
  .shorts { height: calc(100dvh - var(--topbar-h) - var(--bottom-h) - env(safe-area-inset-bottom)); }
  .short { padding: 0; }
  .short-frame { border-radius: 0; width: 100%; aspect-ratio: auto; }
  body.shorts-mode .content { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); }
  .history-section { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
  .admin { padding: 16px 12px 40px; }
  .logo-text { font-size: 17px; }
  .topbar-right { gap: 0; }

  /* 검색: 돋보기를 누르면 상단 바 전체가 검색창이 된다 */
  .search { display: none; }
  .search-open-btn { display: grid; }
  body.search-open .search { display: flex; position: absolute; inset: 0; align-items: center; gap: 4px; padding: 0 8px 0 4px; background: var(--bg); max-width: none; }
  body.search-open .search-back { display: grid; flex-shrink: 0; }
  .search input { height: 36px; border-radius: 18px; border: 0; background: var(--bg-soft); padding: 0 14px; }
  .search-btn { display: none; }
  .suggestions { position: fixed; top: var(--topbar-h); left: 0; right: 0; border-radius: 0; border: 0; border-bottom: 1px solid var(--border); }
  .suggestions li { padding: 12px 16px; }

  /* 사이드바 → 하단 탭바 */
  .sidebar, body.sidebar-collapsed .sidebar {
    display: flex; top: auto; bottom: 0; width: 100%; height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
    padding: 0 0 env(safe-area-inset-bottom); overflow: visible; border-top: 1px solid var(--border); z-index: 20;
  }
  .sidebar a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 0; border-radius: 0; font-size: 10px; }
  .sidebar a svg { width: 22px; height: 22px; }
  .sidebar a:hover { background: none; }
  .sidebar a.active { background: none; font-weight: 700; }
  .sidebar a.active svg { stroke-width: 2.4; }

  .content, body.sidebar-collapsed .content { padding: var(--topbar-h) 0 calc(var(--bottom-h) + env(safe-area-inset-bottom) + 16px); }

  .chips { padding: 8px 12px; gap: 8px; }
  .chip { padding: 5px 12px; font-size: 13px; }

  /* 영상 카드: 화면 꽉 차는 썸네일 */
  .grid { grid-template-columns: 1fr; gap: 20px; padding-top: 4px; }
  .grid .thumb, .list .thumb, .search-results .thumb { width: 100%; border-radius: 0; }
  .card-body { padding: 0 12px; }
  .card-title { font-size: 15px; }
  .card-channel, .card-meta { font-size: 12px; display: inline; }
  .card-channel:not(:empty) + .card-meta:not(:empty)::before { content: ' · '; }
  .card-text { display: block; }
  .card-title { margin-bottom: 2px; }
  .list, .search-results { gap: 20px; padding-top: 4px; }
  .list .card, .search-results .card { flex-direction: column; gap: 12px; }
  .list .avatar, .search-results .avatar { display: block; width: 36px; height: 36px; }
  .search-results .card-body { flex-direction: row; gap: 12px; }
  .list .card-title, .search-results .card-title { font-size: 15px; }
  .list .card-channel, .list .card-meta { font-size: 12px; }

  /* 시청 화면: 플레이어는 위에 고정, 아래로 정보와 관련 영상 */
  .watch { display: block; padding-top: 0; }
  .watch > div:first-child { display: contents; }
  .player { position: sticky; top: var(--topbar-h); z-index: 12; border-radius: 0; }
  .watch-title { font-size: 17px; margin: 12px 12px 10px; }
  .watch-actions { padding: 0 12px; }
  .owner img { width: 34px; height: 34px; }
  .owner-name { font-size: 14px; }
  .description { margin: 12px 12px 0; max-height: 96px; font-size: 13px; }
  .watch aside { margin-top: 20px; }
  .watch .message { padding: 24px 12px; }
  .comments { padding: 0 12px; }
  .resume-bar { margin: 10px 12px 0; }
  .continue { margin: 8px 0 16px; }
  .continue .section-title { margin: 4px 12px 10px; }
  .continue-row { grid-auto-columns: 72%; padding: 0 12px 6px; }
  .continue-row .thumb { border-radius: 10px; }
  .continue-row .card-body { padding: 0; }

  /* 채널 */
  .channel-banner { border-radius: 0; margin-top: 0; aspect-ratio: 4 / 1; }
  .channel-head { padding: 16px 12px; gap: 14px; }
  .channel-head img { width: 64px; height: 64px; }
  .channel-head h1 { font-size: 20px; margin-bottom: 4px; }
  .channel-head p { font-size: 12px; }
  .section-title { margin: 0 12px 8px; font-size: 16px; }
}

/* 큰 휴대폰 가로 / 태블릿: 2열 */
/* 좁은 휴대폰: 상단 버튼(검색·테마·설정·로그아웃·나가기)이 다 들어가도록 로고 글자는 숨긴다 */
@media (max-width: 430px) {
  .logo-text { display: none; }
}

@media (min-width: 561px) and (max-width: 800px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 24px 12px; padding: 4px 12px 0; }
  .grid .thumb { border-radius: 10px; }
  .grid .card-body { padding: 0; }
}

@media (hover: none) {
  .card:hover .thumb img { transform: none; }
}

/* 잠깐 뜨는 안내 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px; background: #202124; color: #fff; font-size: 14px; line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

/* 체험하기 */
.trial-box { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.trial-box p { margin: 0; font-size: 14px; font-weight: 600; }
.trial-box span { font-size: 12px; color: var(--text-sub); }
.trial-start { width: 100%; padding: 12px; border-radius: 14px; border: 1.5px solid var(--accent, #10b981); color: var(--accent, #10b981); background: transparent; font-weight: 700; font-size: 15px; cursor: pointer; }
.trial-start:hover { background: rgba(16, 185, 129, .08); }
.trial-start:disabled { opacity: .6; cursor: default; }
.trial-bar[hidden] { display: none; }
.trial-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; padding: 9px 14px; border-radius: 20px;
  background: #202124; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
@media (max-width: 800px) {
  .trial-bar { right: 12px; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 10px); }
}

/* 앱 목록 (처음 화면) */
body.launcher-mode .sidebar, body.launcher-mode .search, body.launcher-mode .search-open-btn,
body.launcher-mode .logo, body.launcher-mode #menuBtn, body.launcher-mode .apps-btn { display: none !important; }
body.launcher-mode .content, body.launcher-mode.sidebar-collapsed .content { padding-left: 24px; padding-right: 24px; }
.launcher { max-width: 760px; margin: 0 auto; padding: 48px 0 40px; }
.launcher-title { margin: 0 0 28px; font-size: 26px; text-align: center; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 20px; justify-items: center; }
.app-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; width: 112px; border-radius: 18px; color: inherit; text-decoration: none; }
a.app-tile:hover { background: var(--bg-hover); }
.app-icon { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px rgba(16, 185, 129, .3); }
.app-icon svg { width: 36px; height: 36px; fill: #fff; stroke: none; }
.app-name { font-size: 14px; font-weight: 600; text-align: center; }
.app-tile.soon .app-icon { background: transparent; border: 2px dashed var(--border); color: var(--text-sub); font-size: 30px; box-shadow: none; }
.app-tile.soon .app-name { color: var(--text-sub); font-weight: 500; }
@media (max-width: 800px) {
  body.launcher-mode .content { padding: var(--topbar-h) 16px 24px; }
  body.launcher-mode .sidebar { display: none !important; }
  .launcher { padding-top: 32px; }
  .launcher-title { font-size: 22px; }
}
.apps-btn { color: inherit; }
.apps-btn svg circle { fill: currentColor; stroke: none; }

/* ---------- 다른 앱 (체스 등) 공통: 유튜브 메뉴·검색 숨기고 앱 이름 표시 ---------- */
.app-title { display: none; font-size: 18px; font-weight: 700; }
body.app-mode .app-title { display: inline; }
body.app-mode .sidebar, body.app-mode .search, body.app-mode .search-open-btn,
body.app-mode .logo, body.app-mode #menuBtn { display: none !important; }
body.app-mode .content, body.app-mode.sidebar-collapsed .content { padding-left: 24px; padding-right: 24px; }
@media (max-width: 800px) {
  body.app-mode .content { padding: var(--topbar-h) 10px 24px; }
}

/* ---------- 체스 ---------- */
.chess-menu { max-width: 560px; margin: 0 auto; padding: 32px 0; display: flex; flex-direction: column; gap: 12px; }
.chess-menu h1, .chess-lobby h1, .chess-panel h1 { margin: 0 0 8px; font-size: 24px; }
.chess-mode { display: flex; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 16px; color: inherit; text-decoration: none; }
.chess-mode:hover { background: var(--bg-hover); }
.chess-mode-icon { width: 56px; height: 56px; flex-shrink: 0; border-radius: 14px; display: grid; place-items: center; font-size: 34px; background: #769656; color: #fff; }
.chess-mode-text { display: flex; flex-direction: column; gap: 4px; }
.chess-mode-text strong { font-size: 17px; }
.chess-mode-text span { font-size: 13px; color: var(--text-sub); }

.chess-lobby { max-width: 560px; margin: 0 auto; padding: 24px 0; display: flex; flex-direction: column; gap: 14px; }
.chess-panel { max-width: 560px; margin: 0 auto; width: 100%; box-sizing: border-box; padding: 20px; border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; gap: 10px; }
.chess-lobby .chess-panel { margin: 0; }
.chess-panel h2 { margin: 0; font-size: 16px; }
.chess-panel select, .join-form input { height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: inherit; font-size: 15px; }
.join-form { display: flex; gap: 8px; }
.join-form input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.hint-text { margin: 0; font-size: 13px; color: var(--text-sub); line-height: 1.5; }
.chess-error { margin: 0; font-size: 13px; color: #c9373c; }
.chess-error:empty { display: none; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: #769656; border-color: #769656; color: #fff; }
.chess-primary, .chess-actions button, .chess-actions .button-like, .offer button {
  padding: 10px 16px; border-radius: 10px; border: 0; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--bg-soft); color: inherit;
}
.chess-primary, .chess-actions .chess-primary { background: #81b64c; color: #fff; }
.chess-primary:hover { background: #95c75f; }
.chess-primary.small { padding: 8px 14px; font-size: 13px; }
.chess-primary:disabled, .chess-actions button:disabled { opacity: .6; cursor: default; }
.chess-actions .danger { color: #c9373c; }
.chess-back { font-size: 14px; color: var(--text-sub); text-decoration: none; }
.chess-panel input[type="range"] { width: 100%; accent-color: #81b64c; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.room-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg-soft); }
.room-list li.room-empty { justify-content: center; color: var(--text-sub); font-size: 14px; background: transparent; }
.room-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-info span { font-size: 12px; color: var(--text-sub); }
.waiting { text-align: center; align-items: center; margin-top: 32px; }
.room-code { font-size: 44px; font-weight: 800; letter-spacing: 8px; padding: 10px 20px; border-radius: 14px; background: var(--bg-soft); font-family: ui-monospace, monospace; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: #81b64c; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chess-game { display: flex; gap: 20px; justify-content: center; align-items: flex-start; padding: 12px 0; }
.board-col { width: min(100%, 600px, calc(100vh - var(--topbar-h) - 120px)); display: flex; flex-direction: column; gap: 6px; }
.side-col { width: 280px; display: flex; flex-direction: column; gap: 10px; }
.board-wrap { position: relative; }
.board {
  position: relative; display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; width: 100%;
  border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
}
.sq { position: relative; aspect-ratio: 1; }
.sq.light { background: #ebecd0; }
.sq.dark { background: #779556; }
.sq.last.light, .sq.selected.light { background: #f5f682; }
.sq.last.dark, .sq.selected.dark { background: #b9ca43; }
.sq.hint { box-shadow: inset 0 0 0 4px rgba(56, 132, 255, .8); }
.sq.check { background: radial-gradient(circle, #ff3b3b 0%, #e33 30%, rgba(200, 0, 0, .4) 60%, transparent 80%), #779556; }
.sq.light.check { background: radial-gradient(circle, #ff3b3b 0%, #e33 30%, rgba(200, 0, 0, .4) 60%, transparent 80%), #ebecd0; }
.sq.dest::after { content: ''; position: absolute; inset: 35%; border-radius: 50%; background: rgba(0, 0, 0, .18); }
.sq.capture::after { content: ''; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(0, 0, 0, .18); box-sizing: border-box; }
.piece { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; cursor: grab; }
.piece.dragging { opacity: .3; }
.piece.ghost { position: absolute; inset: auto; left: 0; top: 0; z-index: 5; pointer-events: none; cursor: grabbing; }
.coord { position: absolute; font-size: 11px; font-weight: 700; pointer-events: none; z-index: 0; }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 4px; }
.sq.light .coord { color: #779556; }
.sq.dark .coord { color: #ebecd0; }
.promo { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(0, 0, 0, .45); }
.promo-box { background: var(--bg); color: var(--text); border-radius: 14px; padding: 14px; text-align: center; }
.promo-box p { margin: 0 0 8px; font-weight: 700; }
.promo-row { display: flex; gap: 6px; }
.promo-row button { width: 64px; height: 64px; position: relative; border: 0; border-radius: 10px; background: #ebecd0; cursor: pointer; }
.promo-row button:hover { background: #f5f682; }
.promo-cancel { margin-top: 8px; border: 0; background: transparent; color: var(--text-sub); cursor: pointer; }

.player-bar { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; }
.player-dot { width: 14px; height: 14px; border-radius: 4px; border: 1px solid #888; flex-shrink: 0; }
.player-dot.w { background: #fff; }
.player-dot.b { background: #222; }
.player-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.taken { display: flex; align-items: center; flex: 1; min-width: 0; overflow: hidden; }
.taken-piece { width: 18px; height: 18px; margin-right: -6px; }
.lead { margin-left: 10px; font-size: 12px; color: var(--text-sub); font-weight: 600; }
.clock { margin-left: auto; padding: 4px 10px; border-radius: 6px; background: var(--bg-soft); font: 700 18px ui-monospace, monospace; min-width: 64px; text-align: right; }
.player-bar.turn .clock { background: #262421; color: #fff; }
.clock.low { color: #ff5c5c !important; }
.chess-status { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--bg-soft); font-weight: 700; font-size: 15px; text-align: center; min-height: 20px; }
.chess-status.mine { background: #81b64c; color: #fff; }
.chess-status.over { background: #262421; color: #fff; }
.moves { list-style: none; counter-reset: move; margin: 0; padding: 6px 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; }
.moves li { counter-increment: move; display: grid; grid-template-columns: 36px 1fr 1fr; padding: 3px 10px; }
.moves li:nth-child(odd) { background: var(--bg-soft); }
.moves li::before { content: counter(move) '.'; color: var(--text-sub); }
.moves:empty::after { content: '아직 둔 수가 없어요'; display: block; padding: 8px 12px; color: var(--text-sub); }
.chess-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chess-actions > * { flex: 1 1 auto; white-space: nowrap; }
.offer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: #fff4d6; color: #6b4e00; font-size: 14px; font-weight: 600; }
.offer[hidden] { display: none; }
.offer span { flex: 1; }
.chess-banner[hidden] { display: none; }

@media (max-width: 900px) {
  .chess-game { flex-direction: column; align-items: center; gap: 10px; padding: 4px 0; }
  .board-col { width: min(100%, 560px); }
  .side-col { width: min(100%, 560px); }
  .moves { max-height: 120px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .offer { background: #3d3212; color: #ffd978; }
}
:root[data-theme="dark"] .offer { background: #3d3212; color: #ffd978; }

/* 이동 단축키 정하기 (처음 유튜브에 들어갈 때) */
.jump-setup .auth { min-height: calc(100vh - var(--topbar-h) - 40px); }
.jump-label { font-size: 14px; font-weight: 700; margin-top: 4px; }
.jump-hint { font-size: 12px; color: var(--text-sub); line-height: 1.5; margin-top: -4px; }
.jump-setup input { height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg); color: inherit; font-size: 15px; }
.jump-setup input:focus { outline: none; border-color: var(--accent); }
.jump-key { height: 52px; border-radius: 14px; border: 1.5px dashed var(--border); background: var(--bg-soft); color: inherit; font: 700 17px ui-monospace, monospace; cursor: pointer; }
.jump-key.recording { border-color: var(--accent); color: var(--accent); }
