:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: #0e141e;
  --panel-2: #121a26;
  --panel-3: #172130;
  --line: #222d3c;
  --line-bright: #344156;
  --text: #eef2f8;
  --muted: #8e99ab;
  --faint: #616d7e;
  --violet: #7c70e8;
  --violet-soft: #9a90ff;
  --violet-dark: #5548bb;
  --green: #48d5a4;
  --danger: #ef6474;
  --shadow: 0 28px 90px rgb(0 0 0 / 45%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button, input, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { margin: 4px 0 0; color: var(--faint); font-size: 12px; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .16;
  pointer-events: none;
}
.ambient-one { top: -230px; left: 14%; background: #765ce8; }
.ambient-two { right: -260px; bottom: -260px; background: #2a8a96; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
}
.brand > span:last-child { display: grid; }
.brand strong { font-size: 20px; letter-spacing: -.03em; }
.brand small { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--violet-soft), var(--violet-dark));
  box-shadow: 0 13px 32px rgb(87 73 194 / 38%);
  color: white;
  font-weight: 900;
  text-decoration: none;
}
.brand-large .brand-mark { width: 49px; height: 49px; }

.eyebrow {
  color: #8b81ef;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}

.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(460px, .88fr);
}
.auth-story {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px clamp(42px, 6vw, 96px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgb(8 12 19 / 94%), rgb(9 13 20 / 63%)),
    radial-gradient(circle at 72% 28%, rgb(116 94 218 / 30%), transparent 38%),
    linear-gradient(135deg, #101824, #080c13 70%);
  border-right: 1px solid var(--line);
}
.auth-story::after {
  content: "";
  position: absolute;
  right: -110px;
  bottom: 10%;
  width: 480px;
  height: 480px;
  border: 1px solid rgb(137 125 245 / 18%);
  border-radius: 50%;
  box-shadow: 0 0 0 60px rgb(123 109 233 / 4%), 0 0 0 150px rgb(123 109 233 / 3%);
}
.story-copy { position: relative; z-index: 1; max-width: 670px; padding: 72px 0 40px; }
.story-copy h1 {
  margin: 19px 0 24px;
  font-size: clamp(48px, 5.2vw, 80px);
  line-height: .98;
  letter-spacing: -.055em;
}
.story-copy h1 em { color: #8d82f2; font-style: normal; }
.story-copy p { max-width: 590px; margin: 0; color: #9aa6b9; font-size: 17px; line-height: 1.72; }
.trust-row { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 24px; color: var(--faint); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
.trust-row span { display: inline-flex; align-items: center; gap: 8px; }
.trust-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 12px var(--violet); }

.auth-panel {
  display: grid;
  place-items: center;
  padding: 34px clamp(28px, 5vw, 80px);
  background: linear-gradient(180deg, #0b111a, #090e16);
}
.mobile-brand { display: none; }
.auth-card { width: min(450px, 100%); }
.auth-card h2 { margin: 9px 0 9px; font-size: 34px; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 30px; font-size: 14px; line-height: 1.6; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 26px; border: 1px solid var(--line); border-radius: 13px; background: #0a1018; }
.segment { min-height: 41px; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 800; }
.segment.active { background: #192231; color: white; box-shadow: 0 5px 16px rgb(0 0 0 / 30%); }
.field-label { display: block; margin-bottom: 8px; color: #cbd2de; font-size: 12px; font-weight: 800; }
.input-shell { display: grid; grid-template-columns: 44px 1fr; align-items: center; min-height: 55px; border: 1px solid var(--line-bright); border-radius: 13px; background: #0b111a; transition: border-color .2s, box-shadow .2s; }
.input-shell:focus-within { border-color: var(--violet); box-shadow: 0 0 0 3px rgb(124 112 232 / 12%); }
.input-shell > span { color: #7970da; text-align: center; font-weight: 800; }
.input-shell input { min-width: 0; height: 53px; border: 0; outline: 0; background: transparent; }
input::placeholder, textarea::placeholder { color: #505b6b; }
.form-message { min-height: 20px; margin: 7px 0; font-size: 12px; line-height: 1.45; }
.error { color: #ff8e9a; }

.button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  transition: transform .16s, filter .16s, opacity .16s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .58; }
.button.primary { background: linear-gradient(135deg, #8275ed, #6255ca); box-shadow: 0 14px 34px rgb(87 74 198 / 30%); color: white; }
.button.store { margin-top: 10px; border: 1px solid var(--line-bright); background: #1a2432; }
.button.danger { margin-top: 22px; background: #42202a; color: #ffc0c8; }
.wide { width: 100%; }
.text-button { padding: 5px; background: transparent; color: #958bf2; cursor: pointer; font-size: 12px; font-weight: 800; }
.text-button:disabled { color: var(--faint); cursor: default; }
.centered { display: block; margin: 14px auto 0; }
.danger-text { color: var(--danger); }
.code-header { display: flex; align-items: start; justify-content: space-between; }
.otp-input { width: 100%; height: 62px; padding: 0 18px; border: 1px solid var(--line-bright); border-radius: 13px; outline: 0; background: #0b111a; font-size: 27px; font-weight: 850; letter-spacing: .42em; text-align: center; }
.otp-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgb(124 112 232 / 12%); }
.security-note { display: flex; gap: 12px; align-items: center; margin-top: 26px; padding: 15px; border: 1px solid #232d3c; border-radius: 12px; background: #0c131d; color: #857bea; }
.security-note p { display: grid; gap: 2px; margin: 0; }
.security-note strong { color: #bdc5d1; font-size: 11px; }
.security-note small { color: var(--faint); font-size: 10px; line-height: 1.5; }

.workspace { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 76px 360px minmax(0, 1fr); background: var(--bg); }
.rail { min-height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 26px; padding: 22px 12px; border-right: 1px solid var(--line); background: #090e15; }
.rail-logo { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 13px; }
.rail-actions { display: grid; gap: 12px; margin-top: 22px; }
.rail-button, .icon-button, .avatar-button { display: inline-grid; place-items: center; cursor: pointer; }
.rail-button { position: relative; width: 42px; height: 42px; border-radius: 12px; background: transparent; color: #748094; font-size: 19px; }
.rail-button.active { background: #211f3d; color: #a99fff; }
.rail-button:hover { background: #171f2b; color: white; }
.avatar-button { width: 38px; height: 38px; margin-top: auto; border: 1px solid #3c4660; border-radius: 50%; background: #1d2736; color: #beb6ff; font-size: 11px; font-weight: 900; }

.conversation-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0d131c; }
.pane-header { display: flex; align-items: center; justify-content: space-between; padding: 26px 25px 16px; }
.pane-header h2, .chat-header h2 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.035em; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: #111923; color: #aab4c4; }
.icon-button:hover { border-color: var(--line-bright); color: white; }
.search-field { display: grid; grid-template-columns: 35px 1fr; align-items: center; margin: 3px 20px 13px; border: 1px solid #242f3f; border-radius: 11px; background: #0a1017; color: var(--faint); }
.search-field > span { text-align: center; }
.search-field input { height: 42px; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; }
.filter-row { display: flex; gap: 7px; padding: 0 20px 14px; }
.filter { padding: 7px 11px; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; font-size: 10px; font-weight: 850; }
.filter.active { background: #252243; color: #a99eff; }
.conversation-list { min-height: 0; flex: 1; overflow-y: auto; padding: 0 12px; }
.conversation { width: 100%; display: grid; grid-template-columns: 45px 1fr; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: #171d2b; cursor: pointer; text-align: left; }
.conversation:hover { background: #1b2331; }
.conversation-avatar { position: relative; display: inline-grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #2f3851, #1a2230); color: #d0cbff; font-size: 13px; font-weight: 900; }
.conversation-avatar.large { width: 44px; height: 44px; }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #121a25; border-radius: 50%; background: var(--green); }
.conversation-copy { min-width: 0; display: grid; gap: 5px; }
.conversation-copy > span { display: flex; justify-content: space-between; gap: 8px; }
.conversation-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy time { color: var(--faint); font-size: 9px; }
.conversation-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { min-height: 300px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 30px; color: var(--faint); text-align: center; }
.empty-list > span { font-size: 30px; color: #6d63ca; }
.empty-list strong { color: #a7b0be; font-size: 12px; }
.empty-list p { max-width: 230px; margin: 0; font-size: 10px; line-height: 1.55; }
.operator-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); background: #0a1018; }
.operator-footer small { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.operator-state { display: inline-flex; align-items: center; gap: 7px; color: #aab4c2; font-size: 10px; font-weight: 800; }
.operator-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgb(72 213 164 / 60%); }

.chat-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(circle at 80% -20%, rgb(87 72 185 / 10%), transparent 35%), #0b1018; }
.chat-header { height: 77px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgb(11 16 24 / 85%); backdrop-filter: blur(14px); }
.chat-person { display: flex; align-items: center; gap: 12px; }
.mobile-back { display: none; }
.chat-person h2 { font-size: 14px; }
.chat-person p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.encryption-pill { padding: 8px 11px; border: 1px solid #33305c; border-radius: 999px; background: #18162e; color: #9990f0; font-size: 9px; font-weight: 850; letter-spacing: .05em; }
.chat-empty { flex: 1; display: grid; place-items: center; align-content: center; padding: 30px; text-align: center; }
.chat-empty h2 { margin: 10px 0 8px; font-size: 24px; }
.chat-empty p { max-width: 460px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.empty-orbit { width: 110px; height: 110px; display: grid; place-items: center; margin-bottom: 25px; border: 1px solid #292a4b; border-radius: 50%; box-shadow: 0 0 0 18px rgb(101 88 206 / 4%), 0 0 70px rgb(87 72 185 / 18%); }
.empty-orbit span { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 17px; background: linear-gradient(145deg, #8d82ee, #5549bd); font-weight: 900; }
.compose-view { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.handoff-banner { display: flex; align-items: center; gap: 11px; padding: 11px 22px; border-bottom: 1px solid #29264d; background: #151429; color: #988ff2; }
.handoff-banner p { display: grid; gap: 2px; margin: 0; }
.handoff-banner strong { font-size: 10px; }
.handoff-banner small { color: #7e789d; font-size: 9px; }
.message-stage { min-height: 0; flex: 1; overflow-y: auto; padding: 28px clamp(24px, 6vw, 86px); }
.date-divider { display: flex; align-items: center; gap: 13px; color: var(--faint); font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.date-divider::before, .date-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.incoming-card { max-width: 680px; display: grid; grid-template-columns: 42px 1fr; gap: 12px; margin-top: 34px; }
.incoming-card > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px 14px 14px; background: #151d28; box-shadow: 0 12px 34px rgb(0 0 0 / 12%); }
.incoming-card p { margin: 9px 0; color: #d6dbe4; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.incoming-card small { color: var(--faint); font-size: 9px; }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.message-meta strong { color: #a99fff; font-size: 10px; }
.message-meta time { color: var(--faint); font-size: 8px; }
.composer-wrap { flex: 0 0 auto; padding: 15px clamp(24px, 6vw, 86px) max(17px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0a0f16; }
.composer-wrap > label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; font-weight: 800; }
.composer { display: grid; grid-template-columns: 1fr 44px; gap: 9px; align-items: end; padding: 8px; border: 1px solid var(--line-bright); border-radius: 14px; background: #111923; }
.composer:focus-within { border-color: #5f56bb; }
.composer textarea { width: 100%; min-height: 42px; max-height: 140px; resize: vertical; padding: 11px; border: 0; outline: 0; background: transparent; font-size: 12px; line-height: 1.5; }
.send-button { width: 42px; height: 42px; border-radius: 11px; background: linear-gradient(145deg, #8275ec, #5d51c3); cursor: pointer; font-size: 19px; box-shadow: 0 9px 22px rgb(83 70 184 / 30%); }
.composer-note { display: flex; justify-content: space-between; margin-top: 7px; color: var(--faint); font-size: 8px; }
.mobile-tabs { display: none; }

.modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 20px; border: 0; background: rgb(4 7 11 / 82%); backdrop-filter: blur(14px); }
.modal[open] { display: grid; place-items: center; }
.modal::backdrop { background: transparent; }
.modal-card { width: min(460px, 100%); padding: 30px; border: 1px solid #3c4660; border-radius: 24px; background: linear-gradient(150deg, #17202c, #0e151f); box-shadow: var(--shadow); text-align: center; }
.install-card { border: 2px solid #7469dc; box-shadow: var(--shadow), 0 0 0 7px rgb(114 102 221 / 8%); }
.modal-badge { display: inline-flex; padding: 7px 10px; border-radius: 999px; background: #6559c9; font-size: 9px; font-weight: 900; letter-spacing: .11em; }
.modal-logo { width: 62px; height: 62px; margin: 19px auto; border-radius: 18px; font-size: 23px; }
.modal-card h2 { margin: 0 0 9px; font-size: 27px; letter-spacing: -.04em; }
.modal-card > p { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal-card > small { display: block; margin-top: 18px; color: var(--faint); font-size: 9px; line-height: 1.5; }
.settings-card { text-align: left; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.modal-heading h2 { margin-top: 6px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-top: 1px solid var(--line); }
.setting-row > span:first-child { display: grid; gap: 3px; }
.setting-row strong { font-size: 11px; }
.setting-row small { color: var(--faint); font-size: 9px; }
.ok-badge, .pending-badge { padding: 5px 7px; border-radius: 6px; font-size: 8px; font-weight: 900; }
.ok-badge { background: rgb(72 213 164 / 12%); color: var(--green); }
.pending-badge { background: rgb(124 112 232 / 12%); color: #9d94f1; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; max-width: min(420px, calc(100% - 32px)); padding: 12px 16px; border: 1px solid var(--line-bright); border-radius: 11px; background: #18212d; box-shadow: 0 14px 40px rgb(0 0 0 / 40%); color: #d7dde7; font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 940px) {
  .auth-view { grid-template-columns: 1fr minmax(400px, .95fr); }
  .auth-story { padding: 38px; }
  .trust-row { gap: 13px; }
  .workspace { grid-template-columns: 68px 320px minmax(0, 1fr); }
  .encryption-pill { display: none; }
}

@media (max-width: 760px) {
  .ambient { width: 340px; height: 340px; }
  .auth-view { display: block; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 0, rgb(104 85 208 / 18%), transparent 34%), #090e16; }
  .auth-story { display: none; }
  .auth-panel { display: block; padding: 0; background: transparent; }
  .mobile-brand { display: inline-flex; margin-bottom: 45px; }
  .auth-card { width: 100%; }
  .auth-card h2 { font-size: 31px; }
  .auth-card > p { margin-bottom: 25px; }

  .workspace { min-height: 100dvh; display: block; padding-bottom: 70px; }
  .rail { display: none; }
  .conversation-pane { min-height: calc(100dvh - 70px); border: 0; }
  .chat-pane { display: none; min-height: calc(100dvh - 70px); }
  .workspace.chat-open .conversation-pane { display: none; }
  .workspace.chat-open .chat-pane { display: flex; }
  .pane-header { padding-top: max(22px, env(safe-area-inset-top)); }
  .conversation-list { padding-bottom: 20px; }
  .operator-footer { display: none; }
  .mobile-tabs { position: fixed; z-index: 9; right: 0; bottom: 0; left: 0; height: calc(66px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 6px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgb(9 14 21 / 96%); backdrop-filter: blur(16px); }
  .mobile-tabs button { display: grid; place-items: center; gap: 2px; background: transparent; color: var(--faint); font-size: 8px; font-weight: 800; }
  .mobile-tabs button span { font-size: 17px; }
  .mobile-tabs button.active { color: #9d94f1; }
  .chat-header { height: 68px; padding: max(8px, env(safe-area-inset-top)) 15px 8px; }
  .mobile-back { display: inline-grid; flex: 0 0 auto; }
  .chat-person { min-width: 0; flex: 1; }
  .chat-person > div { min-width: 0; }
  .chat-person h2, .chat-person p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions .icon-button { width: 35px; height: 35px; }
  .handoff-banner { padding: 9px 14px; }
  .handoff-banner small { line-height: 1.4; }
  .message-stage { padding: 22px 15px; }
  .composer-wrap { padding: 12px 12px max(13px, env(safe-area-inset-bottom)); }
  .modal { padding: 14px; }
  .modal-card { padding: 27px 20px; border-radius: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
