:root {
  --bg: #0f1116;
  --bg-soft: #171b27;
  --card: rgba(24, 28, 41, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --accent: #f4c767;
  --accent-dark: #d2a94d;
  --text: #f5f7fb;
  --muted: rgba(245, 247, 251, 0.7);
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #23304a 0%, #0f1116 40%, #0b0c10 100%);
  min-height: 100vh;
}

.ambient {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(244, 199, 103, 0.2), transparent 45%),
              radial-gradient(circle at 80% 30%, rgba(110, 160, 255, 0.18), transparent 55%),
              radial-gradient(circle at 50% 80%, rgba(255, 140, 105, 0.18), transparent 50%);
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.8;
}

.page {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  z-index: 1;
}

.hero {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-rates {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.top-rates .rate-pair {
  color: var(--text);
  font-size: 12px;
}

.eyebrow {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin: 0 0 12px;
}

h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(32px, 5vw, 48px);
  margin: 0 0 12px;
}

.subhead {
  color: var(--muted);
  font-size: 18px;
  max-width: 560px;
}

/* ── page nav ── */

.page-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.nav-pill {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.nav-pill:hover,
.nav-pill.active {
  color: #1a1404;
  background: var(--accent);
  border-color: var(--accent);
}

/* ── sticky bar ── */

.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  margin: 0 auto 28px;
  max-width: 900px;
}

.sticky-bar.sticky-top {
  margin: 0 auto 18px;
}

.sticky-item {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.sticky-item strong {
  font-size: 16px;
}

.sticky-item .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sticky-item.wide strong {
  font-size: 14px;
  line-height: 1.3;
}

.rate-note {
  color: var(--muted);
  font-size: 11px;
}

/* ── calculator ── */

.calculator {
  display: grid;
  gap: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.steps {
  display: grid;
  gap: 24px;
}

.step {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.step-number {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1404;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
}

.step-body h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.step-body p {
  margin: 0 0 12px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 199, 103, 0.2);
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.unit {
  font-size: 16px;
  color: var(--muted);
}

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}

.pill input {
  accent-color: var(--accent);
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

button,
.contact-actions a {
  border: none;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-dark));
  color: #1a1404;
  font-weight: 700;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.advanced {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: none;
}

.advanced.active {
  display: block;
}

.section-note {
  color: var(--muted);
  font-size: 14px;
}

/* ── results ── */

.results {
  display: grid;
  gap: 24px;
}

.summary {
  display: grid;
  gap: 20px;
}

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

.summary-value {
  margin: 6px 0 0;
  font-size: 36px;
  font-weight: 800;
}

.summary-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.summary-sub {
  margin: 6px 0 0;
  font-weight: 700;
}

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

/* ── formula ── */

.formula-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.formula-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.formula-block code {
  display: block;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  font-family: "Manrope", monospace;
}

/* ── proposal ── */

.proposal-head h2,
.contacts h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.proposal-body {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  margin-top: 16px;
}

.proposal-block {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.proposal-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 16px;
}

.proposal-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.status {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

.contact-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ── compare ── */

.compare-head h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.compare-head p {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 15px;
}

.compare-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.compare-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compare-table th,
.compare-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.compare-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.compare-table td:nth-child(2) {
  white-space: normal;
  max-width: 200px;
}

.compare-table td:nth-child(n+5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compare-table th:nth-child(n+5) {
  text-align: right;
}

.compare-remove {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.compare-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
  font-size: 18px;
}

.compare-summary strong {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

/* ── library ── */

.library-section,
.history-section {
  margin-top: 32px;
}

.library-section h2,
.history-section h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.library-section .subhead,
.history-section .subhead {
  margin: 0 0 16px;
  font-size: 15px;
}

.library-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 10px;
  margin-bottom: 16px;
}

.library-count {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.library-list {
  display: grid;
  gap: 8px;
}

.library-item {
  display: block;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}

.library-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.lib-item-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.lib-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #1a1404;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lib-year {
  font-size: 12px;
  color: var(--muted);
}

.lib-ext {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}

.lib-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

/* ── history ── */

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.history-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.history-main strong {
  font-size: 14px;
  flex: 1;
}

.history-total {
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
  white-space: nowrap;
}

.history-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.history-date {
  margin-left: auto;
}

/* ── favorites ── */

.favorites-section {
  margin-top: 32px;
}

.favorites-section h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.favorites-section .subhead {
  margin: 0 0 16px;
  font-size: 15px;
}

.favorites-list {
  display: grid;
  gap: 8px;
}

.favorite-item {
  display: grid;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.favorite-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.favorite-item strong {
  font-size: 14px;
}

.favorite-meta {
  font-size: 12px;
  color: var(--muted);
}

/* ── sources ── */

.hint h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.hint p {
  color: var(--muted);
  margin: 0;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.source-link:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

/* ── toast ── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-info {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--accent);
}

.toast-error {
  background: #3a1a1a;
  color: #ff8888;
  border: 1px solid #ff4444;
}

.toast-success {
  background: #1a3a1a;
  color: #88ff88;
  border: 1px solid #44ff44;
}

/* ── footer ── */

.footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.footer-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin: 0 0 8px;
}

.footer p {
  margin: 6px 0;
}

/* ── responsive ── */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-rates {
    flex-wrap: wrap;
  }

  .sticky-bar {
    position: static;
    grid-template-columns: 1fr;
  }

  .proposal-body {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .field-inline {
    grid-template-columns: 1fr;
  }

  .step {
    grid-template-columns: 42px 1fr;
  }

  .step-number {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .library-filters {
    grid-template-columns: 1fr;
  }

  .compare-actions {
    flex-direction: column;
  }

  .compare-table {
    font-size: 12px;
  }

  .compare-table td:nth-child(2) {
    max-width: 120px;
  }

  .page-nav {
    gap: 6px;
  }

  .nav-pill {
    font-size: 13px;
    padding: 6px 14px;
  }
}

/* ── print ── */

@media print {
  .ambient,
  .sticky-bar,
  .page-nav,
  .actions,
  .proposal-form,
  .contact-actions,
  .library-section,
  .history-section,
  .favorites-section,
  .hint,
  .compare-actions,
  .toast,
  #toggle-advanced {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .page {
    padding: 0;
    max-width: 100%;
  }

  .card {
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: none;
    backdrop-filter: none;
    page-break-inside: avoid;
  }

  .step {
    background: #f9f9f9;
  }

  .step-number {
    background: #333;
    color: #fff;
  }

  h1 {
    font-size: 24px;
    color: #000;
  }

  .subhead,
  .muted,
  .summary-label,
  .table-note,
  .section-note {
    color: #666;
  }

  .summary-value {
    color: #000;
    font-size: 28px;
  }

  .formula-block {
    background: #f5f5f5;
    border-color: #ddd;
  }

  .formula-block code {
    color: #333;
  }

  .compare-table th,
  .compare-table td {
    border-color: #ccc;
  }

  .compare-remove {
    display: none;
  }

  .footer {
    color: #999;
  }

  .footer-brand {
    color: #333;
  }

  .eyebrow {
    color: #333;
  }

  .proposal-line {
    color: #000;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}

/* ── skeleton loading ── */

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, rgba(255,255,255,0.06) 50%, var(--bg-soft) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: 8px;
}

.skeleton-line {
  height: 18px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 90%; }

.skeleton-select {
  height: 44px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.skeleton-card {
  padding: 24px;
  border-radius: 18px;
  min-height: 120px;
}

/* ── search highlight ── */

mark.search-hl {
  background: rgba(244, 199, 103, 0.3);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── object count badge ── */

.object-count {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.object-count strong {
  color: var(--accent);
}
