/* ── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
  --navy-950: #0A0F1C;
  --navy-900: #0E1526;
  --navy-800: #141D33;
  --navy-700: #1C2740;
  --line:     #2A3552;
  --paper:    #F4F6FA;
  --ink:      #E9EDF6;
  --ink-dim:  #93A0C0;
  --orange:   #FF7A29;
  --orange-d: #C75B18;
  --teal:     #17C3B2;
  --teal-d:   #0E8377;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,0.4);

  --f-display: 'Space Grotesk', sans-serif;
  --f-body:    'Inter', sans-serif;
  --f-mono:    'JetBrains Mono', monospace;
}

/* ── Base ────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Ensure the HTML [hidden] attribute always wins over any display: property */
[hidden] { display: none !important; }

body {
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(255,122,41,0.07), transparent 60%),
    radial-gradient(ellipse 800px 500px at 100% 0%,  rgba(23,195,178,0.07), transparent 55%),
    var(--navy-950);
  color: var(--ink);
  font-family: var(--f-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, select, textarea, input { font-family: inherit; }
button { cursor: pointer; }

/* ── Loading splash ──────────────────────────────────────────────────────────── */
.loading-view {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-950);
  z-index: 999;
}
.loading-view .brand-mark {
  font-family: var(--f-display);
  font-size: 48px; font-weight: 700;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── Brand mark (shared) ─────────────────────────────────────────────────────── */
.brand-mark { font-family: var(--f-display); font-weight: 700; }
.brand-bang  { color: var(--orange); }

/* ── Auth screen ─────────────────────────────────────────────────────────────── */
.auth-view {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
}
.auth-brand {
  text-align: center; margin-bottom: 32px;
}
.auth-brand .brand-mark { font-size: 40px; }
.auth-tagline {
  display: block;
  font-family: var(--f-mono); font-size: 12px;
  color: var(--ink-dim); margin-top: 6px;
  letter-spacing: 0.04em;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--navy-900);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 28px 32px;
  box-shadow: var(--shadow);
}
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--navy-800);
  padding: 3px; border-radius: 9px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; background: transparent; border: none;
  color: var(--ink-dim); font-size: 14px; font-weight: 500;
  padding: 8px 0; border-radius: 7px;
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--navy-700); color: var(--ink); }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-family: var(--f-mono);
  color: var(--ink-dim); margin-bottom: 6px; letter-spacing: 0.03em;
}
.field input {
  width: 100%;
  background: var(--navy-800);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 11px 14px; border-radius: 8px;
  font-size: 15px; outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--teal-d); }
.field input::placeholder { color: #4A567A; }

.auth-error {
  margin-top: 14px; font-size: 13px;
  color: var(--orange); text-align: center;
}

/* Forgot password */
.forgot-wrap { text-align: center; margin: 10px 0 0; }
.forgot-link {
  background: none; border: none; padding: 0;
  color: var(--ink-dim); font-size: 12px;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; transition: color .15s;
}
.forgot-link:hover { color: var(--teal); }
.reset-msg {
  font-size: 12px; text-align: center;
  margin: 8px 0 0; padding: 8px 12px;
  border-radius: 7px; line-height: 1.4;
}
.reset-msg.success { background: rgba(23,195,178,0.12); color: var(--teal); }
.reset-msg.error   { background: rgba(255,122,41,0.12);  color: var(--orange); }

/* Email verification banner */
.verify-banner {
  background: rgba(255,122,41,0.10);
  border-bottom: 1px solid rgba(255,122,41,0.25);
  padding: 10px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 13px; color: var(--ink);
}
.verify-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.verify-resend {
  background: var(--orange); border: none; color: var(--navy-950);
  font-size: 12px; font-weight: 600; padding: 5px 12px;
  border-radius: 6px; cursor: pointer; transition: background .15s;
}
.verify-resend:hover { background: #FF9147; }
.verify-dismiss {
  background: none; border: none; color: var(--ink-dim);
  font-size: 16px; cursor: pointer; padding: 0 4px;
  transition: color .15s; line-height: 1;
}
.verify-dismiss:hover { color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.solid-btn {
  background: var(--teal);
  border: 1px solid var(--teal-d);
  color: var(--navy-950);
  font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 8px;
  transition: background .15s;
}
.solid-btn:hover  { background: #22D6C4; }
.solid-btn:active { background: var(--teal-d); }
.solid-btn.full   { width: 100%; margin-top: 6px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 12px;
  padding: 7px 13px; border-radius: 7px;
  transition: border-color .15s, color .15s;
}
.ghost-btn:hover { border-color: var(--teal-d); color: var(--ink); }

/* ── Ticker ──────────────────────────────────────────────────────────────────── */
.ticker {
  width: 100%; height: 32px;
  background: var(--navy-900);
  border-bottom: 1px solid var(--line);
  overflow: hidden; display: flex; align-items: center;
}
.ticker-track {
  display: flex; gap: 36px; white-space: nowrap;
  padding-left: 100%;
  animation: scroll-ticker 36s linear infinite;
  font-family: var(--f-mono); font-size: 11px;
}
.ticker-item .pair  { color: var(--ink); font-weight: 500; }
.ticker-item        { color: var(--ink-dim); }
.ticker-item .up    { color: var(--teal); }
.ticker-item .down  { color: var(--orange); }
@keyframes scroll-ticker { from { transform:translateX(0); } to { transform:translateX(-100%); } }
@media (prefers-reduced-motion:reduce) { .ticker-track { animation:none; padding-left:16px; } }

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px 0;
  max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .brand-mark { font-size: 26px; }
.brand-sub { font-family: var(--f-mono); font-size: 11px; color: var(--ink-dim); letter-spacing: 0.04em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.home-lang-wrap { display: flex; align-items: center; gap: 8px; }
.home-lang-wrap label { font-family: var(--f-mono); font-size: 11px; color: var(--ink-dim); }
.home-lang-wrap select {
  background: var(--navy-800); border: 1px solid var(--line);
  color: var(--ink); padding: 7px 11px; border-radius: 8px; font-size: 13px;
}

/* User avatar & dropdown */
.user-menu { position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--teal-d));
  border: none; color: var(--navy-950);
  font-weight: 700; font-size: 14px;
}
.user-dropdown {
  position: absolute; top: 42px; right: 0;
  background: var(--navy-800); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
  min-width: 200px; box-shadow: var(--shadow);
  z-index: 50;
}
.user-email { font-size: 12px; color: var(--ink-dim); margin: 0 0 12px; word-break: break-all; }
.logout-btn {
  width: 100%; background: transparent; border: 1px solid var(--line);
  color: var(--orange); font-size: 13px; padding: 8px; border-radius: 7px;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,122,41,0.1); }

/* ── Main floor ──────────────────────────────────────────────────────────────── */
.floor {
  max-width: 1100px; margin: 0 auto;
  padding: 30px 32px 20px;
}
.thesis {
  font-family: var(--f-display);
  font-size: clamp(20px, 2.8vw, 30px);
  font-weight: 500; line-height: 1.35;
  max-width: 640px; margin: 0 0 28px;
  color: var(--paper);
}

/* ── Translation desk ────────────────────────────────────────────────────────── */
.desk {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  background: var(--navy-900); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}

.pane {
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; min-height: 200px;
}
.pane-in { border-right: 1px solid var(--line); }
.pane-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pane-eyebrow {
  font-family: var(--f-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim);
}
.detected-tag {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--teal); border: 1px solid var(--teal-d);
  padding: 3px 9px; border-radius: 20px;
}
.stamp {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--orange); border: 1px solid var(--orange-d);
  padding: 3px 9px; border-radius: 20px;
  transform: rotate(-1.5deg);
}

textarea {
  flex: 1; resize: none; background: transparent;
  border: none; color: var(--ink); font-size: 15px;
  line-height: 1.6; outline: none; min-height: 130px;
}
textarea::placeholder { color: #4A567A; }
.pane-actions {
  display: flex; gap: 8px; align-items: center; margin-top: 12px;
  flex-wrap: wrap;
}
.char-count { font-family: var(--f-mono); font-size: 11px; color: var(--ink-dim); margin-left: auto; }
.char-count.warn { color: var(--orange); }

.output-text { flex: 1; font-size: 15px; line-height: 1.6; color: var(--ink); }
.muted { color: #4A567A; }

/* Rail */
.rail {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px;
  background: var(--navy-800);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.rail-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--orange-d);
  background: linear-gradient(160deg, var(--orange), var(--orange-d));
  color: var(--navy-950);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.rail-btn:hover   { transform: scale(1.08); }
.rail-btn:active  { transform: scale(0.95); }
.rail-btn:disabled { opacity: 0.45; cursor: progress; }
.rail-hint { font-family: var(--f-mono); font-size: 10px; color: var(--ink-dim); text-align: center; }

/* ── Reply section ───────────────────────────────────────────────────────────── */
.reply-desk {
  margin-top: 18px;
  background: var(--navy-900); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 20px 20px;
}
.reply-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.reply-head h2 { font-family: var(--f-display); font-size: 15px; font-weight: 600; margin: 0; color: var(--paper); }
.tabs { display: flex; gap: 5px; background: var(--navy-800); padding: 3px; border-radius: 8px; }
.tab {
  background: transparent; border: none; color: var(--ink-dim);
  font-size: 12px; padding: 6px 13px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.tab.active { background: var(--teal-d); color: var(--paper); }
.reply-content { font-size: 15px; line-height: 1.6; margin: 0 0 14px; }
.reply-hint { font-size: 12px; color: var(--ink-dim); margin: 14px 0 0; }
.reply-hint strong { color: var(--ink); }

/* ── Status line ─────────────────────────────────────────────────────────────── */
.status { font-family: var(--f-mono); font-size: 12px; color: var(--ink-dim); min-height: 18px; margin: 12px 4px 0; }
.status.error { color: var(--orange); }

/* ── History panel ───────────────────────────────────────────────────────────── */
.history-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 360px; max-width: 90vw;
  background: var(--navy-900); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 60;
  transform: translateX(0);
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
}
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.history-header h3 { font-family: var(--f-display); font-size: 15px; font-weight: 600; margin: 0; }
.history-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.history-card {
  background: var(--navy-800); border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 15px; cursor: pointer;
  transition: border-color .15s;
}
.history-card:hover { border-color: var(--teal-d); }
.history-card-lang {
  font-family: var(--f-mono); font-size: 11px; color: var(--teal);
  margin-bottom: 6px;
}
.history-card-original {
  font-size: 13px; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.history-card-translation {
  font-size: 13px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-card-time {
  font-family: var(--f-mono); font-size: 10px;
  color: #4A567A; margin-top: 8px;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 55;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.baseboard {
  max-width: 1100px; margin: 0 auto;
  padding: 24px 32px 40px;
  display: flex; gap: 10px; align-items: center;
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-dim);
}
.baseboard .dot { color: var(--line); }

/* ── Focus / a11y ────────────────────────────────────────────────────────────── */
button:focus-visible, select:focus-visible,
textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .desk { grid-template-columns: 1fr; }
  .pane-in  { border-right: none; border-bottom: 1px solid var(--line); }
  .rail {
    flex-direction: row; padding: 10px 0;
    border-left: none; border-right: none; border-bottom: 1px solid var(--line);
  }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 14px 16px 0; }
  .floor  { padding: 20px 16px 16px; }
  .home-lang-wrap label { display: none; }
}
@media (max-width: 480px) {
  .topbar-right { gap: 8px; }
  .history-panel { width: 100%; }
}

/* ── PWA standalone display tweaks ──────────────────────────────────────────── */
@media (display-mode: standalone) {
  /* Add safe-area padding for phones with notches */
  body { padding-top: env(safe-area-inset-top); }
  .baseboard { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}

/* ── Mini toggle button ──────────────────────────────────────────────────────── */
.mini-toggle-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px;
  transition: border-color .2s, color .2s, background .2s;
}
.mini-toggle-btn:hover { border-color: var(--teal-d); color: var(--ink); }
body.mini .mini-toggle-btn {
  border-color: var(--teal-d);
  color: var(--teal);
  background: rgba(23,195,178,0.08);
}

/* ── Mini mode overrides ─────────────────────────────────────────────────────── */
/* Hide decorative / spacious elements */
body.mini .ticker          { display: none; }
body.mini .thesis          { display: none; }
body.mini .baseboard       { display: none; }
body.mini .brand-sub       { display: none; }
body.mini .home-lang-wrap label { display: none; }
body.mini .rail-hint       { display: none; }

/* Tighten topbar */
body.mini .topbar {
  padding: 12px 16px;
  margin-bottom: 0;
}
body.mini .brand .brand-mark { font-size: 20px; }

/* Constrain floor to a compact card width */
body.mini .floor {
  max-width: 440px;
  margin: 0 auto;
  padding: 14px 14px 10px;
}

/* Compact desk: single column */
body.mini .desk {
  grid-template-columns: 1fr;
  border-radius: 10px;
}
body.mini .pane-in {
  border-right: none;
  border-bottom: 1px solid var(--line);
}
body.mini .rail {
  flex-direction: row;
  padding: 8px 12px;
  gap: 12px;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--line);
  justify-content: center;
}
body.mini .rail-btn { width: 36px; height: 36px; }
body.mini .pane {
  padding: 12px 14px;
  min-height: 80px;
}
body.mini textarea {
  min-height: 70px;
  font-size: 14px;
}
body.mini .output-text { font-size: 14px; }
body.mini .pane-actions {
  margin-top: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}

/* Compact reply section */
body.mini .reply-desk {
  margin-top: 10px;
  padding: 12px 14px 14px;
  border-radius: 10px;
}
body.mini .reply-head h2 { font-size: 13px; }
body.mini .reply-content  { font-size: 14px; margin-bottom: 10px; }
body.mini .reply-hint      { display: none; }
body.mini .status          { margin: 8px 2px 0; }

