/* ═══════════════════════════════════════════════
   EqConvert — Shared Design System
   Theme: Deep-lab scientific instrument
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=Syne:wght@400;600;700;800&display=swap');

:root {
  --bg:          #080b11;
  --bg2:         #0d1117;
  --surface:     #111620;
  --panel:       #161c28;
  --border:      #1e2840;
  --border-hi:   #2a3858;
  --teal:        #00e5c3;
  --teal-dim:    #00b89a;
  --teal-glow:   rgba(0,229,195,0.12);
  --teal-glow2:  rgba(0,229,195,0.06);
  --amber:       #f0a500;
  --amber-dim:   rgba(240,165,0,0.15);
  --red:         #ff4d6d;
  --red-dim:     rgba(255,77,109,0.12);
  --text:        #cdd6f4;
  --text-dim:    #8892b0;
  --muted:       #4a5568;
  --mono:        'DM Mono', monospace;
  --sans:        'Syne', sans-serif;
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Noise texture overlay ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
}

/* ── Floating background symbols ── */
.bg-symbols {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.bg-sym {
  position: absolute;
  font-family: var(--mono);
  color: rgba(0,229,195,0.035);
  animation: drift linear infinite;
  user-select: none; pointer-events: none;
}
@keyframes drift {
  from { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  to   { transform: translateY(-15vh) rotate(360deg); opacity: 0; }
}

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
  height: 58px;
  background: rgba(8,11,17,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: inherit;
}
.nav-logo-icon {
  width: 30px; height: 30px;
  border: 1.5px solid var(--teal);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 0 10px var(--teal-glow);
  color: var(--teal);
  font-family: var(--mono);
}
.nav-logo-text {
  font-size: 1rem; font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.nav-logo-text span { color: var(--teal); }
.nav-links {
  display: flex; align-items: center; gap: 0.25rem;
}
.nav-link {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
  letter-spacing: 0.02em;
  cursor: pointer; border: none; background: none; font-family: var(--sans);
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--teal); }
.nav-link.nav-signout { color: var(--muted); }
.nav-link.nav-signout:hover { color: var(--red); background: var(--red-dim); }
.nav-user {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}

/* ── Page wrapper ── */
.page {
  position: relative; z-index: 1;
  min-height: calc(100vh - 58px);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 5rem;
  gap: 1.75rem;
}

/* ── Section header ── */
.page-header {
  text-align: center;
  animation: fadeUp 0.5s ease both;
}
.page-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #fff;
  line-height: 1.1;
}
.page-title span { color: var(--teal); }
.page-sub {
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ── Cards ── */
.card {
  width: 100%; max-width: 700px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp 0.5s ease both;
}
.card-header {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 6px var(--teal);
  flex-shrink: 0;
}
.dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.pulse { animation: dotpulse 2s ease infinite; }
@keyframes dotpulse { 0%,100%{opacity:1} 50%{opacity:0.25} }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--teal);
  color: var(--bg);
  box-shadow: 0 4px 20px rgba(0,229,195,0.2);
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s;
}
.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:hover { box-shadow: 0 4px 28px rgba(0,229,195,0.35); transform: translateY(-1px); }
.btn-primary:active { transform: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--teal);
  color: var(--teal);
}
.btn-outline:hover { background: var(--teal-glow); box-shadow: 0 0 20px var(--teal-glow); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); background: var(--panel); }

.btn-danger {
  background: var(--red-dim);
  border: 1.5px solid rgba(255,77,109,0.3);
  color: var(--red);
}
.btn-danger:hover { background: rgba(255,77,109,0.2); }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.78rem; }
.btn-full { width: 100%; }

/* ── Form elements ── */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow2);
}
.input::placeholder { color: var(--muted); }

.input-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

/* ── Divider ── */
.divider {
  display: flex; align-items: center; gap: 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Alert ── */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.78rem;
  display: none;
}
.alert.visible { display: block; }
.alert-error { background: var(--red-dim); border: 1px solid rgba(255,77,109,0.25); color: var(--red); }
.alert-success { background: rgba(0,229,195,0.08); border: 1px solid rgba(0,229,195,0.2); color: var(--teal); }
.alert-info { background: var(--amber-dim); border: 1px solid rgba(240,165,0,0.2); color: var(--amber); }

/* ── Drop zone ── */
.drop-zone {
  width: 100%; max-width: 700px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.75rem 2rem;
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  background: var(--surface);
  animation: fadeUp 0.5s 0.1s ease both;
  position: relative; overflow: hidden;
  text-align: center;
}
.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,229,195,0.05) 0%, transparent 65%);
  pointer-events: none;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--teal);
  border-style: solid;
  background: var(--panel);
  box-shadow: 0 0 48px rgba(0,229,195,0.07);
}
.drop-icon {
  width: 3.5rem; height: 3.5rem;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  transition: transform var(--transition), border-color var(--transition);
}
.drop-zone:hover .drop-icon, .drop-zone.dragover .drop-icon {
  transform: scale(1.06); border-color: var(--teal);
}
.drop-label { font-size: 1rem; font-weight: 600; color: var(--text); }
.drop-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

/* ── Progress bar ── */
.progress-wrap { width: 100%; max-width: 700px; display: none; flex-direction: column; gap: 0.6rem; animation: fadeUp 0.3s ease both; }
.progress-wrap.visible { display: flex; }
.progress-track { height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal));
  border-radius: 99px; width: 0%;
  transition: width 0.35s ease;
  box-shadow: 0 0 8px var(--teal);
}
.progress-label { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); text-align: center; }

/* ── Stats grid ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem;
  width: 100%; max-width: 700px;
}
.stat-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; text-align: center;
  position: relative; overflow: hidden; animation: fadeUp 0.4s ease both;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--teal); transform: scaleX(0); transform-origin: left;
  animation: scaleX 0.5s 0.1s ease forwards;
}
@keyframes scaleX { to { transform: scaleX(1); } }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--teal); font-family: var(--mono); line-height: 1; }
.stat-lbl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 0.35rem; }

/* ── Eq log ── */
.eq-item {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 0.75rem;
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid rgba(30,40,64,0.4);
  animation: fadeIn 0.2s ease both;
}
.eq-item:last-child { border-bottom: none; }
.eq-latex { font-family: var(--mono); font-size: 0.72rem; color: var(--amber); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq-arrow { color: var(--teal); font-size: 0.9rem; flex-shrink: 0; }
.eq-unicode { font-family: var(--mono); font-size: 0.82rem; color: var(--teal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }

/* ── History list ── */
.history-list { width: 100%; max-width: 700px; display: flex; flex-direction: column; gap: 0.6rem; }
.history-item {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  animation: fadeUp 0.3s ease both;
  transition: border-color var(--transition), background var(--transition);
}
.history-item:hover { border-color: var(--border-hi); background: var(--panel); }
.history-icon { font-size: 1.5rem; flex-shrink: 0; }
.history-meta { flex: 1; min-width: 0; }
.history-name {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-date { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
.history-expires { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); margin-top: 0.15rem; }
.history-expires.soon { color: var(--amber); }
.history-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ── File bar ── */
.file-bar {
  width: 100%; max-width: 700px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1.25rem;
  display: none; align-items: center; gap: 1rem;
  animation: fadeUp 0.25s ease both;
}
.file-bar.visible { display: flex; }
.file-bar-name { flex: 1; font-family: var(--mono); font-size: 0.8rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-bar-size { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); flex-shrink: 0; }
.clear-btn { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 0.2rem; transition: color var(--transition); flex-shrink: 0; }
.clear-btn:hover { color: var(--red); }

/* ── Empty state ── */
.empty-state {
  width: 100%; max-width: 700px;
  text-align: center; padding: 4rem 2rem;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-title { font-size: 0.95rem; font-weight: 600; color: var(--text-dim); }
.empty-sub { font-family: var(--mono); font-size: 0.73rem; margin-top: 0.4rem; }

/* ── Loading spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0,229,195,0.2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ── Utilities ── */
.hidden { display: none !important; }
.w-full { width: 100%; }
.max-700 { max-width: 700px; width: 100%; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.text-muted { color: var(--muted); font-family: var(--mono); font-size: 0.75rem; }
.scrollable { max-height: 260px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .page { padding: 2rem 1rem 4rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 2; }
  .history-item { flex-wrap: wrap; }
  .history-actions { width: 100%; }
  .history-actions .btn { flex: 1; }
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  height: 64px;
  background: rgba(8,11,17,0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  background: none;
  cursor: pointer;
  transition: color var(--transition);
  padding: 0.5rem 0;
  position: relative;
}

.bottom-nav-tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--transition), transform var(--transition);
}

.bottom-nav-tab:hover {
  color: var(--text);
}

.bottom-nav-tab.active {
  color: var(--teal);
}

.bottom-nav-tab.active svg {
  filter: drop-shadow(0 0 6px rgba(0,229,195,0.5));
  transform: translateY(-1px);
}

/* Active indicator dot above active tab */
.bottom-nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--teal);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 8px var(--teal);
}

/* ── Top header bar (replaces old .nav for protected pages) ── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  background: rgba(8,11,17,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.top-header-logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
}

.top-header-icon {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--teal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-family: var(--mono);
  color: var(--teal);
  box-shadow: 0 0 10px var(--teal-glow);
}

.top-header-name {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.top-header-name span {
  color: var(--teal);
}

/* ── Page padding adjustment for bottom nav ── */
.page {
  padding-bottom: 88px; /* 64px nav + 24px breathing room */
}

/* ── Responsive bottom nav ── */
@media (max-width: 600px) {
  .bottom-nav {
    height: 60px;
  }
  .bottom-nav-tab {
    font-size: 0.55rem;
  }
  .bottom-nav-tab svg {
    width: 20px;
    height: 20px;
  }
}