:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #c0352b;
  --danger-bg: #fdecea;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --text: #e6e8ec;
    --muted: #9aa2b1;
    --border: #2e333c;
    --accent: #5b8cff;
    --accent-text: #0b0d10;
    --danger: #ff7b72;
    --danger-bg: #3a1d1b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans CJK JP", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topnav { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card.narrow { max-width: 440px; margin: 2rem auto; }
.muted { color: var(--muted); font-size: .9rem; }
.alert { background: var(--danger-bg); color: var(--danger); padding: .5rem .75rem; border-radius: 6px; }

.stack { display: flex; flex-direction: column; gap: .5rem; }
.inline { display: inline; margin: 0; }
input[type=email], input[type=text], input[type=search] {
  font: inherit; color: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
button { font: inherit; cursor: pointer; }
button.primary {
  padding: .6rem 1rem;
  border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600;
}
button.link { border: 0; background: none; color: var(--accent); padding: 0; }

.footer { padding: 1rem; text-align: center; font-size: .85rem; color: var(--muted); }
.langs { display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem 1rem; }
.langs strong { color: var(--text); font-weight: 600; }
.debug { white-space: pre-wrap; font-size: .75rem; overflow: auto; max-height: 50vh; }

h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
.card + .card { margin-top: 1rem; }
.card h2:first-child { margin-top: 0; }
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--accent); }
.notice { background: color-mix(in srgb, var(--accent) 12%, transparent); padding: .6rem .8rem; border-radius: 8px; }
.notice p { margin: .25rem 0; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.row input:not([type=checkbox]):not([type=radio]) { flex: 1 1 14rem; min-width: 0; }
button {
  padding: .55rem .9rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
button.primary { border-color: transparent; }
button.danger, button.link.danger { color: var(--danger); }
button:disabled { opacity: .6; cursor: default; }
select {
  font: inherit; color: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
}
.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; margin: .5rem 0; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); }
table.list th, table.list td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list td.actions form + form { margin-left: .75rem; }
tr.disabled td { opacity: .5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- files */
.linklike { color: var(--accent); cursor: pointer; text-decoration: underline; }
.files-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.files-head h1 { margin: 0; }
.usage { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--muted); }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 120px; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.warn > span { background: var(--danger); }
.dropzone {
  margin-top: 1rem; padding: 1.75rem 1rem; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted);
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dropzone p { margin: 0; }
.queue { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.queue li { padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; }
.queue .q-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.queue .q-row + .bar, .queue .q-row + .q-row { margin-top: .35rem; }
.queue .q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .q-row a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue li.ok .bar > span { background: #2f9e44; }
.queue li.failed { border-color: var(--danger); }
.queue li.failed .q-status { color: var(--danger); }
.toolbar input[type=search] { flex: 1 1 12rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: .5rem .75rem; color: var(--text); text-decoration: none; font-size: .9rem; }
.seg a[aria-current] { background: var(--accent); color: var(--accent-text); }
.bulkbar { justify-content: space-between; }
.bulkbar .check { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; }
.empty { text-align: center; padding: 1.5rem 0; }
table.files td.c-check, table.files th.c-check { width: 2rem; }
table.files .c-size, table.files .c-date { white-space: nowrap; color: var(--muted); }
table.files .c-name { overflow-wrap: anywhere; }
table.files .c-name a { color: var(--text); text-decoration: none; }
table.files .c-name a:hover { color: var(--accent); }
.file-actions { display: inline-flex; flex-wrap: wrap; gap: .25rem .75rem; justify-content: flex-end; font-size: .85rem; }
.file-actions a { text-decoration: none; }
.badge {
  display: inline-block; min-width: 2.6rem; margin-right: .4rem; padding: .05rem .3rem;
  border-radius: 4px; font-size: .7rem; font-weight: 700; text-align: center; vertical-align: 1px;
  background: var(--border); color: var(--muted);
}
.kind-image { --kind: #2f9e44; } .kind-video { --kind: #d6336c; } .kind-audio { --kind: #ae3ec9; }
.kind-text, .kind-markdown { --kind: #1c7ed6; } .kind-pdf { --kind: #e8590c; }
.badge[class*="kind-"]:not(.kind-other) { background: color-mix(in srgb, var(--kind) 18%, transparent); color: var(--kind); }
.grid { list-style: none; margin: .5rem 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.tile { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.tile .thumb {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3;
  border-radius: 6px; background: var(--bg); text-decoration: none; overflow: hidden;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile .thumb .ext { font-weight: 700; color: var(--kind, var(--muted)); }
.tile-check { position: absolute; top: .6rem; left: .6rem; }
.tile-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: .75rem; }
.tile .file-actions { justify-content: flex-start; font-size: .75rem; }
.pager { display: flex; justify-content: center; gap: 1rem; margin-top: .75rem; }
@media (max-width: 640px) {
  table.files .c-date { display: none; }
  .topnav .who { display: none; }
}

/* ---- link buttons, list thumbnails */
a.button {
  display: inline-block; padding: .55rem .9rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
img.mini { width: 2.6rem; height: 1.8rem; object-fit: cover; border-radius: 4px; margin-right: .4rem; vertical-align: middle; background: var(--bg); }
.small { font-size: .8rem; }

/* ---- share page */
body.share { background: var(--bg); }
.share-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.share-title { min-width: 0; flex: 1 1 18rem; }
.share-title h1 { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-title p { margin: 0; font-size: .85rem; }
.share-actions { display: flex; gap: .5rem; }
.share-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; gap: .5rem; }
.share-body img, .share-body video {
  max-width: 100%; max-height: calc(100vh - 9rem); width: auto; height: auto;
  border-radius: 6px; background: #000;
}
.share-body.kind-image img { background: transparent; }
.share-body audio { width: min(600px, 100%); }
.textview { width: min(980px, 100%); align-self: stretch; margin: 0 auto; }
.textview .seg { margin-bottom: .75rem; }
.textview pre {
  margin: 0; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
}
.markdown { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; overflow-wrap: anywhere; }
.markdown img { max-width: 100%; }
.markdown pre { background: var(--bg); padding: .75rem; border-radius: 6px; overflow: auto; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: .3rem .6rem; }
.markdown blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--border); color: var(--muted); }
.download-card { text-align: center; padding: 2rem 1rem; }
.big-ext {
  display: inline-flex; align-items: center; justify-content: center; width: 6rem; height: 7.5rem;
  border: 2px solid var(--border); border-radius: 10px; font-weight: 800; color: var(--muted); background: var(--surface);
}
.share-body.kind-text, .share-body.kind-markdown { justify-content: flex-start; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.narrow-form { max-width: 360px; }
input.short { flex: 0 0 6rem !important; width: 6rem; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.danger-zone label { flex-basis: 100%; }
