:root {
  --bg: #f6f5f1;
  --bg-glow: rgb(245 165 36 / 14%);
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #16181d;
  --muted: #6b6f78;
  --faint: #9a9da5;
  --line: #e6e3dc;
  --line-strong: #d6d2c8;
  --brand: #14213d;
  --brand-ink: #ffffff;
  --bar: #14213d;
  --amber: #e8920c;
  --amber-text: #9a5b00;
  --amber-soft: #fdf1dc;
  --danger: #c2321b;
  --danger-soft: #fdebe7;
  --ok: #1f7a5c;
  --shadow: 0 1px 2px rgb(20 24 32 / 5%), 0 10px 30px -12px rgb(20 24 32 / 14%);
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1016;
    --bg-glow: rgb(245 165 36 / 9%);
    --surface: #151a23;
    --surface-2: #121720;
    --ink: #e9eaee;
    --muted: #9298a4;
    --faint: #6b7280;
    --line: #232937;
    --line-strong: #2f3646;
    --brand: #f5a524;
    --brand-ink: #14130f;
    --bar: #7d93bd;
    --amber: #f5a524;
    --amber-text: #f5b84d;
    --amber-soft: #2c2314;
    --danger: #f08a78;
    --danger-soft: #34191a;
    --ok: #5cc9a0;
    --shadow: 0 1px 0 rgb(255 255 255 / 3%) inset, 0 12px 30px -16px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  background: radial-gradient(1100px 420px at 50% -120px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

.shell { max-width: 920px; min-height: 100vh; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; }
main { flex: 1; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { border-radius: 7px; }
.wordmark { font: 700 19px/1 var(--mono); letter-spacing: -0.03em; }
.wordmark span { color: var(--amber); }
.top-right { display: flex; align-items: center; gap: 12px; }
.clock { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 500 13px/1 var(--mono); }
.clock-label { color: var(--faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 0 var(--amber); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(232 146 12 / 45%); } 70% { box-shadow: 0 0 0 7px rgb(232 146 12 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(232 146 12 / 0%); } }

/* controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 18px;
  border: 1px solid var(--brand); border-radius: 11px;
  background: var(--brand); color: var(--brand-ink);
  font: 600 14.5px/1 var(--sans); text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: transform .08s ease, filter .15s ease, background .15s ease, border-color .15s ease;
}
button:hover, .button:hover { filter: brightness(1.12); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; filter: none; }
.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.ghost:hover { filter: none; border-color: var(--muted); }
.small { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.icon-button { width: 42px; padding: 0; background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.icon-button:hover { filter: none; border-color: var(--muted); }
.icon-button.done { color: var(--ok); border-color: var(--ok); }
:focus-visible { outline: 3px solid rgb(232 146 12 / 45%); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lede { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
h1 { margin: 0; font-size: 24px; line-height: 1.25; letter-spacing: -0.025em; }

.error { margin: 12px 0 0; color: var(--danger); font-size: 14px; }
.error:empty { display: none; }
.error.banner { padding: 11px 14px; border-radius: 11px; background: var(--danger-soft); }

/* loading */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 120px 0; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* gate */
.gate { display: flex; justify-content: center; padding: 9vh 0 40px; }
.gate-card {
  width: 100%; max-width: 420px; padding: 36px 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.gate-mark { border-radius: 14px; box-shadow: 0 10px 24px -10px rgb(20 33 61 / 55%); }
.gate h1 { margin-top: 16px; font: 700 26px/1.1 var(--mono); letter-spacing: -0.04em; }
.gate .lede { margin-top: 10px; }
.gate form { margin-top: 24px; }
.field {
  display: flex; gap: 6px; padding: 5px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field:focus-within { border-color: var(--amber); box-shadow: 0 0 0 4px rgb(232 146 12 / 16%); }
.field input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font: 600 18px/1 var(--mono); letter-spacing: .14em;
}
.field input::placeholder { color: var(--faint); font: 500 15px/1 var(--sans); letter-spacing: 0; }
.field button { height: 44px; border-radius: 10px; }
.gate .error { text-align: center; }
.gate-clock { margin: 18px 0 0; color: var(--faint); font-size: 13px; }
.gate-clock time { color: var(--muted); font: 600 13px/1 var(--mono); }

/* list header */
.files-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 18px; }
.files-head button svg { width: 16px; height: 16px; }

.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 22px 0 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stats > div { padding: 14px 18px; min-width: 0; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: 12.5px; }
.stats dd { margin: 3px 0 0; font: 700 19px/1.2 var(--mono); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd.soon { color: var(--amber-text); }
.stats dd.urgent { color: var(--danger); }

/* cards */
.list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.card {
  position: relative;
  display: grid; grid-template-columns: 46px minmax(0, 1fr) 150px 236px; align-items: center; gap: 16px;
  padding: 16px 18px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.new { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.ext {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 12px; font: 700 11px/1 var(--mono); letter-spacing: .02em;
  color: var(--k-ink, #4b5563); background: var(--k-bg, #eef0f3);
}
.ext[data-kind="archive"] { --k-ink: #9a5b00; --k-bg: #fdf1dc; }
.ext[data-kind="doc"]     { --k-ink: #1d4ed8; --k-bg: #e6eefc; }
.ext[data-kind="image"]   { --k-ink: #7c3aed; --k-bg: #f0eafd; }
.ext[data-kind="video"]   { --k-ink: #be185d; --k-bg: #fce7f1; }
.ext[data-kind="audio"]   { --k-ink: #0f766e; --k-bg: #def5f1; }
.ext[data-kind="code"]    { --k-ink: #334155; --k-bg: #e8edf3; }
@media (prefers-color-scheme: dark) {
  .ext { --k-ink: #b6bcc8; --k-bg: #212734; }
  .ext[data-kind="archive"] { --k-ink: #f5b84d; --k-bg: #2c2314; }
  .ext[data-kind="doc"]     { --k-ink: #8fb2ff; --k-bg: #17233b; }
  .ext[data-kind="image"]   { --k-ink: #c4a8ff; --k-bg: #251d3a; }
  .ext[data-kind="video"]   { --k-ink: #f59ac4; --k-bg: #351a28; }
  .ext[data-kind="audio"]   { --k-ink: #6fdcc9; --k-bg: #142d2a; }
  .ext[data-kind="code"]    { --k-ink: #b6c3d4; --k-bg: #1e2633; }
}

.file { min-width: 0; display: grid; gap: 3px; }
.name { font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sep { color: var(--faint); }
.badge { margin-left: 4px; padding: 2px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber-text); font-size: 11.5px; font-weight: 650; }

.time { display: grid; gap: 2px; justify-items: end; text-align: right; }
.left { font: 700 18px/1.2 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.until { color: var(--muted); font-size: 12.5px; }

.actions { display: flex; justify-content: flex-end; gap: 8px; }

.drain {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; overflow: hidden;
  background: var(--line); border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
}
.drain span { display: block; height: 100%; width: 100%; background: var(--bar); transition: width 1s linear, background .3s ease; }

.card.soon .left { color: var(--amber-text); }
.card.soon .drain span { background: var(--amber); }
.card.urgent .left { color: var(--danger); }
.card.urgent .drain span { background: var(--danger); }
.card.expired { opacity: .5; }
.card.expired .get { pointer-events: none; opacity: .5; }

/* empty */
.empty {
  display: grid; justify-items: center; gap: 12px; margin-top: 14px; padding: 48px 20px; text-align: center;
  color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
}
.empty img { opacity: .55; border-radius: 10px; filter: grayscale(1); }
.empty p { margin: 0; }
.empty strong { color: var(--ink); }

/* copy menu */
.copy-menu { position: relative; }
.copy-menu > summary { list-style: none; }
.copy-menu > summary::-webkit-details-marker { display: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; height: 42px; border: 1px solid var(--line-strong); border-radius: 11px; cursor: pointer; }
.copy-menu[open] > summary { border-color: var(--muted); }
.menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: 260px; padding: 6px;
  display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 18px 40px -12px rgb(16 24 32 / 30%);
}
.menu button {
  width: 100%; height: auto; display: grid; justify-content: start; justify-items: start; gap: 2px; padding: 9px 11px; text-align: left;
  background: transparent; color: var(--ink); border: 0; border-radius: 8px; font-weight: 600;
}
.menu button:hover { filter: none; background: var(--surface-2); }
.menu button small { color: var(--muted); font-size: 12px; font-weight: 400; }
.menu button.done strong { color: var(--ok); }

/* viewer */
body.viewing .shell { max-width: 1280px; }
.viewer { padding-top: 10px; }
.viewer-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.viewer-bar .back svg, .viewer-actions svg { width: 16px; height: 16px; }
.viewer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.viewer-title .ext { width: 38px; height: 38px; border-radius: 10px; font-size: 10px; }
.viewer-title .left { font: 600 13px/1 var(--mono); color: var(--ink); }
.viewer-title .meta { flex-wrap: wrap; white-space: normal; row-gap: 2px; }
.viewer-title .left.soon { color: var(--amber-text); }
.viewer-title .left.urgent, .viewer-title .left.expired { color: var(--danger); }
.viewer-actions { display: flex; gap: 8px; }
.viewer-actions .button { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.viewer .error.banner { margin-top: 12px; }

.tabs { display: inline-flex; gap: 2px; margin-top: 14px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.tabs button { height: 32px; padding: 0 14px; background: transparent; color: var(--muted); border: 0; border-radius: 8px; font-size: 13.5px; }
.tabs button:hover { filter: none; color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }

.viewer-body { margin-top: 14px; }
.viewer-body > iframe {
  display: block; width: 100%; height: calc(100vh - 190px); min-height: 420px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.viewer-notice { padding: 40px 20px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }
.viewer-body > div > .viewer-notice { margin-bottom: 12px; padding: 14px; }

.stage {
  display: grid; place-items: center; min-height: 320px; padding: 20px; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--surface);
  background-image: linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%),
                    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
.stage img { max-width: 100%; max-height: calc(100vh - 230px); cursor: zoom-in; box-shadow: var(--shadow); }
.stage.actual { place-items: start; }
.stage.actual img { max-width: none; max-height: none; cursor: zoom-out; }
.stage.media video { max-width: 100%; max-height: calc(100vh - 230px); border-radius: 10px; background: #000; }
.stage.media audio { width: min(560px, 100%); }

.lines, .json, .md-code, .csv {
  margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.lines, .json {
  padding: 14px 0; overflow: auto; max-height: calc(100vh - 230px);
  font: 13px/1.6 var(--mono); tab-size: 4;
}
.json { padding: 16px 20px; white-space: pre; }
.lines { counter-reset: ln; }
.lines span { display: block; padding: 0 18px 0 0; white-space: pre; }
.lines span::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 4.2em; margin-right: 14px; padding-right: 10px;
  color: var(--faint); text-align: right; border-right: 1px solid var(--line); user-select: none;
}
.j-key { color: #1d4ed8; }
.j-str { color: #15803d; }
.j-num { color: #b45309; }
.j-bool, .j-null { color: #7c3aed; }
@media (prefers-color-scheme: dark) {
  .j-key { color: #8fb2ff; }
  .j-str { color: #7fd8a4; }
  .j-num { color: #f5b84d; }
  .j-bool, .j-null { color: #c4a8ff; }
}

.csv { overflow: auto; max-height: calc(100vh - 230px); }
.csv table { border-collapse: collapse; font-size: 13px; }
.csv th, .csv td { padding: 7px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; text-align: left; vertical-align: top; }
.csv thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 650; }
.csv .rn { color: var(--faint); font: 12px/1.6 var(--mono); text-align: right; background: var(--surface-2); }

.markdown {
  max-width: 820px; margin: 0 auto; padding: 36px 44px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 15.5px; line-height: 1.75; overflow-wrap: anywhere;
}
.markdown > :first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 1.6em 0 .6em; line-height: 1.3; letter-spacing: -0.02em; }
.markdown h1 { font-size: 1.9em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.markdown h2 { font-size: 1.45em; padding-bottom: .25em; border-bottom: 1px solid var(--line); }
.markdown h3 { font-size: 1.2em; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown .md-table, .markdown pre { margin: 0 0 1em; }
.markdown p { white-space: pre-line; }
.markdown ul, .markdown ol { padding-left: 1.6em; }
.markdown li + li { margin-top: .25em; }
.markdown li.task { list-style: none; margin-left: -1.3em; }
.markdown li.task input { margin: 0 .4em 0 0; vertical-align: -1px; }
.markdown a { color: #1d4ed8; }
.markdown blockquote { padding: .2em 1em; color: var(--muted); border-left: 4px solid var(--line-strong); }
.markdown code { padding: .15em .4em; font: .88em/1.4 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; }
.markdown .md-code { padding: 14px 16px; overflow: auto; box-shadow: none; background: var(--surface-2); tab-size: 4; }
.markdown .md-code code { padding: 0; border: 0; background: none; font-size: 13px; line-height: 1.6; }
.markdown img { max-width: 100%; border-radius: 8px; }
.markdown hr { margin: 2em 0; border: 0; border-top: 1px solid var(--line); }
.markdown .md-table { overflow: auto; }
.markdown table { border-collapse: collapse; font-size: .94em; }
.markdown th, .markdown td { padding: 7px 12px; border: 1px solid var(--line); }
.markdown th { background: var(--surface-2); }
.markdown .al-center { text-align: center; }
.markdown .al-right { text-align: right; }
@media (prefers-color-scheme: dark) { .markdown a { color: #8fb2ff; } }

@media (max-width: 860px) {
  .viewer-bar { grid-template-columns: auto minmax(0, 1fr); }
  .viewer-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .viewer-actions > * { flex: 1; }
  .markdown { padding: 24px 20px; }
}

.foot { padding: 36px 0 28px; color: var(--faint); font-size: 12.5px; text-align: center; }

@media (max-width: 720px) {
  .card { grid-template-columns: 42px minmax(0, 1fr); gap: 12px 14px; padding: 14px 14px 17px; }
  .ext { width: 42px; height: 42px; }
  .time { grid-column: 1 / -1; grid-template-columns: auto 1fr; align-items: baseline; justify-items: start; gap: 10px; text-align: left; }
  .actions { grid-column: 1 / -1; }
  .actions .get, .actions .view { flex: 1; }
  .stats > div { padding: 12px 12px; }
  .stats dd { font-size: 16px; }
  .clock-label { display: none; }
}

@media (max-width: 420px) {
  .shell { padding: 0 16px; }
  .gate { padding-top: 5vh; }
  .gate-card { padding: 28px 20px 22px; border-radius: 18px; }
  .files-head { align-items: flex-start; }
  h1 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
