.portal-user-menu {
  position: relative;
}

.portal-user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  transition: background 0.18s var(--ease-out);
}

.portal-user-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
}

.portal-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.portal-user-avatar-fallback {
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(145deg, #007aff, #0064e9);
  color: white;
}

.portal-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(14, 15, 20, 0.96);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  z-index: 40;
}

.portal-user-meta {
  margin: 0 0 10px;
  font-size: 0.78rem;
}

.portal-logout-btn {
  width: 100%;
}

/* ── Portal login — matches tablet hub / iPadOS shell ── */

html:has(.login-page),
body.login-page {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: #07070a;
  color: #fff;
  font-family: var(--font, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif);
  -webkit-font-smoothing: antialiased;
}

body.login-page * {
  box-sizing: border-box;
}

body.login-page button,
body.login-page a {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

.login-screen {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.login-screen .ruby-wallpaper {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(80% 58% at 74% 76%, rgba(0, 148, 184, 0.45) 0%, rgba(0, 44, 70, 0.2) 35%, transparent 64%),
    radial-gradient(75% 78% at 24% 8%, rgba(96, 73, 150, 0.82) 0%, rgba(38, 28, 86, 0.88) 48%, rgba(5, 6, 18, 0.95) 100%),
    linear-gradient(118deg, #080611 0%, #201746 38%, #5a5290 48%, #1b143b 64%, #06111f 100%);
}

.login-screen .ruby-wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 34%, rgba(0, 0, 0, 0.2)),
    radial-gradient(80% 45% at 50% 6%, rgba(255, 255, 255, 0.1), transparent 58%);
}

.login-screen .system-status {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(22px, 3vw, 44px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 12px #000;
}

.login-screen .system-status__right {
  display: flex;
  align-items: center;
  gap: 9px;
}

.login-screen .system-signal {
  height: 13px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.login-screen .system-signal i {
  display: block;
  width: 3px;
  background: currentColor;
  border-radius: 2px;
}

.login-screen .system-signal i:nth-child(1) { height: 4px; }
.login-screen .system-signal i:nth-child(2) { height: 7px; }
.login-screen .system-signal i:nth-child(3) { height: 10px; }
.login-screen .system-signal i:nth-child(4) { height: 13px; }

.login-screen .system-wifi {
  width: 15px;
  height: 11px;
  border-top: 2px solid;
  border-radius: 50%;
  position: relative;
}

.login-screen .system-wifi::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  left: 5px;
  bottom: 0;
}

.login-screen .system-battery {
  width: 24px;
  height: 11px;
  border: 1.5px solid;
  border-radius: 3px;
  padding: 2px;
  position: relative;
}

.login-screen .system-battery::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 3px;
  width: 2px;
  height: 5px;
  background: currentColor;
  border-radius: 0 2px 2px 0;
}

.login-screen .system-battery i {
  display: block;
  width: 82%;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
}

.login-home-indicator {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: 128px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 7px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.login-stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(56px, 8vh, 80px) 20px clamp(40px, 6vh, 56px);
}

.login-panel {
  width: min(380px, 92vw);
  padding: 32px 28px 28px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 12, 18, 0.55);
  backdrop-filter: saturate(140%) blur(32px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-hero-mark {
  margin-bottom: 20px;
}

.login-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #007aff 0%, #0064e9 100%);
  box-shadow:
    0 12px 32px rgba(0, 122, 255, 0.35),
    inset 0 1px rgba(255, 255, 255, 0.25);
}

.login-steps {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 22px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.login-step {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  transition: transform 0.2s ease, background 0.2s ease;
}

.login-step.is-active {
  width: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
}

.login-step.is-done {
  background: rgba(48, 209, 88, 0.85);
}

.login-step-panel {
  display: none;
}

.login-step-panel.is-active {
  display: block;
  animation: loginFadeIn 0.32s var(--ease-out, cubic-bezier(0.2, 0.9, 0.3, 1));
}

@keyframes loginFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-panel h1,
.login-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif);
  letter-spacing: -0.04em;
  font-weight: 700;
}

.login-panel h1 {
  font-size: clamp(1.6rem, 5vw, 1.95rem);
}

.login-panel h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
}

.login-lead {
  margin: 0 0 24px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.55);
}

.login-lead strong {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

.login-actions {
  display: grid;
  gap: 10px;
}

.login-discord-btn,
.login-primary-btn,
.login-secondary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 13px 20px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 0.94rem;
  transition: transform 0.18s var(--ease-out, ease), box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.login-discord-btn {
  color: #fff;
  background: linear-gradient(145deg, #5865f2, #4752c4);
  box-shadow:
    0 12px 32px rgba(88, 101, 242, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.login-discord-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 16px 40px rgba(88, 101, 242, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.login-discord-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.login-discord-icon {
  width: 21px;
  height: 21px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M20.3 4.4A17.2 17.2 0 0 0 15.5 3l-.2.4a15.6 15.6 0 0 0-6.6 0L8.5 3a17.2 17.2 0 0 0-4.8 1.4C1.5 9.2.7 13.9 1.1 18.5l.1.1a17.4 17.4 0 0 0 5.2 2.6l.1-.3a11.8 11.8 0 0 1-1.8-2.8l.5.2a12.5 12.5 0 0 0 10.6 0l.5-.2c-.4.9-1 1.7-1.8 2.8l.1.3a17.4 17.4 0 0 0 5.2-2.6l.1-.1c.8-5.3.1-9.9-2.7-14.1ZM8.7 15.1c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2Zm6.6 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.login-primary-btn {
  color: #fff;
  background: linear-gradient(145deg, #007aff 0%, #0064e9 100%);
  box-shadow: 0 10px 28px rgba(0, 122, 255, 0.28);
}

.login-primary-btn:hover {
  transform: translateY(-1px);
}

.login-primary-btn--link {
  text-decoration: none;
  margin-top: 4px;
}

.login-secondary-btn {
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  min-height: 40px;
  font-size: 0.82rem;
  font-weight: 600;
}

.login-secondary-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

.login-local-wrap {
  margin: 0;
}

.login-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.login-preset {
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.login-preset:hover {
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.login-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  text-align: left;
  color: #fecdd3;
  background: rgba(255, 69, 58, 0.12);
  border: 1px solid rgba(255, 69, 58, 0.28);
}

.login-hint {
  margin: 10px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.42);
}

.login-hint code {
  font-size: 0.72rem;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.login-hint--warn {
  color: rgba(255, 214, 10, 0.88);
}

.login-text-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 6px 0;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.38);
}

.login-text-btn:hover {
  color: rgba(255, 255, 255, 0.65);
}

.character-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 8px;
  text-align: left;
}

.character-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 14px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.character-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.character-avatar {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(0, 122, 255, 0.4), rgba(88, 86, 214, 0.3));
}

.character-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.character-meta strong {
  font-size: 0.88rem;
  font-weight: 650;
}

.character-meta .muted,
.character-last {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
}

.character-chevron {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.32);
}

@media (max-width: 420px) {
  .login-panel {
    padding: 28px 22px 24px;
  }
}
