:root {
  --bg: #f6f6f8; --surface: #fff; --text: #1b1b1f; --muted: #6b6b76; --line: #e3e3e8;
  --accent: #fe2c55; --accent-ink: #fff; --info: #eef4ff; --warn: #fff6e0; --error: #ffecec;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111114; --surface: #1c1c21; --text: #ececf1; --muted: #9a9aa6; --line: #2e2e36;
          --info: #1b2433; --warn: #2e2716; --error: #331a1d; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 12px; } h2 small { color: var(--muted); font-weight: normal; font-size: 13px; margin-left: 6px; }
input, select, button { font: inherit; color: inherit; }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input.small { padding: 4px 8px; width: 140px; }
button, .btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: #c0392b; }
.btn.on { border-color: var(--accent); color: var(--accent); }
button.link { background: none; border: none; padding: 0; color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; }
.inline { display: inline; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--accent); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.topbar nav a.on { background: var(--bg); font-weight: 600; }
.me { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.me form { display: inline; }
.budget { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel.narrow { max-width: 480px; }
.cols { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input[name=keyword], .row input[name=link] { flex: 1 1 260px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label, .login label { display: flex; flex-direction: column; gap: 4px; }
label.check { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; }
.fetch-form { display: flex; flex-direction: column; gap: 10px; }
.fetch-form > button { align-self: flex-start; }
.tabs { display: flex; gap: 16px; }

.msg { padding: 10px 12px; border-radius: 8px; margin: 10px 0 0; }
.msg.info { background: var(--info); } .msg.warn { background: var(--warn); } .msg.error { background: var(--error); }
.msg.inline { display: inline-block; padding: 2px 8px; margin: 0; font-size: 13px; }
.msg .btn { margin-left: 8px; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters input[name=q] { flex: 1 1 220px; }
.context { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .1s; }
.card:hover, .card:focus { transform: translateY(-2px); outline: 2px solid var(--accent); }
.thumb { position: relative; aspect-ratio: 3 / 4; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.badge.saved { left: 6px; right: auto; background: var(--accent); }
.meta { padding: 8px 10px; }
.meta p { margin: 0 0 4px; }
.desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; }
.stats { font-size: 13px; }
.more { grid-column: 1 / -1; justify-self: center; }

dialog#modal { width: min(1100px, 96vw); max-height: 94vh; border: none; border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); }
dialog#modal::backdrop { background: rgba(0,0,0,.6); }
.close { position: absolute; right: 10px; top: 10px; z-index: 2; border-radius: 50%; width: 34px; height: 34px; padding: 0; }
.video-view { display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
@media (max-width: 800px) { .video-view { grid-template-columns: 1fr; } }
.player { background: #000; display: flex; flex-direction: column; justify-content: center; min-height: 300px; }
.player video { width: 100%; max-height: 80vh; background: #000; }
.player .quality, .player .hint { color: #ccc; padding: 6px 10px; font-size: 13px; }
.player .quality .btn { background: #222; color: #ddd; border-color: #444; }
.player .quality .btn.on { border-color: var(--accent); color: #fff; }
.player .msg { margin: 10px; color: var(--text); }
.images { display: flex; overflow-x: auto; gap: 4px; max-height: 80vh; }
.images img { max-height: 80vh; }
.info { padding: 20px 18px; overflow-y: auto; max-height: 90vh; }
.author { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.desc-ko { white-space: pre-wrap; }
.desc-zh { white-space: pre-wrap; color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; margin: 6px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.tags a { color: var(--accent); text-decoration: none; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; }

table.list, table.mini { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th, table.list td, table.mini th, table.mini td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
table.mini td, table.mini th { padding: 4px 6px; font-size: 13px; }
.actions-cell form { margin: 2px 0; }
.thumb-s { width: 56px; cursor: pointer; } .thumb-s img { width: 48px; height: 64px; object-fit: cover; border-radius: 4px; }
.meter { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.meter div { height: 100%; background: var(--accent); } .meter div.warn { background: #e67e22; }

.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; background: var(--surface); padding: 28px; border-radius: 14px; border: 1px solid var(--line); }
.login h1 { color: var(--accent); text-align: center; }
