/* SyncBoard · 同步板 */
:root {
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #e7e9ff 0%, rgba(245,246,250,0) 60%),
             radial-gradient(900px 500px at 100% 0%, #dff7fb 0%, rgba(245,246,250,0) 55%);
  --panel: #ffffff;
  --panel-soft: #f8f9fc;
  --border: #e4e6ef;
  --border-strong: #d3d6e4;
  --text: #16181f;
  --muted: #6a7080;
  --faint: #9aa1b1;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-2: #0891b2;
  --danger: #e11d48;
  --danger-soft: #fff1f4;
  --ok: #10b981;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 30px rgba(16, 24, 40, .07);
  --radius: 16px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --bg-grad: radial-gradient(1200px 600px at 20% -10%, #1d2140 0%, rgba(14,16,22,0) 60%),
               radial-gradient(900px 500px at 100% 0%, #12313a 0%, rgba(14,16,22,0) 55%);
    --panel: #171a22;
    --panel-soft: #1d212b;
    --border: #272c39;
    --border-strong: #333a4b;
    --text: #e8eaf2;
    --muted: #9aa2b5;
    --faint: #6f7789;
    --accent: #8b87f8;
    --accent-soft: #24274a;
    --accent-2: #38bdf8;
    --danger: #fb7185;
    --danger-soft: #331c25;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 18px 80px;
}

/* ---------- generic controls ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6d5ef0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-soft); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.btn-icon { padding: 7px 9px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 92px; font-family: var(--mono); font-size: 14px; line-height: 1.55; }
label { font-size: 13px; color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- home ---------- */
.home { padding-top: 6vh; }
.home-head { text-align: center; margin-bottom: 26px; }
.logo {
  width: 58px; height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 26px;
  margin: 0 auto 14px;
  box-shadow: 0 10px 26px rgba(79, 70, 229, .32);
}
.home h1 { font-size: 27px; margin: 0 0 6px; letter-spacing: .5px; }
.home .sub { color: var(--muted); margin: 0; font-size: 14.5px; }
.home-card { padding: 22px; max-width: 520px; margin: 0 auto; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; }
.row { display: flex; gap: 10px; }
.row > .grow { flex: 1; min-width: 0; }
.hint { color: var(--faint); font-size: 12.5px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--muted);
}

/* ---------- room ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  margin: -20px -18px 16px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.topbar .spacer { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.off { background: var(--danger); }

.lock-card { max-width: 420px; margin: 12vh auto; padding: 24px; text-align: center; }
.lock-card h2 { margin: 12px 0 6px; font-size: 20px; }
.lock-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.composer { padding: 14px; margin-bottom: 18px; }
.composer textarea { min-height: 84px; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.composer-bar .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); }

.progress { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; display: none; }
.progress.on { display: block; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }

.list { display: flex; flex-direction: column; gap: 12px; }
.item { padding: 12px 14px; }
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.item-head .meta { min-width: 0; flex: 1; }
.item-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 12px; color: var(--faint); }
.badge {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.badge.file { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.badge.img  { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.item-actions { display: flex; gap: 6px; flex: none; }

.text-body {
  white-space: pre-wrap; word-break: break-word; font-family: var(--mono);
  font-size: 14px; background: var(--panel-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; max-height: 340px; overflow: auto;
}
.text-body.clamped { max-height: 220px; }
.item-edit textarea { min-height: 120px; }

.file-row { display: flex; align-items: center; gap: 12px; }
.file-icon {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 19px;
  background: var(--panel-soft); border: 1px solid var(--border);
}
.img-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--panel-soft); }
.img-wrap img { display: block; width: 100%; max-height: 380px; object-fit: contain; cursor: zoom-in; background: repeating-conic-gradient(var(--panel-soft) 0% 25%, var(--panel) 0% 50%) 50% / 18px 18px; }
.img-fail { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

.empty { text-align: center; padding: 48px 20px; color: var(--faint); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.drop-hint {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 3px dashed var(--accent);
  display: grid; place-items: center;
  font-size: 19px; font-weight: 600; color: var(--accent);
  pointer-events: none;
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 12, 18, .45);
  display: grid; place-items: center;
  padding: 18px;
  backdrop-filter: blur(2px);
}
.modal {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--panel);
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: pop .18s ease;
  max-width: 90vw;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 10, 14, .82);
  display: grid; place-items: center; padding: 20px;
}
.lightbox[hidden] { display: none; }
.lightbox-inner {
  position: relative; max-width: min(1000px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; gap: 10px;
}
.lightbox-inner img {
  max-width: 100%; max-height: 78vh; object-fit: contain;
  border-radius: 12px; background: #fff;
}
.lightbox-close {
  position: absolute; top: -14px; right: -14px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--panel); color: var(--text); font-size: 16px; cursor: pointer;
  box-shadow: var(--shadow);
}
.lightbox-bar { display: flex; align-items: center; gap: 12px; }
.lightbox-name { color: #e9ecf5; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.lightbox-actions { display: flex; gap: 8px; }
.lightbox-actions .btn-ghost { color: #dfe3ee; }

@media (max-width: 560px) {
  .app { padding: 16px 13px 70px; }
  .topbar { margin: -16px -13px 14px; padding: 9px 13px; }
  .topbar .title span { max-width: 32vw; }
  .btn span.t { display: none; }
  .btn { padding: 8px 10px; }
}
