:root {
  color-scheme: dark;
  --bg: #08090d;
  --card: rgba(17, 19, 26, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e9ecf4;
  --muted: #8b93a5;
  --accent: #ff8a1f;
  --accent-soft: #ffd166;
  --ok: #3ddc97;
  --err: #ff6b6b;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
}

.glow-one {
  width: 520px;
  height: 520px;
  top: -220px;
  left: -120px;
  background: #ff7a18;
}

.glow-two {
  width: 480px;
  height: 480px;
  right: -180px;
  bottom: -200px;
  background: #5b2bff;
  opacity: 0.28;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(420px, 100%);
  padding: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #ff7a18, #ffd166);
  color: #1a1206;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.login-card h1 {
  margin: 26px 0 6px;
  font-size: 23px;
  line-height: 1.2;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: #6e7688;
}

input:focus {
  border-color: rgba(255, 138, 31, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 138, 31, 0.14);
}

button {
  font: inherit;
  cursor: pointer;
}

#login-button,
#send-button {
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, #ff7a18, #ffd166);
  color: #1a1206;
  font-weight: 700;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

#login-button:hover,
#send-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none !important;
}

.login-note {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--err);
}

.login-note.ok {
  color: var(--ok);
}

.footnote {
  margin: 18px 0 0;
  font-size: 12px;
  color: #6e7688;
}

.app-wrap {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 22px 18px 32px;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-email {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.ghost {
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.ghost:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.app-card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  min-height: min(72vh, 720px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 19px;
}

.panel-sub {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-sub strong {
  color: var(--text);
}

.bridge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.bridge-online {
  color: var(--ok);
  border-color: rgba(61, 220, 151, 0.35);
  background: rgba(61, 220, 151, 0.08);
}

.bridge-offline {
  color: var(--err);
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.07);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 14px;
}

.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.tab[aria-pressed="true"] {
  color: #1a1206;
  background: linear-gradient(135deg, #ff7a18, #ffd166);
  border-color: transparent;
}

.chat {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: 48vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 4px 10px;
  scrollbar-width: thin;
  scrollbar-color: #333a4a transparent;
}

.empty {
  margin: auto;
  max-width: 320px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.message {
  max-width: min(78%, 620px);
  padding: 9px 12px 10px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.035);
}

.message-in {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-out {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: rgba(255, 138, 31, 0.09);
  border-color: rgba(255, 138, 31, 0.28);
}

.message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.message-author {
  font-weight: 700;
  color: #cfd5e2;
}

.message-out .message-author {
  color: var(--accent-soft);
}

.message-time {
  font-variant-numeric: tabular-nums;
}

.message-text {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

.badge-pending,
.badge-sending {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.3);
}

.badge-sent {
  color: var(--ok);
  border-color: rgba(61, 220, 151, 0.3);
}

.badge-failed {
  color: var(--err);
  border-color: rgba(255, 107, 107, 0.4);
}

.composer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.chip {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: #b9c0d0;
  font-size: 12px;
  text-align: left;
}

.chip:hover {
  border-color: rgba(255, 138, 31, 0.45);
  color: var(--text);
}

.send-row {
  display: flex;
  gap: 9px;
}

#send-button {
  width: auto;
  margin: 0;
  padding: 0 22px;
  flex: 0 0 auto;
}

.hint {
  margin: 9px 0 0;
  font-size: 11.5px;
  color: #6e7688;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9aa3b5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 11px 16px;
  border-radius: 10px;
  background: #1c202b;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.45);
}

@media (max-width: 640px) {
  .app-wrap {
    padding: 14px 10px 20px;
  }

  .app-card {
    padding: 16px;
    min-height: calc(100vh - 96px);
  }

  .topbar {
    padding-bottom: 12px;
  }

  .user-email {
    display: none;
  }

  .panel-head {
    flex-direction: column;
  }

  .chat {
    max-height: none;
    flex: 1 1 auto;
    min-height: 240px;
  }

  .message {
    max-width: 88%;
  }

  #send-button {
    padding: 0 16px;
  }

  .login-card {
    padding: 24px;
  }
}
