:root {
  --bg: #f8f5f0;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --text: #2a2521;
  --muted: #6e655c;
  --line: #e4ddd2;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d8;
  --accent-text: #8f3d1b;
  --free: #2f7a4f;
  --free-bg: #e2f1e7;
  --paid: #8a5a00;
  --paid-bg: #f8ecd2;
  --video: #3c4fb0;
  --video-bg: #e4e8fa;
  --mark: #ffe17a;
  --mark-text: #3a2c00;
  --cur: #fff3d6;
  --cover-l: 86%;
  --stitch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='16'%3E%3Cpath d='M2 2 L9 13 L16 2' fill='none' stroke='black' stroke-opacity='.09' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1917;
    --surface: #252220;
    --surface-2: #2e2a27;
    --text: #ece6de;
    --muted: #a69d93;
    --line: #3a3531;
    --accent: #e0855c;
    --accent-ink: #1b1917;
    --accent-soft: #3d2a20;
    --accent-text: #f0a882;
    --free: #8bd6a8;
    --free-bg: #1f3a2a;
    --paid: #f0c56a;
    --paid-bg: #3d3018;
    --video: #b0bcff;
    --video-bg: #262c4d;
    --mark: #806512;
    --mark-text: #fff3c4;
    --cur: #352c20;
    --cover-l: 30%;
    --stitch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='16'%3E%3Cpath d='M2 2 L9 13 L16 2' fill='none' stroke='white' stroke-opacity='.09' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 16px; font-weight: 600; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px max(16px, calc((100% - 1120px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 19px; text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.top nav { display: flex; gap: 4px; }
.top nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 15px; }
.top nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 120px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; cursor: pointer; font-size: 15px; font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 14px; }

select, input[type="number"], input[type="search"], textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 9px 12px; min-height: 42px;
}
input[type="search"] { width: 100%; font-size: 17px; padding: 12px 16px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--muted);
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* 목록 */
.search { margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.myyarn {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.myyarn label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.myyarn input[type="number"] { width: 90px; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.count { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.card {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--muted); }
.cover {
  position: relative; height: 128px;
  background-color: hsl(var(--h, 30) 38% var(--cover-l));
  background-image: var(--stitch);
}
.cover.big { height: auto; min-height: 220px; border-radius: var(--radius); }
.cover-tag {
  position: absolute; left: 10px; bottom: 10px;
  background: var(--surface); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600;
}
.cover-dur {
  position: absolute; right: 10px; bottom: 10px;
  background: rgb(0 0 0 / 0.65); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px;
}
.card .body { padding: 12px 14px 14px; display: grid; gap: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.b { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.b.free { background: var(--free-bg); color: var(--free); }
.b.paid { background: var(--paid-bg); color: var(--paid); }
.b.video { background: var(--video-bg); color: var(--video); }
.meta { color: var(--muted); font-size: 14px; margin: 0; }
.fit { color: var(--free); font-size: 14px; font-weight: 600; margin: 2px 0 0; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 0; }

/* 상세 */
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 14px; font-size: 15px; }
.detail-head { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 28px; margin-bottom: 24px; }
.detail-head .sub { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
.detail-head .summary { margin: 12px 0 0; font-size: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.kv { width: 100%; border-collapse: collapse; font-size: 15px; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 7px 12px 7px 0; width: 34%; vertical-align: top; }
.kv td { padding: 7px 0; }
.kv tr + tr th, .kv tr + tr td { border-top: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tech { list-style: none; padding: 0; margin: 0; }
.tech li { padding: 9px 0; border-top: 1px solid var(--line); }
.tech li:first-child { border-top: 0; }
.tech .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lv { display: inline-flex; gap: 2px; }
.lv i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.lv i.on { background: var(--accent); }
.tech .abbr { color: var(--muted); font-size: 13px; }
.tech .play { margin-left: auto; }
.player { margin-top: 10px; }
.player iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; }
.player-demo {
  aspect-ratio: 16 / 9; border-radius: 10px; background: #171513; color: #e9e2d8;
  display: grid; place-content: center; text-align: center; gap: 6px; padding: 16px; font-size: 14px;
}
.player-demo strong { font-size: 18px; }
.player-demo code { color: #b9ae9f; font-size: 12px; word-break: break-all; }
.diff-note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.diff-note b { color: var(--text); }
.chapters { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; }
.chapters button { width: 100%; text-align: left; border: 0; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; cursor: pointer; display: flex; gap: 12px; }
.chapters time { color: var(--accent-text); font-variant-numeric: tabular-nums; min-width: 48px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 760px) {
  h1 { font-size: 22px; }
  .detail-head, .cols { grid-template-columns: minmax(0, 1fr); }
  .cover.big { min-height: 160px; }
  .top { gap: 12px; }
  .top nav a { padding: 6px 10px; font-size: 14px; }
}

/* 뷰어 */
.viewer-start {
  display: grid; gap: 14px; justify-items: start;
  background: var(--surface); border: 1px dashed var(--muted); border-radius: var(--radius); padding: 28px;
}
.viewer-start p { margin: 0; color: var(--muted); }
.viewer-start .row { display: flex; flex-wrap: wrap; gap: 8px; }
.viewer-start textarea { width: 100%; min-height: 140px; font-family: inherit; }
.linked { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.linked b { color: var(--text); }
.doc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-head h1 { font-size: 20px; margin-right: auto; }
.sizebar {
  position: sticky; top: 53px; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.sizebar .label { font-size: 14px; color: var(--muted); }
.sizebar .chip { font-size: 15px; padding: 7px 16px; }
.sizebar .spacer { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.notice { background: var(--paid-bg); color: var(--paid); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.textdoc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 0; font-size: 18px; line-height: 1.7;
}
.page-label { font-size: 12px; color: var(--muted); padding: 10px 20px 4px; letter-spacing: 0.04em; }
.ln { padding: 3px 20px 3px 17px; border-left: 3px solid transparent; cursor: pointer; overflow-wrap: anywhere; }
.ln:hover { background: var(--surface-2); }
.ln.blank { cursor: default; min-height: 12px; padding-top: 0; padding-bottom: 0; }
.ln.blank:hover { background: none; }
.ln.cur { background: var(--cur); border-left-color: var(--accent); }
.textdoc.has-cur .ln:not(.cur):not(.blank) { color: color-mix(in srgb, var(--text) 62%, transparent); }
mark.mine { background: var(--mark); color: var(--mark-text); border-radius: 4px; padding: 0 4px; font-weight: 700; }
mark.mine.na { font-weight: 500; font-size: 0.85em; }
.other { color: var(--muted); }
.pdfdoc { display: grid; gap: 16px; }
.pg { position: relative; background: #fff; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); cursor: crosshair; }
.pg canvas { display: block; width: 100%; height: auto; }
.ruler {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: rgb(255 214 64 / 0.32); border-top: 2px solid #e0a400; border-bottom: 2px solid #e0a400;
}
.ruler-ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

/* 영상 같이 보기 */
.doc-body.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.doc-body.split .vpanel { position: sticky; top: 64px; }
.doc-body.video-only .doc-main { display: none; }
.doc-body.video-only .vpanel { max-width: 920px; margin: 0 auto; }
.vpanel { display: grid; gap: 10px; }
.vplayer { aspect-ratio: 16 / 9; background: #171513; border-radius: 12px; overflow: hidden; }
.vplayer iframe { display: block; width: 100% !important; height: 100% !important; border: 0; }
.vplayer .player-demo { aspect-ratio: auto; height: 100%; border-radius: 0; }
.vmore { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 12px; }
.vmore summary { cursor: pointer; padding: 8px 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.vurl { display: flex; gap: 8px; }
.vurl input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; min-height: 40px; }
.vhint { color: var(--paid); font-size: 13px; margin: 6px 0 0; }
.vhint-static { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.vpanel h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.vlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; max-height: 320px; overflow: auto; }
.vlist button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  border: 1px solid transparent; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.vlist button.on { background: var(--accent-soft); border-color: var(--accent); }
.vlist time { color: var(--accent-text); font-variant-numeric: tabular-nums; min-width: 44px; }
.vlist button > span:last-child.muted { margin-left: auto; }
@media (max-width: 900px) {
  .doc-body.split { display: flex; flex-direction: column-reverse; gap: 0; }
  .doc-body.split .vpanel {
    position: sticky; top: 49px; z-index: 15; width: 100%;
    background: var(--bg); padding: 4px 0 8px; gap: 6px;
  }
  .doc-body.split .sizebar { position: static; }
  .doc-body.split .vplayer { border-radius: 10px; }
}

.vbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px max(12px, calc((100% - 1120px) / 2)) calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.vbar .group { display: flex; align-items: center; gap: 6px; }
.vbar .lbl { font-size: 13px; color: var(--muted); }
.vbar .val { font-size: 26px; font-weight: 800; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.vbar .val.sm { font-size: 20px; min-width: 32px; }
.vbar .round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.vbar .plus {
  height: 56px; min-width: 112px; padding: 0 22px; border-radius: 16px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 800; cursor: pointer;
}
.vbar .plus:active { transform: scale(0.97); }
.vbar .sep { width: 1px; height: 36px; background: var(--line); }
.vbar .push { margin-left: auto; }
.wake { font-size: 13px; }
.wake.on { background: var(--free-bg); color: var(--free); border-color: var(--free); }
@media (max-width: 760px) {
  .vbar { gap: 8px; }
  .vbar .sep, .vbar .hide-sm { display: none; }
  .vbar .plus { flex: 1; }
  .textdoc { font-size: 17px; }
  .sizebar { top: 49px; }
}

/* 공통 추가 */
.cover.thumb { background-size: cover; background-position: center; }
.meta.orig, .sub.orig { font-size: 13px; }
abbr.ko { text-decoration: underline dotted color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 4px; cursor: help; }
.btn.big { font-size: 19px; padding: 14px 26px; border-radius: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 15px; max-width: calc(100% - 32px);
}

/* 내 도안함 */
.lib-who { color: var(--muted); margin: 6px 0 16px; font-size: 16px; }
.lib-who b { color: var(--text); }
.lib-list { display: grid; gap: 10px; }
.lib-item {
  display: flex; align-items: center; gap: 14px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.lib-item:hover { border-color: var(--muted); }
.lib-icon { width: 46px; height: 56px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-content: center; font-size: 12px; font-weight: 800; flex: none; }
.lib-text { display: grid; gap: 2px; min-width: 0; flex: 1; font-size: 18px; }
.lib-open { color: var(--accent-text); font-weight: 700; font-size: 17px; flex: none; }
.lib-blocked { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; font-size: 18px; }
.lib-blocked p { margin: 0 0 10px; }

/* 초대 받기 */
.join { max-width: 560px; display: grid; gap: 14px; justify-items: start; padding-top: 40px; }
.join h1 { font-size: 28px; }
.join-big { font-size: 20px; line-height: 1.6; margin: 0; }
.join-tip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; font-size: 16px; }
.join-tip p { margin: 6px 0 0; color: var(--muted); }
.join-err { color: #c0392b; margin: 0; }

/* 관리 */
.admin h2 { font-size: 20px; }
.sub-h { font-size: 15px; margin: 18px 0 8px; }
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 10px 0; }
.row-form label, .collect-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.row-form input:not([type="checkbox"]):not([type="file"]), .collect-form input:not([type="checkbox"]) {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; min-height: 40px; color: var(--text);
}
.collect-form { display: grid; gap: 10px; margin-top: 12px; }
.adm-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.adm-row:first-child { border-top: 0; }
.adm-grow { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.adm-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input.inline { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 6px; font-weight: 600; color: var(--text); }
input.inline:hover, input.inline:focus { border-color: var(--line); background: var(--surface); }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.pill.on { background: var(--free-bg); color: var(--free); }
.pill.off { background: var(--surface-2); color: var(--muted); }
.invite-card { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--radius); padding: 16px; margin: 8px 0; }
.invite-card p { margin: 0 0 6px; }
.qr { width: 150px; background: #fff; border-radius: 8px; padding: 4px; }
.qr svg { width: 100%; height: auto; display: block; }
.link-line code { font-size: 15px; word-break: break-all; }
.collect-card { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.yt-thumb { width: 160px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.techs { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.techs legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.chk { display: inline-flex !important; align-items: center; gap: 4px; font-size: 14px !important; color: var(--text) !important; }
.pdf-list { margin: 10px 0; }
