@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --line: #e3e1db;
  --text: #1d1d1b;
  --muted: #6f6d66;
  --accent: #9a7a2e;
  --accent-ink: #ffffff;
  --accent-soft: #f4ecd9;
  --sel: #f7f0de;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok: #2e7d4f;
  --ok-soft: #e4f3ea;
  --shadow: 0 10px 30px rgba(20, 18, 10, .12);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1b1b19;
    --surface-2: #242421;
    --line: #33322e;
    --text: #ecebe6;
    --muted: #9c9a92;
    --accent: #d2ad5b;
    --accent-ink: #1a1508;
    --accent-soft: #3a3120;
    --sel: #2c2718;
    --danger: #f08a80;
    --danger-soft: #3a1f1c;
    --ok: #7cc79a;
    --ok-soft: #1d3326;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }
.right { text-align: right; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 버튼 · 입력 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s;
}
label.btn { margin: 0; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: transparent; color: inherit; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

label { display: block; font-size: 14px; font-weight: 500; margin: 0 0 14px; }
label > input, label > select, label > textarea, .search {
  display: block; width: 100%; margin-top: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
label > textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-size: 14px; font-weight: 500; padding: 0 4px; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
input[readonly] { background: var(--surface-2); }

.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.banner { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.tag.on { background: var(--ok-soft); color: var(--ok); }
.tag.off { background: var(--danger-soft); color: var(--danger); }

/* ---------- 로그인 · 외부 업로드 ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card.wide { max-width: 620px; }
.auth-card h1 { margin: 18px 0 8px; }
.auth-card .muted { margin: 0 0 18px; font-size: 14px; }
.auth-card .brand { font-size: 15px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #1d1d1b; color: #d2ad5b; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
@media (prefers-color-scheme: dark) { .brand-mark { background: #d2ad5b; color: #1a1508; } }

.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 32px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); transition: .15s;
}
.dropzone svg { width: 40px; height: 40px; color: var(--accent); }
.dropzone strong { color: var(--text); font-weight: 600; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.uplist { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.upitem { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.upname { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upmeta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.upitem.done .upstat { color: var(--ok); font-weight: 600; }
.upitem.error .upstat, .upmsg { color: var(--danger); }
.upitem.done .upmsg { color: var(--muted); }
.upmsg { font-size: 12px; margin-top: 4px; }
.bar { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.upitem.done .bar i { background: var(--ok); }
.upitem.error .bar i { background: var(--danger); }

/* ---------- 앱 레이아웃 ---------- */
body.app { --top: 56px; --side: 232px; }
.top {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top form { margin: 0; }
.spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 14px; padding: 4px 8px 4px 4px; border-radius: 99px; }
.user-chip:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }

.side {
  position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); z-index: 20; padding: 16px 10px;
  background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.side-label { font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 10px 6px; }
.side-label:first-child { padding-top: 0; }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.side a:hover { background: var(--surface-2); }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--muted); }
.scrim { display: none; }

.main { margin: var(--top) 0 0 var(--side); padding: 22px 28px 80px; max-width: calc(1180px + var(--side)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; min-height: 36px; }
.lead { margin: -4px 0 18px; max-width: 70ch; font-size: 14px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.crumbs a { text-decoration: none; padding: 2px 4px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); }
.crumbs a:last-child { color: var(--text); }
.crumbs a:not(:last-child) { color: var(--muted); font-weight: 500; }
.crumbs .sep { color: var(--line); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tb-main, .tb-sel { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tb-sel { padding-left: 10px; border-left: 1px solid var(--line); }
.sel-count { font-size: 14px; font-weight: 600; color: var(--accent); margin-right: 2px; }
.toolbar .search { width: 220px; margin: 0 0 0 auto; height: 36px; }
.page-head .search { width: 280px; margin: 0; height: 36px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); user-select: none; white-space: nowrap; }
.files th[data-sort] { cursor: pointer; }
.files th.sorted { color: var(--text); }
.files th.sorted::after { content: " ↑"; }
.files th.sorted.desc::after { content: " ↓"; }
.files td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files tbody tr:hover { background: var(--surface-2); }
.files tbody tr.sel { background: var(--sel); }
.files tr.dim td { opacity: .55; }
.files .ck { width: 42px; text-align: center; }
.files .num { text-align: right; width: 100px; white-space: nowrap; color: var(--muted); }
.files .date { width: 150px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.files .wrap { word-break: break-all; }
.files td.name a, .files td.name .nm { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; max-width: 100%; }
.files td.name a:hover span { text-decoration: underline; }
.files td.name span { overflow-wrap: anywhere; }
.m-meta { display: none; }
.files .empty, .files .loading { text-align: center; padding: 48px 12px; color: var(--muted); }
.files.logs td { font-size: 13px; }
.ic { width: 22px; height: 22px; }
.ic.folder { color: var(--accent); fill: var(--accent-soft); }
.ic.img { color: #4b7bb8; } .ic.doc { color: #5b6b7d; } .ic.zip { color: #8a6b3f; } .ic.media { color: #8c4f9a; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h3 { margin-right: auto; }
.linkbox { display: flex; gap: 6px; }
.linkbox input { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; font: 13px ui-monospace, Menlo, monospace; background: var(--surface-2); color: var(--text); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; }
.card-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.card .note { margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel.narrow { max-width: 440px; }

/* ---------- 업로드 패널 · 끌어놓기 ---------- */
.uppanel {
  position: fixed; right: 16px; bottom: 16px; width: 360px; max-height: 60vh; z-index: 40; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.uppanel header { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.uppanel header strong { flex: 1; font-size: 14px; }
.uppanel .uplist { margin: 0; padding: 10px; overflow-y: auto; }
.uppanel.min .uplist { display: none; }
.uppanel.min #upToggle svg { transform: rotate(180deg); }
.dropveil {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 16%, transparent); border: 3px dashed var(--accent);
}
.dropveil.over { display: grid; }
.dropveil div { background: var(--surface); padding: 14px 22px; border-radius: 10px; box-shadow: var(--shadow); font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60;
  background: #1d1d1b; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; transition: .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #fff; }

/* ---------- 대화상자 ---------- */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(440px, calc(100vw - 32px)); }
dialog.wide { width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dlg { padding: 22px 22px 18px; margin: 0; }
.dlg-body p { margin: 0 0 8px; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dlg-err { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 14px; margin-top: 4px; }
.picker-roots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.picker-crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; word-break: break-all; }
.picker-list { border: 1px solid var(--line); border-radius: 8px; height: 260px; overflow-y: auto; }
.pk-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.pk-row:hover { background: var(--surface-2); }
.pk-row:disabled { opacity: .4; cursor: default; }
.pad { padding: 14px; }

.only-mobile { display: none !important; }

/* ---------- 휴대폰 ---------- */
@media (max-width: 820px) {
  body.app { --side: 260px; }
  .only-mobile { display: inline-grid !important; }
  span.only-mobile { display: inline !important; }
  .hide-mobile { display: none !important; }
  .side { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 15; }
  .main { margin-left: 0; padding: 16px 16px 90px; }
  .top { padding: 0 8px 0 4px; }
  .crumbs { font-size: 17px; }
  .toolbar .search, .page-head .search { width: 100%; margin: 0; order: -1; }
  .tb-sel { padding-left: 0; border-left: 0; width: 100%; }
  .tb-main .btn, .tb-sel .btn { padding: 0 11px; }
  .files th.num, .files th.date, .files td.num, .files td.date { display: none; }
  .files thead th:nth-child(3), .files tbody td:nth-child(3) { display: none; }
  .files td.name .m-meta { display: block; font-size: 12px; color: var(--muted); margin: 2px 0 0 32px; }
  .files td.name a, .files td.name .nm { display: flex; }
  .files.logs th, .files.logs td { display: table-cell !important; }
  .table-wrap { overflow-x: auto; }
  .cards { grid-template-columns: 1fr; }
  .uppanel { left: 8px; right: 8px; bottom: 8px; width: auto; }
}

/* ---------- 외부 회원 (가입 · 업로드 전용 화면) ---------- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.drop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drop-head form { margin: 0; }
.sent-title { margin: 28px 0 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bar.quota { margin-bottom: 10px; }
.sent { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 320px; overflow-y: auto; }
.sent li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sent li:last-child { border-bottom: 0; }
.sent .nm { overflow-wrap: anywhere; }
.sent .small { white-space: nowrap; }
.pwbox { margin-top: 20px; font-size: 14px; }
.pwbox summary { cursor: pointer; color: var(--muted); }
.pwbox form { margin-top: 12px; }
.auth-card .note.small { margin: 4px 0 12px; line-height: 1.6; }
@media (max-width: 520px) { .sent li { flex-direction: column; gap: 2px; } }

/* ---------- 입구 · 관리자 ---------- */
.auth-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 14px; }
.auth-links a { color: var(--accent); }
.side-label:empty { display: none; }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag.site { background: #e3ecf8; color: #2f5b93; }
.tag.ext { background: var(--surface-2); color: var(--muted); }
.tag.warn { background: #fdf0d8; color: #8a5a00; }
@media (prefers-color-scheme: dark) {
  .tag.site { background: #1f2d40; color: #9cc2f0; }
  .tag.warn { background: #3a2e14; color: #e8c170; }
}
.pending { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.pending h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pending .count { background: var(--danger); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 8px; }
.pend-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.pend-info { min-width: 0; }
.pend-info div { margin-top: 2px; }
.pend-act { display: flex; gap: 6px; flex: none; }
.files.users tbody tr { cursor: pointer; }
.user-facts { margin-bottom: 12px; }
.user-facts .wide { grid-column: 1 / -1; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
table.mini th, table.mini td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.mini tr.warn td { color: var(--danger); }
#ipBox { max-height: 220px; overflow: auto; }
.files.logs td a { color: inherit; }
@media (max-width: 820px) {
  .pend-row { flex-direction: column; align-items: flex-start; }
  .files.users th, .files.users td { display: table-cell !important; }
}
.tag { white-space: nowrap; }

/* ---------- 관리자 현황 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.stat span { font-size: 13px; color: var(--muted); }
.stat b { font-size: 26px; font-variant-numeric: tabular-nums; }
.stat.warn { border-color: var(--danger); }
.stat.warn b { color: var(--danger); }
.stat:hover { background: var(--surface-2); }
.areas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.area { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.area h2 { font-size: 15px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.area h2 a { color: var(--accent); font-weight: 500; }
.area-links { display: flex; flex-direction: column; gap: 4px; }
.area-links a { padding: 8px 10px; border-radius: 8px; text-decoration: none; background: var(--surface-2); display: flex; justify-content: space-between; }
.area-links a:hover { background: var(--accent-soft); }
.area p { margin: 0; }
.area .table-wrap { border: 0; }
@media (max-width: 820px) { .areas { grid-template-columns: 1fr; } }

/* 2026-09-25: 줄마다 다운로드·삭제 버튼, 상위 폴더 줄 */
table.files th.act, table.files td.act { width: 1%; white-space: nowrap; text-align: right; }
table.files td.act .btn { margin-left: 6px; }
table.files tr.up-row td.name a { color: var(--muted, #9a9a9a); }
