@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --void: #02010a;
  --bg: #060414;
  --nebula-1: #150b2e;
  --nebula-2: #241348;
  --panel: rgba(8, 7, 24, 0.97);
  --border: rgba(167, 230, 255, 0.08);
  --text: #c2e7ff;
  --text-secondary: #8fa3bd;
  --cyan: #a7e6ff;
  --violet: #c9b6ff;
  --gold: #c89632;
  --gold-2: #e6b24a;
  --molten: linear-gradient(135deg, #c89632 0%, #ffb347 45%, #ff7a18 100%);
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--void);
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, var(--nebula-2) 0%, transparent 55%),
    radial-gradient(ellipse 100% 50% at 90% 100%, var(--nebula-1) 0%, transparent 60%),
    var(--bg);
  overflow: hidden;
}

#app {
  position: relative;
  height: 100dvh;
  width: 100vw;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  animation: fade-in 0.25s ease-out;
}
.screen.active {
  display: flex;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3, .mono {
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

/* ---------- Logo mark ---------- */
.logo-mark {
  display: block;
}

/* ---------- Onboarding ---------- */
.onboard {
  align-items: center;
  justify-content: space-between;
  padding: 32px 24px calc(24px + var(--safe-bottom));
  text-align: center;
}

.onboard-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  flex: 1;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.slide {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.slide.active {
  display: flex;
}

.slide h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--cyan);
}

.slide p {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  max-width: 320px;
}

.dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s ease, transform 0.2s ease;
}
.dot.active {
  background: var(--gold-2);
  transform: scale(1.2);
}

.onboard-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.signup-form {
  display: none;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.signup-form.active {
  display: flex;
}

.field {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
}
.field::placeholder {
  color: var(--text-secondary);
}
.field:focus {
  border-color: var(--cyan);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.btn-primary {
  background: var(--molten);
  color: var(--void);
}
.btn-primary:active {
  filter: brightness(0.92);
}
.btn-primary:disabled {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:active {
  background: rgba(255, 255, 255, 0.03);
}
.btn-danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.35);
}
.btn-danger:active {
  background: rgba(255, 107, 107, 0.08);
}

.link-row {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.link-row a, .link-btn {
  color: var(--cyan);
  text-decoration: none;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.error-note {
  font-size: 13px;
  color: #ff9f6b;
  text-align: center;
  min-height: 18px;
}

/* ---------- Chat ---------- */
.chat {
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active {
  color: var(--cyan);
}

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 84%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: fade-in 0.2s ease-out;
}
.msg.user {
  align-self: flex-end;
  background: var(--molten);
  color: var(--void);
  border-bottom-right-radius: 4px;
}
.msg.twin {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-mono);
}

.sources-strip {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--violet);
  letter-spacing: 0.02em;
}

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.4;
  animation: pulse-dot 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 110px;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
  line-height: 1.3;
}
.composer textarea:focus {
  border-color: var(--cyan);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--molten);
  color: var(--void);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:active {
  filter: brightness(0.92);
}
.send-btn:disabled {
  opacity: 0.4;
}

.banner {
  margin: 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 159, 107, 0.3);
  background: rgba(255, 159, 107, 0.06);
  color: #ff9f6b;
  font-size: 13px;
  display: none;
  flex-shrink: 0;
}
.banner.show {
  display: block;
}

/* ---------- Settings ---------- */
.settings {
  height: 100%;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.toggle-row-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toggle-row-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.toggle-row-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + .switch-track {
  background: rgba(200, 150, 50, 0.35);
  border-color: var(--gold-2);
}
.switch input:checked + .switch-track::before {
  transform: translateX(20px);
  background: var(--gold-2);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.version-note {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
  padding-top: 4px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 85vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Bring your history ---------- */
.import {
  height: 100%;
  padding: 0 0 calc(18px + var(--safe-bottom));
}

.import-body {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 36px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.import-body h2 {
  margin: 0;
  font-size: 22px;
  color: var(--text);
}
.import-why {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.import-why em {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}

.import-pick {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.import-pick.hidden {
  display: none;
}

.import-howto {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.import-howto strong {
  color: var(--text);
  font-weight: 600;
}
.import-howto code {
  font-family: var(--font-mono);
  color: var(--cyan);
}

.import-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  border-radius: 12px;
  border: 1.5px dashed rgba(200, 150, 50, 0.45);
  background: var(--panel);
  cursor: pointer;
  text-align: center;
}
.import-drop:active {
  background: rgba(200, 150, 50, 0.06);
}
.import-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.import-drop-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: #ffb347;
}
.import-drop-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

.import-paste-wrap {
  display: none;
  flex-direction: column;
  gap: 10px;
}
.import-paste-wrap.active {
  display: flex;
}
.import-paste-wrap textarea {
  resize: vertical;
  line-height: 1.45;
}
.import-pick > .link-btn {
  align-self: center;
}

.import-progress {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.import-progress.active {
  display: flex;
}
.import-progress-text {
  font-size: 14px;
  color: var(--text);
}
.bar {
  position: relative;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(167, 230, 255, 0.08);
}
.bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  border-radius: 2px;
  background: var(--molten);
  animation: bar-slide 1.3s ease-in-out infinite;
}
@keyframes bar-slide {
  from { left: -35%; }
  to { left: 100%; }
}

.import-bottom {
  text-align: center;
  padding-top: 8px;
}

.import-card {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 20px 18px;
  border-radius: 14px;
  border: 1px solid rgba(200, 150, 50, 0.3);
  background: var(--panel);
}
.import-card.active {
  display: flex;
}
.vp-count {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
}
.vp-count span {
  font-size: 30px;
  font-weight: 600;
  background: var(--molten);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-right: 4px;
}
.vp-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: -6px;
}
.vp-sub {
  font-size: 12px;
  color: var(--text-secondary);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -4px;
}
.chip {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(167, 230, 255, 0.18);
  color: var(--cyan);
}
.tells {
  margin: 4px 0 6px;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

/* ---------- Plan card (Settings) ---------- */
.plan-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.plan-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}
.plan-status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #ff9f6b;
}
.plan-usage {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.plan-bar span {
  left: 0;
  animation: none;
  transition: width 0.4s ease;
}
.plan-tiers {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.plan-tiers li.current {
  color: var(--cyan);
}
.plan-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-actions .hidden {
  display: none;
}
.plan-note {
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 18px;
  margin: 0;
}
.plan-note[data-state="err"] {
  color: #ff9f6b;
}
.msg.system .link-btn {
  display: block;
  margin-top: 6px;
  text-decoration: underline;
}

/* ---------- Signing back in (plan 2026-10-04_evoeon_sign_back_in.md P2) ---------- */
.signin-why {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.code-field {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.code-field::placeholder {
  text-transform: none;
  letter-spacing: 0.04em;
}

.recovery {
  height: 100%;
  padding: 0 0 calc(18px + var(--safe-bottom));
}
.recovery-body {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 36px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.recovery-body h2 {
  margin: 0;
  font-size: 22px;
  color: var(--text);
}
.recovery-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 18px;
  border-radius: 14px;
  border: 1px solid rgba(200, 150, 50, 0.3);
  background: var(--panel);
}
.recovery-code {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold-2);
  text-align: center;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}
.recovery-bottom {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 22px 0;
}

.link-card {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(200, 150, 50, 0.3);
  background: var(--panel);
}
.link-card.active {
  display: flex;
}
.link-countdown {
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--cyan);
}
.link-countdown[data-state="expired"] {
  color: #ff9f6b;
}
