:root {
  color-scheme: light dark;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fe;
  --border: #e6e8f2;
  --text: #1c2130;
  --text-soft: #6b7280;
  --primary: #5b5bf0;
  --primary-strong: #4a4ad9;
  --green: #16a34a;
  --green-bg: #e7f7ee;
  --blue: #2563eb;
  --blue-bg: #e9f0fe;
  --red: #dc2626;
  --toast-bg: #1f2430;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 8px 24px rgba(20, 24, 50, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --surface: #171a23;
    --surface-2: #1e2230;
    --border: #2a3040;
    --text: #e8eaf3;
    --text-soft: #9aa2b8;
    --primary: #8f8ff5;
    --primary-strong: #7c7cf0;
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, .14);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, .14);
    --red: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Login (popup over the app) ---------- */
.login-view {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vh, 28px);
  overflow-y: auto;
  background: rgba(14, 16, 28, .55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.login-card {
  width: min(460px, 100%);
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 40px) clamp(18px, 4vw, 36px);
  text-align: center;
}

.logo-img {
  display: block;
  object-fit: cover;
}
.logo-img.login {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  border-radius: 20px;
  box-shadow: 0 10px 24px rgba(91, 91, 240, .35);
}
.logo-img.small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  box-shadow: 0 6px 14px rgba(91, 91, 240, .3);
}

.login-card h1 { margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.tagline { color: var(--text-soft); font-size: 15px; line-height: 1.55; margin: 0 0 22px; }

.features {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  text-align: left;
  font-size: 14px;
  color: var(--text-soft);
}
.features li {
  padding: 8px 0 8px 30px;
  position: relative;
  line-height: 1.4;
}
.features li::before {
  content: '✓';
  position: absolute;
  left: 4px;
  top: 8px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(20, 24, 50, .05);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-google:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.divider.guest-divider { margin: 20px 0 16px; }
.btn-guest {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn-guest:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); box-shadow: var(--shadow); }
.btn-guest:active { transform: scale(.97); }
.guest-hint { margin: 10px 0 0; font-size: 12px; color: var(--text-soft); }

.legal { margin: 16px 0 0; font-size: 12px; color: var(--text-soft); line-height: 1.5; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 18px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.email-auth { text-align: left; }
.ea-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.ea-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.ea-tab.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.ea-tabs.hidden { display: none; }
.ea-step { display: block; }
.ea-step.hidden { display: none; }
.ea-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin: 0 0 12px;
}
.ea-input:focus { border-color: var(--primary); }
.ea-code-input {
  text-align: center;
  font-size: 18px;
  letter-spacing: 10px;
  font-weight: 700;
}
.btn-block { width: 100%; }
.ea-hint { margin: 0 0 12px; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.ea-hint b { color: var(--text); }
.ea-rule { margin: -4px 0 12px; font-size: 12px; color: var(--text-soft); }
.ea-target {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.ea-error { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--red); line-height: 1.45; }
.ea-ok { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--green); line-height: 1.45; }
.ea-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.ea-links .link {
  background: none;
  border: none;
  font-size: 12.5px;
  padding: 4px;
}
.ea-photo-preview {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  margin: 0 auto 14px;
  background: var(--surface-2);
}
.ea-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.ea-photo-preview .initials {
  width: 100%;
  height: 100%;
  font-size: 26px;
  border: none;
  border-radius: 50%;
}
#ea-photo {
  border: 1px dashed var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 10px;
}
#ea-photo::-webkit-file-upload-button {
  border: none;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  margin-right: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- App shell ---------- */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.5vw, 16px);
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 2vw, 28px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.3px; }

.me { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 2px solid var(--border);
}
.initials {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--primary);
  border: 2px solid var(--surface);
  border-radius: 50%;
  width: 38px; height: 38px;
  flex: none;
}
.person .initials { width: 36px; height: 36px; font-size: 12.5px; }
.me-text { text-align: right; }
.me-name { font-weight: 600; font-size: 14px; }
.me-email { font-size: 12px; color: var(--text-soft); }

.menu-wrap { position: relative; }
.menu-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 12px;
}
.menu-btn:hover { background: var(--surface-2); }
.menu-btn .avatar,
.menu-btn .initials { width: 38px; height: 38px; }
.chev { color: var(--text-soft); font-size: 11px; transition: transform .18s ease; }
.menu-btn.open .chev { transform: rotate(180deg); }
.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(10, 14, 40, .22);
  padding: 6px;
  z-index: 60;
  transform-origin: top right;
  animation: menu-pop .18s cubic-bezier(.2, .9, .3, 1.25) backwards;
}
.user-menu.hidden { display: none; }
.menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.menu-header .avatar,
.menu-header .initials { width: 38px; height: 38px; }
.menu-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-email { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.menu-item svg { flex: none; }
.menu-item.logout svg { opacity: .85; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.logout { color: var(--red); }
.menu-item.logout:hover { background: rgba(220, 38, 38, .12); }
.spark-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .2s, box-shadow .2s;
}
.menu-item.connected .spark-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
}

.history-topbar { justify-content: flex-start; gap: 14px; }
.btn-back {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  cursor: pointer;
  font-size: 16px;
  flex: none;
}
.btn-back:hover { background: var(--surface-2); }
.logo-img.small { width: 28px; height: 28px; border-radius: 8px; }
.history-sub-line { font-size: 12px; color: var(--text-soft); }

.history-page {
  flex: 1;
  width: 100%;
  max-width: min(900px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.5vw, 24px) clamp(12px, 2vw, 20px) 40px;
}
.history-page .tabs { max-width: min(420px, 100%); }
.history-page .history-list { max-width: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 40, .5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(10, 14, 40, .35);
  padding: 22px;
  width: 100%;
  max-width: 440px;
  animation: menu-pop .18s cubic-bezier(.2, .9, .3, 1.25) backwards;
}
.modal-card h3 { margin: 0 0 6px; font-size: 16px; }
.modal-card .modal-sub { margin: 0 0 14px; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.mcp-url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: stretch;
}
.mcp-url-row .search { flex: 1; margin-bottom: 0; font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--text); }
.mcp-url-row .btn-primary { flex: none; }
.modal-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--red);
  background: rgba(220, 38, 38, .08);
  border: 1px solid rgba(220, 38, 38, .25);
  border-radius: 10px;
}
#mcp-reset { margin-bottom: 8px; }

.offline-banner {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  letter-spacing: .2px;
}
.offline-connect {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: 12px;
}
.offline-hint { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--text-soft); }
.offline-connect .btn-primary { margin-bottom: 8px; }
.offline-code {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  margin: 0 0 10px;
  padding: 10px;
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  word-break: break-all;
}
.offline-waiting {
  margin: 10px 0;
  font-size: 12.5px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.5;
}
.offline-code::-webkit-scrollbar { width: 6px; }
.offline-code::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#offline-step-offer .btn-block,
#offline-step-answer .btn-block {
  margin-bottom: 14px;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 24px);
  padding: clamp(10px, 1.5vw, 22px);
  max-width: min(1600px, 100%);
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.4vw, 24px);
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(12px, 1.3vw, 20px);
  min-height: clamp(200px, 45vh, 420px);
}

.room-join-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
#room-controls { margin-top: 14px; }
#room-controls .btn-primary { margin-bottom: 10px; }
.room-join-row .search { flex: 1; margin-bottom: 0; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.room-join-row .btn-ghost { flex: none; }

.room-code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 10px;
}
.room-code-label { font-size: 11px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px; }
.room-code-val {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--blue);
}
.room-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.room-actions .link { background: none; border: none; padding: 0; }
.room-leave { color: var(--red); }
.room-leave:hover { text-decoration: underline; }

.room-link-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 10px;
}
.room-link-box.hidden { display: none; }
.room-link-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}
.room-link-row .search { flex: 1; margin-bottom: 0; font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); }
.room-link-row .btn-ghost { flex: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.hint { font-size: 11px; font-weight: 500; color: var(--text-soft); }

.icon-btn {
  border: none;
  background: var(--surface-2);
  width: 30px; height: 30px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-soft);
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn.spin { animation: spin .6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.legend { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge.same { background: var(--green-bg); color: var(--green); }
.badge.server { background: var(--blue-bg); color: var(--blue); }

.search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: var(--surface-2);
  outline: none;
  margin-bottom: 10px;
}
.search:focus { border-color: var(--primary); background: var(--surface); }

.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.people-list .person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.people-list .person:hover { background: var(--surface-2); }
.people-list .person.selected { background: var(--blue-bg); border-color: rgba(37, 99, 235, .25); }
.person .avatar { width: 36px; height: 36px; flex: none; }
.person-info { min-width: 0; flex: 1; }
.person-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 11.5px; color: var(--text-soft); }

.empty {
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
  padding: 30px 10px;
}

/* ---------- Share panel ---------- */
.selected-peer {
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selected-peer.empty { color: var(--text-soft); font-weight: 500; background: transparent; padding: 0; }
.selected-peer.same { background: var(--green-bg); color: var(--green); }
.selected-peer.server { background: var(--blue-bg); color: var(--blue); }

.panel-share { display: flex; flex-direction: column; }
.panel-share .panel-head { flex: none; }

.dropzone {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 34px) clamp(14px, 2vw, 20px);
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dropzone.drag { border-color: var(--primary); background: var(--blue-bg); }
.dz-icon {
  width: 46px; height: 46px;
  margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 22px;
  font-weight: 700;
}
.dropzone p { margin: 0 0 4px; font-size: 14px; }
.dropzone p:first-of-type { font-weight: 600; }
.dz-sub { color: var(--text-soft); font-size: 12.5px; }
.link { color: var(--primary); cursor: pointer; font-weight: 600; }

.file-picker { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.picked-files { list-style: none; margin: 0 0 12px; padding: 0; max-height: 160px; overflow: auto; }
.picked-files li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 13px;
  border-bottom: 1px dashed var(--border);
}
.picked-files li:last-child { border-bottom: none; }
.picked-files .fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked-files .fsize { color: var(--text-soft); font-size: 12px; flex: none; }
.picked-files .x { border: none; background: none; color: var(--text-soft); cursor: pointer; font-size: 15px; flex: none; }
.picked-files .x:hover { color: var(--red); }

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #6d6df5, #4a4ad9);
  color: #fff;
  padding: 11px 22px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(91, 91, 240, .3);
  transition: transform .12s ease, opacity .12s ease;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* 14px breathing room between action buttons that sit next to each other. */
.btn-primary + .btn-primary,
.btn-primary + .btn-ghost,
.btn-ghost + .btn-primary,
.btn-ghost + .btn-ghost,
.btn-google + .btn-primary,
.btn-google + .btn-ghost,
.btn-primary + .btn-google,
.btn-ghost + .btn-google {
  margin-left: 14px;
}
.btn-block + .btn-block,
.btn-block + .btn-primary,
.btn-primary + .btn-block,
.btn-block + .btn-ghost,
.btn-ghost + .btn-block {
  margin-left: 0;
  margin-top: 14px;
}

.transfers, .incoming { display: flex; flex-direction: column; gap: 10px; }

.t-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
}
.t-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.t-head .who { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-head .stat { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.t-head .stat.ok { color: var(--green); }
.t-head .stat.err { color: var(--red); }

.pbar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.pbar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6d6df5, #4a4ad9);
  border-radius: 999px;
  transition: width .1s linear;
}
.t-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-soft); margin-top: 6px; }

.incoming .t-card { background: var(--surface-2); }
.incoming .files { margin: 8px 0; list-style: none; padding: 0; }
.incoming .files li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; }
.incoming .files .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.incoming .btn-dl {
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  flex: none;
}

/* ---------- History ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.tab.active { background: var(--text); color: var(--surface); border-color: var(--text); }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.h-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.h-icon {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 14px;
}
.h-item.sent .h-icon { background: var(--blue-bg); color: var(--blue); }
.h-item.received .h-icon { background: var(--green-bg); color: var(--green); }
.h-info { flex: 1; min-width: 0; }
.h-fname { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-sub { font-size: 11.5px; color: var(--text-soft); }
.h-date { font-size: 11px; color: var(--text-soft); flex: none; text-align: right; }
.h-dl {
  border: none;
  background: var(--surface-2);
  color: var(--text);
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  flex: none;
}
.h-dl:hover { background: var(--primary); color: #fff; }
.h-del {
  border: none;
  background: transparent;
  color: var(--text-soft);
  width: 24px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  flex: none;
}
.h-del:hover { background: rgba(220, 60, 60, 0.12); color: #dc3c3c; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--toast-bg);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: toast-in .32s cubic-bezier(.18, .89, .32, 1.15) backwards;
  line-height: 1.45;
}
.toast.out { animation: toast-out .28s ease forwards; }
.toast b { color: #c7c7ff; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

@media (max-width: 1150px) {
  .layout { grid-template-columns: minmax(210px, 250px) minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .panel-share { order: -1; }
  .topbar { flex-wrap: wrap; }
  .me-text { display: none; }
  .selected-peer { max-width: 100%; }
  .history-page { max-width: 100%; }
}
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; }
  .brand-name { font-size: 15px; }
  .me { gap: 8px; }
  .menu-btn .avatar,
  .menu-btn .initials { width: 32px; height: 32px; }
  .panel { padding: 12px; }
  .dropzone { padding: 18px 12px; }
  .picked-files li { flex-wrap: wrap; }
  .ea-links { flex-direction: column; align-items: stretch; gap: 6px; }
  .toasts { left: 12px; right: 12px; max-width: none; }
  .btn-back { width: 34px; height: 34px; }
  .logo-img.small { width: 26px; height: 26px; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade-slide-down { from { opacity: 0; transform: translateY(-10px); } }
@keyframes item-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pop-in {
  0% { opacity: 0; transform: scale(.88); }
  70% { transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes toast-in { from { opacity: 0; transform: translateX(28px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(28px) scale(.95); } }
@keyframes menu-pop { from { opacity: 0; transform: scale(.9) translateY(-6px); } }
@keyframes step-in { from { opacity: 0; transform: translateY(7px); } }
@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes dz-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes dz-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.08); }
}
@keyframes dz-pulse {
  0% { box-shadow: 0 0 0 0 rgba(91, 91, 240, .28); }
  100% { box-shadow: 0 0 0 14px rgba(91, 91, 240, 0); }
}
@keyframes sheen {
  from { transform: translateX(-120%); }
  to { transform: translateX(220%); }
}
@keyframes pulse-once {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .45); }
  100% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
}
@keyframes glow-pop {
  0% { opacity: 0; transform: scale(.6); filter: blur(3px); }
  60% { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); filter: none; }
}
@keyframes shimmer {
  to { background-position: -200% center; }
}

/* View transitions */
.app-view { animation: fade-in .3s ease backwards; }
.topbar { animation: fade-slide-down .4s cubic-bezier(.2, .8, .3, 1) backwards; }
.panel { animation: rise-in .45s cubic-bezier(.2, .8, .3, 1) backwards; }
.panel-people { animation-delay: .05s; }
.panel-rooms { animation-delay: .12s; }
.panel-share { animation-delay: .1s; }

/* Brand shimmer */
.brand-name,
.login-card h1 {
  background: linear-gradient(90deg, var(--text) 0%, var(--primary) 45%, var(--text) 90%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}

/* Login popup */
.login-view { animation: fade-in .25s ease backwards; }
.login-card { animation: pop-in .42s cubic-bezier(.21, 1.02, .52, 1.1) backwards; }
.logo-img.login { animation: logo-float 3.4s ease-in-out infinite; }
.features li, .legal, .divider { animation: fade-in .5s ease backwards; }

/* Email-auth steps + tabs */
.ea-step:not(.hidden) { animation: step-in .3s ease backwards; }
.ea-tab.active, .tab.active { animation: pop-in .25s cubic-bezier(.21, 1.02, .52, 1.1) backwards; }

/* List stagger (people, rooms, history, picked files, features, incoming files) */
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li {
  animation: item-in .35s cubic-bezier(.2, .8, .3, 1) backwards;
}
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(1) { animation-delay: .02s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(2) { animation-delay: .05s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(3) { animation-delay: .08s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(4) { animation-delay: .11s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(5) { animation-delay: .14s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(6) { animation-delay: .17s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(7) { animation-delay: .20s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(8) { animation-delay: .23s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(9) { animation-delay: .26s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(10) { animation-delay: .29s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(11) { animation-delay: .32s; }
:is(.people-list, .picked-files, .history-list, .features, .incoming .files) li:nth-child(12) { animation-delay: .35s; }

/* People hover slide */
.people-list .person { transition: background .12s ease, border-color .12s ease, transform .12s ease; }
.people-list .person:hover { transform: translateX(2px); }

/* Selected peer pop (retriggered from JS) */
.selected-peer { transition: background .2s ease, color .2s ease, transform .2s ease; }
.selected-peer.pop { animation: pop-in .32s cubic-bezier(.21, 1.02, .52, 1.1); }

/* Rooms */
.room-code-box { animation: rise-in .4s cubic-bezier(.2, .8, .3, 1) backwards; }
.room-code-val { animation: glow-pop .55s cubic-bezier(.2, .8, .3, 1) backwards; }

/* Dropzone */
.dz-icon { animation: dz-float 3s ease-in-out infinite; }
.dropzone:hover .dz-icon { transform: scale(1.08); }
.dropzone.drag { animation: dz-pulse .9s ease-in-out infinite; }
.dropzone.drag .dz-icon { animation: dz-bounce .5s ease-in-out infinite; }

/* Transfer cards */
.t-card { animation: rise-in .35s cubic-bezier(.2, .8, .3, 1) backwards; }
.incoming .btn-dl { animation: pulse-once 1.4s ease; }

/* Progress bar sheen */
.pbar > div { position: relative; overflow: hidden; }
.pbar > div::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .38), transparent);
  animation: sheen 2.4s linear infinite;
}

/* Empty states */
.empty { animation: fade-in .4s ease backwards; }

/* Press feedback for all interactive controls */
.btn-google:active,
.btn-primary:active:not(:disabled),
.btn-ghost:active,
.icon-btn:active,
.btn-back:active,
.menu-item:active,
.btn-dl:active,
.h-dl:active,
.ea-tab:active,
.tab:active,
.icon-btn:active { transform: scale(.95); }
.btn-ghost, .icon-btn, .btn-back, .menu-item, .btn-dl, .h-dl, .ea-tab, .tab, .btn-google {
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease;
}

/* Input focus glow */
input, textarea { caret-color: var(--primary); }
.search:focus,
.ea-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 91, 240, .16);
}
.search { transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }

/* Custom gliding caret (replaces the native one so it can slide smoothly) */
.caret-mirror {
  position: fixed;
  left: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
  white-space: pre;
}
input.no-native-caret { caret-color: transparent; }
.caret-glow {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, #9a9af8, var(--primary));
  box-shadow: 0 0 8px rgba(91, 91, 240, .75), 0 0 2px rgba(91, 91, 240, .9);
  opacity: 0;
  pointer-events: none;
  z-index: 55;
  transition: transform .18s cubic-bezier(.2, .8, .3, 1), opacity .12s ease;
}
.caret-glow.active { opacity: 1; animation: caret-blink 1.15s ease-in-out infinite; }
@keyframes caret-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Accessibility: focus ring + reduced motion */
button:focus-visible,
input:focus-visible,
.link:focus-visible,
label:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
  }
}