:root {
  color-scheme: dark;
  --bg: #07080b;
  --content: #1c1c1e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --muted: rgba(235, 235, 245, 0.6);
  --accent: #0a84ff;
  --lg-veil-rgb: 255 255 255;
  --lg-veil-a: 0.1;
  --lg-bright: 0.92;
  --lg-specular: 0.28;
  --lg-rim: 0.16;
  --lg-shadow-a: 0.4;
  --lg-fg: rgb(255 255 255 / 0.94);
  --lg-solid-rgb: 28 28 30;
  --bg-primary: rgb(7 8 11);
  --bg-secondary: rgb(28 28 30);
  --bg-tertiary: rgb(44 44 46);
  --label: rgb(255 255 255 / 0.94);
  --label-secondary: rgb(255 255 255 / 0.62);
  --separator: rgb(255 255 255 / 0.12);
  --fill: rgb(120 120 128 / 0.36);
  --fill-secondary: rgb(120 120 128 / 0.32);
  --fill-tertiary: rgb(118 118 128 / 0.24);
  --accent-dark-rgb: 10 132 255;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
html, body { margin: 0; height: 100%; background:
  radial-gradient(640px 920px at 36px -80px, rgba(214, 224, 236, 0.34), transparent 62%),
  radial-gradient(900px 640px at 88% 120%, rgba(46, 58, 78, 0.55), transparent 58%),
  var(--bg);
  color: var(--text); }
body, #shell-view {
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  --lg-radius: 22px;
  width: min(420px, 100%);
  padding: 28px;
}
.tg-login {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: #2aabee;
  color: #fff;
  font-weight: 600;
}
.gate-card h1 { margin: 14px 0 8px; font-size: 22px; }
.gate-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(10, 132, 255, 0.15);
  color: #4da3ff;
  font-weight: 600;
}

#shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}
#shell.rail-open { grid-template-columns: 232px minmax(0, 1fr); }
.rail {
  --lg-radius: 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.rail, .rail button { font-size: 14px; font-family: inherit; }
.rail svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
#shell.rail-open .rail-brand { justify-content: flex-start; }
.rail-kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.rail-title { font-weight: 600; }
.rail-label { min-width: 0; display: none; }
#shell.rail-open .rail-label { display: block; }
.rail nav { display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.rail nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  height: 44px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 0;
}
#shell.rail-open .rail nav button { justify-content: flex-start; padding: 0 10px; }
.rail nav button span { display: none; white-space: nowrap; }
#shell.rail-open .rail nav button span { display: inline; }
.rail nav button:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.rail nav button.active { background: rgba(10, 132, 255, 0.28); color: white; }
#rail-toggle {
  margin: 4px 10px 0;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
#rail-toggle:hover { background: #1c1c21; color: var(--text); }
#shell.rail-open .chev { transform: rotate(180deg); }
.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
#nav-people {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 0;
}
#shell.rail-open #nav-people { justify-content: flex-start; padding: 0 10px; }
#nav-people span { display: none; white-space: nowrap; }
#shell.rail-open #nav-people span { display: inline; }
#nav-people.active, #nav-people:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.rail-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
#shell.rail-open .rail-user { flex-direction: row; justify-content: flex-start; padding: 12px; }
.rail-user img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.text-btn {
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: 12px;
}
.text-btn span { display: none; }
#shell.rail-open .text-btn span { display: inline; }
.grant {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.grant input {
  flex: 1;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #141418;
  padding: 0 12px;
}
.grant button, .invite-remove {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
}
.invite-remove, .user-delete { height: 30px; background: #1c1c21; color: var(--muted); }
.access-actions { display: flex; gap: 8px; align-items: center; }
.user-delete:hover { color: #e7a3a3; }
#shell-view {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: var(--content);
  box-shadow: none;
  backdrop-filter: none;
}
#shell-view.shell-pending { visibility: hidden; }
#shell-view > * { height: 100%; min-height: 0; }
#shell-view #app { height: 100%; }
#shell-view .px-4.pt-4 { display: none; }

.locked, .people {
  height: 100%;
  overflow: auto;
  padding: 28px;
}
.locked { max-width: 560px; }
.locked h2, .people h2 { margin: 0 0 8px; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.muted { color: var(--muted); line-height: 1.45; }
.people table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--fill);
  border: 0;
  border-radius: 12px;
  overflow: hidden;
}
.people th, .people td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.people th { color: var(--muted); font-size: 12px; font-weight: 600; }
.people tr:last-child td { border-bottom: 0; }
.history { max-width: none; }
.grant input, .switch {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.switch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 12px;
}
.switch.on { background: rgba(10, 132, 255, 0.35); border-color: rgba(10, 132, 255, 0.8); }
@media (prefers-reduced-transparency: reduce) {
  .rail, .gate-card { background: #2c2c2e; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

:root { --shell-tab: 0px; }
html, body { max-width: 100%; overflow-x: hidden; }

@media (max-width: 760px) {
  :root { --shell-tab: calc(62px + env(safe-area-inset-bottom, 0px)); }
  input, select, textarea { font-size: 16px; }
  html, body { height: 100%; }
  #shell, #shell.rail-open {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
  }
  #shell-view {
    order: 1;
    flex: 1;
    width: 100%;
    min-height: 0;
    border-radius: 0;
  }
  .rail {
    --lg-radius: 0px;
    order: 2;
    flex-direction: row;
    align-items: stretch;
    height: var(--shell-tab);
    min-height: var(--shell-tab);
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    z-index: 80;
    overflow: hidden;
  }
  .rail-brand, #rail-toggle { display: none; }
  .rail nav {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 4px 2px;
    min-width: 0;
  }
  .rail nav button, #nav-people {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    height: auto;
    min-height: 0;
    padding: 4px 1px;
    border-radius: 12px;
  }
  #shell.rail-open .rail nav button,
  #shell.rail-open #nav-people { justify-content: center; padding: 4px 1px; }
  .rail nav button span, #nav-people span {
    display: block !important;
    font-size: 9px;
    line-height: 1.05;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .rail-foot {
    flex: none;
    flex-direction: row;
    align-items: center;
    margin: 0;
    gap: 2px;
    padding: 4px 4px 4px 2px;
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
  }
  .rail-foot #nav-people { flex: 0 0 52px; }
  #nav-people[hidden] { display: none !important; }
  .rail-user {
    flex-direction: row;
    gap: 0;
    padding: 0;
  }
  #shell.rail-open .rail-user { padding: 0; }
  #user-name, .rail-user img, #logout span { display: none !important; }
  #logout {
    width: 40px;
    height: 40px;
    justify-content: center;
    border-radius: 12px;
  }
  .locked, .people { padding: 16px 14px 24px; }
  .grant { flex-direction: column; }
  .grant button, .grant input { width: 100%; }
  .people table, .people tbody, .people tr, .people td { display: block; width: 100%; }
  .people thead { display: none; }
  .people table { background: transparent; border-radius: 0; }
  .people tr {
    margin: 0 0 10px;
    padding: 6px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
  }
  .people td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 0;
    text-align: right;
  }
  .people td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    flex: none;
  }
  .people td.empty-row { display: block; text-align: left; }
  .people td.empty-row::before { content: none; }
  .access-actions { justify-content: flex-end; }
}

#toasts {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: calc(var(--shell-tab, 0px) + 16px);
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border-radius: 16px;
  background: #2c2c2e;
  color: #f5f5f7;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 3px 0 0 #0a84ff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: none; }
.toast p {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.toast-close {
  width: 28px;
  height: 28px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(235, 235, 245, 0.6);
  font-size: 18px;
  line-height: 1;
}
.toast-close:hover { background: rgba(255, 255, 255, 0.08); color: #f5f5f7; }
.toast-ok { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 3px 0 0 #30d158; }
.toast-error { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 3px 0 0 #ff453a; }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: none; }
}
