/* 中转站 — styles. Layout rule: things side by side are the same width and height (grid with
   minmax(0, 1fr), stretch), and long text is cut with "…". Light only. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { display: inline-grid; place-items: center; }
.ico svg { width: 20px; height: 20px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
kbd {
  font-family: var(--font-mono); font-size: 13px; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text);
}

/* ── page frame ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243, 245, 248, 0.92);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}
.topbar-inner {
  max-width: var(--content-max); margin: 0 auto; min-height: 56px;
  display: grid; grid-template-columns: minmax(var(--tap), auto) minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 0 calc(var(--gutter) - 8px);
}
.topbar-title { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-end { display: flex; align-items: center; gap: 4px; }
.page { max-width: var(--content-max); margin: 0 auto; padding: 12px var(--gutter) calc(var(--safe-bottom) + 40px); }
.page.narrow { max-width: 520px; }
.page-head { padding: 32px 0 20px; }
.page-head h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; }
.page-head p { margin-top: 6px; color: var(--text-2); }
.stack { display: grid; gap: var(--gap); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 4px 8px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-3); letter-spacing: 0.02em; }
.whoami { margin: 0 4px 10px; font-size: 13px; }
.rules { margin: 16px 4px 0; text-align: center; }

/* ── buttons ── */
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: var(--r-pill); border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--accent-ink); cursor: pointer; flex: none;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.danger { color: var(--text-3); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.is-armed { width: auto; padding: 0 12px; color: var(--on-accent); background: var(--danger); font-size: 14px; font-weight: 600; }

.btn {
  position: relative; min-height: var(--tap); padding: 10px 18px; border-radius: var(--r-m);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer; text-align: center;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1), box-shadow var(--dur-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn .ico svg, .btn > svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px rgba(30, 91, 214, 0.24); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-tonal { background: var(--accent-soft); color: var(--accent-ink); }
.btn-tonal:hover { background: #DCE7FC; }
.btn-ghost { background: transparent; color: var(--accent-ink); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-lg { min-height: 52px; font-size: 16px; border-radius: var(--r-l); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: var(--r-s); }
.btn-block { display: flex; width: 100%; }
.btn.is-busy { color: transparent; }
.btn.is-busy .ico { opacity: 0; }
.spinner {
  position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}
.btn.is-busy .spinner { color: var(--text-2); }
.btn-primary.is-busy .spinner { color: var(--on-accent); }
.spinner-inline { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.btn-row > .btn { width: 100%; height: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; font-weight: 600; justify-self: start; }

/* ── cards and lists ── */
.card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); padding: var(--card-pad); }
.card-title { margin: 0; font-size: 17px; font-weight: 700; }
.notice { display: grid; gap: 12px; justify-items: start; }
.list { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); overflow: hidden; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px var(--card-pad); background: var(--surface); width: 100%;
}
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.row-sub { margin-top: 2px; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; align-items: center; gap: 2px; }
.row-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.row-icon svg { width: 22px; height: 22px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; justify-self: start;
}
.chip .ico svg { width: 14px; height: 14px; }
.chip-ok { background: var(--positive-soft); color: var(--positive); }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ── login ── */
.login .card { display: grid; gap: 12px; }
.pair-code { font-size: 44px; font-weight: 700; letter-spacing: 0.08em; text-align: center; color: var(--accent-ink); padding: 8px 0; }
.steps { margin: 0; padding-left: 22px; color: var(--text-2); display: grid; gap: 4px; }
.pair-status { text-align: center; }

/* ── composer ── */
.composer { display: grid; gap: 14px; }
.dropzone {
  display: grid; justify-items: center; gap: 8px; padding: 22px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--r-m); background: var(--surface-2); color: var(--text-2);
  transition: border-color var(--dur-1), background var(--dur-1);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.dropzone-icon svg { width: 24px; height: 24px; }
.dropzone-title { font-weight: 600; color: var(--text); }
.composer-text { display: grid; gap: 10px; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── form fields ── */
.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.input, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--r-s); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 16px; line-height: 1.4; appearance: none; -webkit-appearance: none;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.textarea { min-height: 120px; resize: vertical; }
.textarea.is-short { min-height: 84px; }
.code-input { font-size: 28px; text-align: center; letter-spacing: 0.2em; }
.error-text { color: var(--danger); font-size: 14px; }
.warn-text { color: var(--warning); }

/* ── items ── */
.item {
  display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr) auto; gap: 12px; align-items: start;
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1); padding: 12px;
}
.item.is-taken { background: var(--surface-2); box-shadow: none; border: 1px solid var(--line); }
.thumb {
  width: var(--thumb); height: var(--thumb); border-radius: 12px; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3); overflow: hidden; border: 0; padding: 0;
}
.thumb svg { width: 26px; height: 26px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.is-image { cursor: zoom-in; }
.thumb.is-file { background: var(--accent-soft); color: var(--accent-ink); }
.thumb.is-text { background: var(--positive-soft); color: var(--positive); }
.item-main { min-width: 0; display: grid; gap: 4px; }
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.item-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.item-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; align-items: center; gap: 2px; }
.empty { display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--text-2); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.empty-icon svg { width: 24px; height: 24px; }

@media (max-width: 480px) {
  .item { grid-template-columns: 44px minmax(0, 1fr); }
  .thumb { width: 44px; height: 44px; }
  .item-actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) var(--tap); gap: 8px; }
  .item-actions.has-share { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--tap); }
}

/* ── uploads ── */
.upload { display: grid; gap: 8px; padding: 12px var(--card-pad); }
.upload-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width var(--dur-2) var(--ease-out); }
.drop-hint {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none;
  background: rgba(30, 91, 214, 0.12); border: 4px dashed var(--accent);
}
.drop-hint > div { display: grid; justify-items: center; gap: 8px; padding: 24px 36px; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow-3); font-size: 18px; font-weight: 700; color: var(--accent-ink); }
.drop-hint svg { width: 36px; height: 36px; }

/* ── add device ── */
.request { display: grid; grid-template-columns: var(--thumb) minmax(0, 1fr); gap: 12px; align-items: center; }
.done { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 12px 0; }
.done-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--positive-soft); color: var(--positive); }
.done-icon svg { width: 28px; height: 28px; }

/* ── picture viewer ── */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 35, 0.72); display: grid; place-items: center; padding: 16px;
  opacity: 0; transition: opacity var(--dur-2) var(--ease-out);
}
.overlay.is-open { opacity: 1; }
.viewer-box { display: grid; gap: 10px; max-width: min(1100px, 100%); max-height: 100%; }
.viewer-box img { max-height: calc(100dvh - 120px); max-width: 100%; margin: 0 auto; border-radius: var(--r-m); background: var(--surface); object-fit: contain; }
.viewer-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; color: #FFFFFF; }
.viewer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── toast and update screen ── */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 20px); z-index: 80; display: grid; justify-items: center; pointer-events: none; padding: 0 var(--gutter); }
.toast {
  max-width: 480px; padding: 12px 16px; border-radius: var(--r-m); background: #1C2533; color: #FFFFFF; box-shadow: var(--shadow-3);
  font-size: 14px; opacity: 0; transform: translateY(8px); transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.toast.is-shown { opacity: 1; transform: none; }
.toast.is-error { background: var(--danger); }
.update-screen { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; }
.update-screen h2 { margin: 6px 0 0; font-size: 19px; }
.update-screen p { color: var(--text-2); }

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

/* ── shortcut key ── */
.key-box { display: grid; gap: 10px; }
.key-box .input { font-size: 14px; }
