/* TunnelDrop — cool slate base, one teal accent, one ceiling red used only for the limit line. */
:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5b6b7a;
  --line: #d3dce4;
  --accent: #0e7c70;
  --accent-ink: #ffffff;
  --accent-soft: #d5ece8;
  --ceiling: #b4361b;
  --warn: #9a5b00;
  --radius-s: 6px;
  --radius-l: 14px;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171e;
    --surface: #18222c;
    --ink: #e6edf3;
    --muted: #93a4b5;
    --line: #2b3946;
    --accent: #3cc2b0;
    --accent-ink: #06201c;
    --accent-soft: #163a36;
    --ceiling: #ff7a5c;
    --warn: #f0b45a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}
[hidden] { display: none !important; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.92em; }

.top, main, .foot { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.25rem; }
.mark { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.top nav { display: flex; gap: 1.25rem; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.top nav a:hover { color: var(--ink); }

main { padding-top: 2.5rem; padding-bottom: 3rem; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.12; letter-spacing: -0.03em; margin: 0 0 0.75rem; font-weight: 800; max-width: 22ch; }
.lede { color: var(--muted); margin: 0 0 1.75rem; max-width: 60ch; }

/* tabs */
.tabs { display: inline-flex; gap: 0.25rem; padding: 0.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 1rem; }
.tabs button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 0.4rem 1rem; border-radius: 999px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

/* drop zone */
.drop {
  display: grid; place-items: center; align-content: center; gap: 0.25rem; text-align: center;
  min-height: 11rem; padding: 1.5rem;
  border: 2px dashed var(--line); border-radius: var(--radius-l); background: var(--surface);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { font-size: 1.2rem; }
.drop span { color: var(--muted); }
.drop.over, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }

.queue { list-style: none; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.35rem; }
.queue li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.75rem; background: var(--surface); border-radius: var(--radius-s); border: 1px solid var(--line); }
.queue li span:last-child { color: var(--muted); white-space: nowrap; }
.queue button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; }

/* fields */
.field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.field > span { font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.55rem 0.7rem; width: 100%;
}
textarea { font-family: var(--mono); font-size: 0.92rem; resize: vertical; }
.check { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
.check input { width: auto; accent-color: var(--accent); }

.opts { border: 0; padding: 0; margin: 1.5rem 0 1.25rem; display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 0.9rem; }
.opts legend { font-weight: 700; margin-bottom: 0.6rem; padding: 0; }
.opts .check { grid-column: span 3; }
@media (max-width: 600px) { .opts { grid-template-columns: 1fr; } .opts .check { grid-column: auto; } }

/* buttons */
button, .button {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1rem; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  white-space: nowrap; flex-shrink: 0;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.55; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding: 0.7rem 1.6rem; }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.danger { color: var(--ceiling); }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.error { color: var(--ceiling); font-weight: 600; }
.notice { padding: 0.75rem 1rem; border-left: 4px solid var(--warn); background: var(--surface); border-radius: var(--radius-s); }
.status { color: var(--muted); }

/* The chunk meter: every request is a bar drawn to scale against Cloudflare's per-request ceiling. */
.meter { margin: 2rem 0 0; }
.strip {
  position: relative; height: 7rem; display: flex; align-items: flex-end; gap: 2px;
  padding: 0 0.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden;
}
.ceiling { position: absolute; left: 0; right: 0; top: 0.9rem; border-top: 2px dashed var(--ceiling); }
.ceiling::after {
  content: attr(data-label); position: absolute; right: 0.6rem; top: 0.2rem;
  font-size: 0.78rem; font-weight: 700; color: var(--ceiling);
}
.bar { flex: 1 1 0; min-width: 2px; max-width: 18px; min-height: 4px; border-radius: 2px 2px 0 0; background: var(--line); }
.bar.sending { background: var(--accent); opacity: 0.5; }
.bar.done { background: var(--accent); }
.bar.retry { background: var(--warn); }
.meter figcaption { color: var(--muted); font-size: 0.92rem; margin-top: 0.5rem; }

/* results */
.results { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.9rem; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1rem; }
.result-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.r-meta { color: var(--muted); font-size: 0.92rem; }
.share-link { display: flex; gap: 0.4rem; }
.share-link input { font-family: var(--mono); font-size: 0.85rem; min-width: 0; }
.qr { display: block; margin: 0.75rem 0 0; width: 11rem; height: 11rem; image-rendering: pixelated; background: #fff; padding: 0.4rem; border-radius: var(--radius-s); }
.r-details { margin-top: 0.75rem; color: var(--muted); }
.r-details summary { cursor: pointer; }
.r-details code { word-break: break-all; color: var(--ink); }

/* view */
.open-form { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.open-form .field { margin: 0; flex: 1 1 14rem; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 1rem 0; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.view-out { margin-top: 1rem; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.75rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.view-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1.25rem; overflow-x: auto; }
.view-body pre { margin: 0; font: 0.9rem/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.view-body.md pre { background: var(--bg); padding: 0.9rem; border-radius: var(--radius-s); }
.view-body.md > :first-child { margin-top: 0; }
.view-body.md blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.view-body img, .view-body video { max-width: 100%; height: auto; display: block; border-radius: var(--radius-s); }
.tk-kw { color: #8a3ffc; font-weight: 600; }
.tk-str { color: #0e7c70; }
.tk-com { color: var(--muted); font-style: italic; }
.tk-num { color: #b4361b; }
@media (prefers-color-scheme: dark) { .tk-kw { color: #c6a4ff; } .tk-str { color: #6fe0cf; } .tk-num { color: #ff9b7f; } }

/* room */
.room-form { margin-top: 1rem; }
.room-log { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; gap: 0.6rem; }
.room-log li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 0.75rem 0.9rem; }
.room-log li.mine { border-color: var(--accent); }
.room-log pre { margin: 0 0 0.4rem; font: 0.9rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.room-log .when { color: var(--muted); font-size: 0.82rem; margin-right: 0.6rem; }
.room-log button { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

.foot { color: var(--muted); font-size: 0.88rem; padding-bottom: 2rem; }

/* admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface); border-radius: var(--radius-l); overflow: hidden; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 0.75rem 0.9rem; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }

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