:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #65717f;
  --line: #d8dee7;
  --accent: #1976d2;
  --accent-strong: #0f5cad;
  --ok: #16845b;
  --offline: #8b95a1;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.portal-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.login-view,
.desktop-success-view {
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(42px, 13vh, 112px);
  text-align: center;
}

.app-icon {
  width: clamp(82px, 22vw, 118px);
  height: clamp(82px, 22vw, 118px);
  display: block;
  border-radius: 24px;
  object-fit: contain;
  filter: drop-shadow(0 18px 36px rgba(23, 32, 42, 0.18));
}

.app-icon-small {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  filter: none;
}

.login-view h1,
.desktop-success-view h1 {
  margin: 20px 0 6px;
  font-size: clamp(42px, 9vw, 58px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
}

.servers-view h1 {
  margin: 18px 0 6px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.login-view p,
.desktop-success-view p,
.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.success-message {
  width: min(100%, 420px);
  margin-top: 34px;
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

.success-message h2 {
  margin: 0 0 8px;
  color: var(--ok);
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.success-message p {
  font-size: 17px;
}

.apple-button,
.provider-button,
.primary-button,
.ghost-button,
.server-button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.login-buttons {
  width: min(100%, 340px);
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.provider-button,
.primary-button {
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 650;
}

.provider-button {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.primary-button {
  background: #050505;
  color: #ffffff;
}

.provider-button:disabled,
.primary-button:disabled {
  opacity: 0.65;
  cursor: default;
}

.provider-icon {
  justify-self: center;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.provider-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.apple-icon {
  color: #050505;
}

.apple-button {
  background: var(--panel);
  color: var(--text);
}

.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.email-form {
  display: grid;
  gap: 12px;
}

.email-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.error-text {
  min-height: 22px;
  margin-top: 14px;
  color: var(--danger);
}

.servers-view {
  padding-top: 2px;
}

.servers-header {
  display: grid;
  gap: 24px;
  padding: 4px 0 22px;
}

.compact-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 750;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin-top: 0;
}

.ghost-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}

.status-message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.server-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.server-button {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: 0 1px 2px rgba(23, 32, 42, 0.05);
}

.server-button:not(:disabled):hover {
  border-color: #b8c5d5;
}

.server-button:disabled {
  cursor: default;
  color: var(--offline);
  background: #f9fafb;
}

.server-name {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.server-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.server-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
}

.server-state::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.server-button:disabled .server-state {
  color: var(--offline);
}

@media (max-width: 520px) {
  .portal-shell {
    padding: max(12px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  }

  .login-view {
    min-height: calc(100vh - 30px);
    padding-top: clamp(28px, 8vh, 70px);
  }

  .brand-mark {
    width: 68px;
    height: 68px;
    border-radius: 18px;
  }

  .login-view h1 {
    margin-top: 16px;
    font-size: 28px;
  }

  .login-buttons {
    margin-top: 24px;
  }

  .topbar {
    align-items: flex-start;
  }

  .server-button {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
