:root {
  --bg: #f5f5f7; --card: #fff; --fg: #1d1d1f; --muted: #6e6e73; --faint: #86868b;
  --line: rgba(0, 0, 0, .08); --fill: rgba(118, 118, 128, .12);
  --accent: #0071e3; --accent-hover: #0077ed; --danger: #ff3b30; --ok: #34c759;
  --bar: rgba(251, 251, 253, .78); --shadow: 0 2px 6px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.06);
  --page-shadow: 0 1px 3px rgba(0,0,0,.08), 0 10px 40px rgba(0,0,0,.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --card: #1c1c1e; --fg: #f5f5f7; --muted: #a1a1a6; --faint: #8e8e93;
    --line: rgba(255, 255, 255, .1); --fill: rgba(118, 118, 128, .24);
    --accent: #0a84ff; --accent-hover: #409cff; --danger: #ff453a; --ok: #30d158;
    --bar: rgba(22, 22, 23, .78); --shadow: 0 0 0 1px rgba(255,255,255,.06);
    --page-shadow: 0 0 0 1px rgba(255,255,255,.08);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  letter-spacing: -0.022em; -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); font-size: 14px; letter-spacing: -0.01em; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 12px 0 0; }

/* ---------- 버튼 · 입력 ---------- */
button, .btn {
  font: inherit; font-size: 15px; font-weight: 500; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 18px; border: 0; border-radius: 980px;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
  transition: background .2s, transform .1s, opacity .2s;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .4; pointer-events: none; }
button:focus-visible, .btn:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.plain { background: var(--fill); color: var(--fg); }
.plain:hover { background: color-mix(in srgb, var(--fill) 100%, var(--fg) 6%); }
.icon-btn { width: 36px; padding: 0; background: transparent; color: var(--accent); }
.icon-btn:hover { background: var(--fill); }
.icon-btn.danger { color: var(--danger); }
.danger-fill { background: var(--danger); }
.danger-fill:hover { background: var(--danger); opacity: .88; }
input[type=text], input[type=password] {
  font: inherit; width: 100%; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg); transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }
input::placeholder { color: var(--faint); }

/* ---------- 상단 바 (반투명) ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 52px; padding: 0 max(16px, calc((100% - 948px) / 2));
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.bar form { margin: 0; }
.brand { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #0a84ff, #5e5ce6); display: grid; place-items: center; color: #fff; }
.brand-mark svg { width: 14px; height: 14px; stroke-width: 2.4; }
.link-btn { background: transparent; color: var(--accent); padding: 0 4px; min-height: 32px; font-size: 14px; }
.link-btn:hover { background: transparent; text-decoration: underline; }

/* ---------- 잠금 · 로그인 ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--card); border-radius: 28px; padding: 48px 32px 36px; box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
.gate-icon {
  width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--fill); color: var(--fg);
}
.gate-icon svg { width: 28px; height: 28px; stroke-width: 1.6; }
.gate h1 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 8px; overflow-wrap: anywhere; }
.gate .sub { color: var(--muted); font-size: 15px; margin: 0 0 28px; }
.gate .btn { margin-top: 8px; }
.field-go { position: relative; }
.field-go input { padding-right: 52px; height: 52px; border-radius: 14px; font-size: 17px; }
.field-go button { position: absolute; right: 8px; top: 8px; width: 36px; min-height: 36px; padding: 0; }
.field-go button svg { width: 18px; height: 18px; stroke-width: 2.2; }
.shake { animation: shake .4s; }

/* ---------- 관리 페이지 ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 48px 16px 96px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.hero h1 { font-size: clamp(32px, 6vw, 48px); line-height: 1.08; font-weight: 700; letter-spacing: -0.035em; margin: 0; }
.hero p { margin: 6px 0 0; color: var(--muted); font-size: 17px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  padding: 36px 20px; margin-bottom: 40px; border-radius: 22px; cursor: pointer;
  background: var(--card); border: 1.5px dashed color-mix(in srgb, var(--faint) 50%, transparent);
  transition: border-color .2s, background .2s, transform .2s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.drop.over { transform: scale(1.01); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { border-color: var(--accent); }
.drop-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); margin-bottom: 6px; }
.drop-icon svg { width: 24px; height: 24px; }
.drop strong { font-size: 17px; font-weight: 600; }
.drop .muted { font-size: 13px; }
.drop .choose { color: var(--accent); }
.progress { width: min(320px, 100%); height: 4px; border-radius: 4px; background: var(--fill); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .2s; }
.progress.indeterminate i { width: 30%; animation: slide 1.1s ease-in-out infinite; }

.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin: 0 0 10px 20px; }
.files { display: grid; gap: 16px; }
.file { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.file-head { display: flex; align-items: center; gap: 14px; padding: 18px 16px 18px 20px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; align-items: center; gap: 4px; }

.badge { flex: none; display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 6px; border-radius: 12px; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: #fff; }
.viewer-bar .badge { min-width: 0; height: 22px; border-radius: 6px; font-size: 10px; padding: 0 6px; }
.t-pdf { background: linear-gradient(160deg, #ff6259, #e5352b); }
.t-xls { background: linear-gradient(160deg, #3ad16b, #1fa64a); }
.t-ppt { background: linear-gradient(160deg, #ffac40, #f07f12); }
.t-hwp { background: linear-gradient(160deg, #4aa3ff, #0a6fe0); }

.shares { border-top: 1px solid var(--line); }
.share { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 20px; min-height: 56px; }
.share + .share { border-top: 1px solid var(--line); margin-left: 20px; padding-left: 0; }
.share-url { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-url b { font-weight: 500; }
.share-url span { color: var(--faint); }
.pill { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 500; background: var(--fill); color: var(--muted); }
.pill svg { width: 12px; height: 12px; stroke-width: 2.2; }
.pill.locked { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.no-share { padding: 14px 20px; color: var(--faint); font-size: 14px; border-top: 1px solid var(--line); }

.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; stroke-width: 1.2; color: var(--faint); margin-bottom: 10px; }

@media (max-width: 600px) {
  .wrap { padding-top: 32px; }
  .file-head { flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-end; }
  .share { flex-wrap: wrap; row-gap: 4px; }
  .share-url { flex-basis: 100%; }
  .share .pill { margin-right: auto; }
}

/* ---------- 시트 (다이얼로그) ---------- */
dialog {
  width: min(400px, calc(100% - 32px)); padding: 28px 24px 20px; border: 0; border-radius: 22px;
  background: var(--card); color: var(--fg); box-shadow: 0 24px 80px rgba(0,0,0,.25);
}
dialog[open] { animation: pop .28s cubic-bezier(.2, .9, .3, 1.2); }
dialog::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; text-align: center; letter-spacing: -0.025em; }
dialog p { margin: 0 0 18px; color: var(--muted); font-size: 14px; text-align: center; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }
.prefix-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding-left: 14px; }
.prefix-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.prefix-field span { color: var(--faint); font-size: 15px; white-space: nowrap; }
.prefix-field input { border: 0; background: transparent; padding-left: 2px; box-shadow: none !important; }
dialog input[type=text], dialog input[type=password] { background: var(--bg); }
.link-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--bg); }
.link-box code { flex: 1; min-width: 0; font-family: inherit; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.dlg-actions { display: flex; gap: 10px; margin-top: 22px; }
.dlg-actions button { flex: 1; min-height: 44px; font-size: 16px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 50; transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 980px;
  background: color-mix(in srgb, var(--fg) 88%, transparent); color: var(--bg); font-size: 15px; font-weight: 500;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); pointer-events: none;
  transition: opacity .25s, transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: var(--ok); stroke-width: 2.4; }

/* ---------- 뷰어 ---------- */
.viewer-bar .title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.viewer-bar strong { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .muted { flex: none; font-size: 13px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 32px 16px 80px; }
.pages canvas { width: 100%; max-width: 920px; height: auto; background: #fff; border-radius: 4px; box-shadow: var(--page-shadow); animation: fade .4s both; }
.loading { display: flex; align-items: center; gap: 10px; padding: 80px 0; color: var(--muted); font-size: 15px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--muted); animation: spin .8s linear infinite; }
.doc { display: block; width: 100%; height: calc(100vh - 52px); height: calc(100dvh - 52px); border: 0; background: var(--bg); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(330%); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.viewer-bar .dl { flex: none; min-height: 30px; padding: 0 12px 0 10px; font-size: 13px; gap: 4px; }
.viewer-bar .dl svg { width: 16px; height: 16px; stroke-width: 2; }
@media (max-width: 600px) { .viewer-bar .dl { width: 30px; padding: 0; font-size: 0; gap: 0; } }
