/* EZ Drop — its own accent in the fleet: teal.
 *
 * Analytics is purple, Remailminder green, EZ Author navy, Pinsive magenta.
 * Teal was free and reads as "in transit" rather than as a status colour, so
 * green and red stay available for what a transfer actually did.
 *
 * Scrollbars are hidden app-wide per the house rule; the only thing that ever
 * scrolls visibly here would be a wide table, and there isn't one.
 */

:root {
  --accent: #0F8B9E;
  --accent-ink: #0B6B79;
  --accent-soft: #E4F4F6;

  --bg: #F7F9FA;
  --card: #FFFFFF;
  --ink: #17252A;
  --ink-soft: #5B6B70;
  --line: #DFE6E8;

  --ok: #1E8E5A;
  --warn: #B4690E;
  --bad: #C0392B;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(23,37,42,.06), 0 6px 20px rgba(23,37,42,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1618;
    --card: #162226;
    --ink: #E8F1F3;
    --ink-soft: #94A8AD;
    --line: #25353A;
    --accent: #2BB3C7;
    --accent-ink: #7FD8E5;
    --accent-soft: #123036;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

/* `hidden` has to outrank the layout rules below it. Without this, `#tabs`
   (display:flex) and any `.page` stay on screen with hidden="true" set, which
   is how the pairing gate ended up invisible on a brand-new device — the one
   screen a brand-new device has to see. */
[hidden] { display: none !important; }

/* House rule: no scrollbars anywhere. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: none;
}

h1, h2 { letter-spacing: -0.3px; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 10px; }

.muted { color: var(--ink-soft); font-size: 13px; }
.lede { color: var(--ink-soft); margin: 0 0 14px; }
.empty { color: var(--ink-soft); font-size: 14px; padding: 14px 2px; }
.spacer { flex: 1; }
.mini { width: 15px; height: 15px; }

/* ── Splash (app overrides on the shared structural CSS) ─────────────── */
#splash { background: var(--bg); }
.splash-logo { width: 84px; height: 84px; }
.splash-name { color: var(--ink); }
.splash-by { color: var(--ink-soft); }

/* ── Top bar ───────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.brand img { width: 26px; height: 26px; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.conn.is-on .dot { background: var(--ok); }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
#tabs {
  position: sticky; top: 0; z-index: 25;
  display: flex; gap: 2px;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-soft);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.tab svg { width: 17px; height: 17px; }
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.is-on { background: var(--accent-soft); color: var(--accent-ink); }

/* ── Layout ────────────────────────────────────────────────────────────── */
#main { max-width: 820px; margin: 0 auto; padding: 18px 16px 40px; }
.page { display: none; }
.page.is-on { display: block; }
.section-head { margin: 26px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ink-soft); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.centred { text-align: center; }

.row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* ── Controls ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--line); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

input[type="text"], textarea {
  flex: 1; min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
  font: inherit;
}
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#join-code { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }

/* ── Drop zone ─────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--card);
  padding: 30px 20px; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 30px; height: 30px; color: var(--accent); }
.dz-inner p { margin: 10px 0 14px; color: var(--ink-soft); }
.dz-inner strong { color: var(--ink); }
.dz-inner .row { justify-content: center; }

.staged { margin-top: 14px; }
.staged-head { display: flex; align-items: center; justify-content: space-between; }

/* ── Peer tiles ────────────────────────────────────────────────────────── */
.peers { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.peer {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 18px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  cursor: pointer; text-align: center;
  box-shadow: var(--shadow);
}
.peer:hover { border-color: var(--accent); }
.peer.is-armed { border-color: var(--accent); background: var(--accent-soft); }
.peer .ring {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.peer .ring svg { width: 25px; height: 25px; }
.peer .who { font-weight: 600; font-size: 14px; line-height: 1.25; }
.peer .tag { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.peer.guest .ring { background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); }

/* ── File rows ─────────────────────────────────────────────────────────── */
.filelist { list-style: none; margin: 0; padding: 0; }
.filerow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card);
  margin-bottom: 8px;
}
.filerow .meta { flex: 1; min-width: 0; }
.filerow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .sub { font-size: 12px; color: var(--ink-soft); }
.filerow .sub.bad { color: var(--bad); }
.filerow .sub.ok { color: var(--ok); }

.bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .12s linear; }

/* ── Quota ─────────────────────────────────────────────────────────────── */
.quota { margin-bottom: 14px; }
.quota-bar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.quota-bar > div { height: 100%; background: var(--accent); width: 0; }

/* ── Big codes ─────────────────────────────────────────────────────────── */
.bigcode {
  font-size: 40px; font-weight: 700; letter-spacing: 8px;
  color: var(--accent-ink);
  margin: 16px 0 8px;
  font-variant-numeric: tabular-nums;
}
.token {
  display: block; word-break: break-all;
  padding: 11px 13px; margin: 8px 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}

/* ── Pair requests ─────────────────────────────────────────────────────── */
.requests { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; }
.request {
  max-width: 460px; margin: 0 auto; width: 100%;
  background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow);
}
.request .code { font-weight: 700; letter-spacing: 3px; color: var(--accent-ink); font-size: 19px; }

/* ── Toasts ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 70; display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 14px; font-size: 14px; box-shadow: var(--shadow);
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* ── Dialog ────────────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  padding: 20px; max-width: 460px; width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog textarea { width: 100%; margin-bottom: 12px; }

/* ── Footer ────────────────────────────────────────────────────────────── */
#foot {
  max-width: 820px; margin: 0 auto;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 10px;
  color: var(--ink-soft); font-size: 13px;
  border-top: 1px solid var(--line);
}

/* ── Wide screens: it is a desktop app first ───────────────────────────── */
@media (min-width: 720px) {
  #topbar { padding: 12px 24px; }
  #tabs { padding: 10px 20px; }
  #main { padding: 24px 20px 48px; }
  .peers { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* An incoming-file card warns before you accept, not after it fails. */
.request .warn { color: var(--bad); margin: 0 0 12px; }

/* Shown when the browser is withholding capabilities at this address. */
.degraded {
  max-width: 820px; margin: 12px auto 0; padding: 11px 14px;
  border: 1px solid var(--warn); border-radius: 10px;
  color: var(--warn); font-size: 13px; line-height: 1.45;
}
@media (min-width: 720px) { .degraded { margin-top: 16px; } }

/* An outside device has to quote its code; one on your network does not. */
.request .detail { color: var(--ink-soft); font-size: 13px; margin: 0 0 10px; }

/* Nearby: on this network but not one of your own devices. Visible, sendable,
   and nothing more — it cannot see the drop folder. */
.peer.nearby .ring { background: var(--accent-soft); color: var(--accent-ink); border: 0; }
.peer.nearby { border-style: dashed; }

/* ── First run ─────────────────────────────────────────────────────────── */
.intro {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
.intro-card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
  text-align: center;
}
.intro-logo { width: 62px; height: 62px; }
.intro-card h1 { margin: 14px 0 6px; }
.intro-points { list-style: none; margin: 22px 0; padding: 0; text-align: left; display: grid; gap: 16px; }
.intro-points li { display: flex; gap: 13px; align-items: flex-start; font-size: 14px; color: var(--ink-soft); line-height: 1.45; }
.intro-points svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--accent); }
.intro-points strong { color: var(--ink); display: block; }

/* Hosting locally is useful news, not a warning. */
.degraded.hosting { border-color: var(--accent); color: var(--accent-ink); }
