:root {
  --ink: #0c2340;
  --ink-soft: #163a5f;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --line: rgba(12, 35, 64, 0.12);
  --text: #0c2340;
  --muted: #5a7190;
  --accent: #0ea5e9;
  --accent-deep: #0369a1;
  --warm: #f59e0b;
  --danger: #e11d48;
  --radius: 18px;
  --shadow: 0 20px 50px rgba(12, 35, 64, 0.12);
  --font: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 640px at 8% -8%, rgba(14, 165, 233, 0.22), transparent 55%),
    radial-gradient(900px 560px at 96% 6%, rgba(245, 158, 11, 0.16), transparent 50%),
    linear-gradient(165deg, #eef6fc 0%, #f7fafc 42%, #e8f0f7 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(12, 35, 64, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 35, 64, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

.app {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  animation: rise 0.55s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.7rem;
  background:
    linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 55%, var(--warm) 120%);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
  animation: pulse-mark 3.2s ease-in-out infinite;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-domain {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-deep);
  letter-spacing: 0.01em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

.topbar-right {
  display: grid;
  gap: 0.45rem;
  justify-items: end;
}

.site-nav,
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.site-nav a,
.footer-nav a {
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.site-nav a:hover,
.footer-nav a:hover {
  text-decoration: underline;
}

.btn-install,
.btn-install-lg {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent-deep));
}

.btn-install-lg {
  padding: 0.85rem 1.15rem;
  font-size: 0.95rem;
  border-radius: 12px;
  white-space: nowrap;
}

.btn-install-link {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent-deep);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-install-link:hover {
  text-decoration: underline;
}

.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(145deg, rgba(14, 165, 233, 0.14), rgba(245, 158, 11, 0.1));
  border: 1px solid rgba(14, 165, 233, 0.28);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}

.install-banner[hidden] {
  display: none !important;
}

.install-banner strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.install-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.install-help {
  margin: 0 0 0.65rem !important;
  font-size: 0.8rem !important;
}

@media (max-width: 700px) {
  .install-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-install-lg {
    width: 100%;
    text-align: center;
  }
}

.site-intro {
  margin: 0 0 1.35rem;
  padding: 1.15rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  animation: rise 0.6s ease both 0.03s;
}

.site-intro h2 {
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.site-intro p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
  max-width: 72ch;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.25rem;
  align-items: start;
  min-height: 70vh;
}

.workspace {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  min-height: 620px;
  position: relative;
  overflow: hidden;
  animation: rise 0.65s ease both 0.05s;
}

.panel {
  display: none;
  animation: fade-slide 0.35s ease both;
}

.panel.active {
  display: block;
}

.panel-head {
  margin-bottom: 1.35rem;
}

.panel-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
}

.calc-shell {
  width: min(360px, 100%);
  margin: 0.5rem auto 0;
}

.calc-display {
  background: rgba(12, 35, 64, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  text-align: right;
  min-height: 5.5rem;
}

.calc-expr {
  min-height: 1.25rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.calc-result {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 0.35rem;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

.key {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 500;
  border-radius: 12px;
  min-height: 3.2rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.key:hover {
  background: #fff;
  border-color: rgba(14, 165, 233, 0.4);
}

.key:active {
  transform: scale(0.96);
}

.key-muted {
  color: var(--muted);
}

.key-op {
  color: var(--accent-deep);
}

.key-equals {
  background: linear-gradient(160deg, var(--accent), var(--accent-deep));
  color: #fff;
  border-color: transparent;
  font-weight: 700;
}

.key-equals:hover {
  background: linear-gradient(160deg, #38bdf8, var(--accent));
}

.key-zero {
  grid-column: span 2;
}

.form {
  display: grid;
  gap: 1rem;
  max-width: 460px;
}

.form label {
  display: grid;
  gap: 0.4rem;
}

.form label > span,
.toggle-group legend {
  color: var(--muted);
  font-size: 0.9rem;
}

.form input,
.form select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input:focus,
.form select:focus {
  border-color: rgba(14, 165, 233, 0.6);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.form select {
  cursor: pointer;
}

.toggle-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0;
  display: grid;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.55);
}

.radio {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.radio input {
  width: auto;
  accent-color: var(--accent);
}

.btn-primary {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent-deep));
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: scale(0.98);
}

.results {
  margin-top: 1.4rem;
  max-width: 460px;
  animation: fade-slide 0.35s ease both;
}

.result-hero {
  background: linear-gradient(145deg, rgba(14, 165, 233, 0.14), rgba(245, 158, 11, 0.1));
  border: 1px solid rgba(14, 165, 233, 0.28);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.85rem;
}

.result-label {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.result-value {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  letter-spacing: -0.02em;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.result-grid > div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.7);
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}

.result-grid strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
}

.result-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.check {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.92rem;
}

.check input {
  width: auto;
  accent-color: var(--accent);
}

.hint {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.currency-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.65rem;
  align-items: end;
}

.btn-swap {
  appearance: none;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 0.15rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent-deep);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn-swap:hover {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.35);
}

.btn-swap:active {
  transform: rotate(180deg);
}

.sidebar {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  animation: rise 0.7s ease both 0.12s;
}

.sidebar-label {
  margin: 0 0 0.75rem 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.tool-nav {
  display: grid;
  gap: 0.45rem;
}

.tool-btn {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.tool-btn:hover {
  background: rgba(14, 165, 233, 0.06);
  border-color: var(--line);
}

.tool-btn.active {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.35);
}

.tool-btn:active {
  transform: scale(0.98);
}

.tool-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(12, 35, 64, 0.05);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--accent-deep);
  flex-shrink: 0;
}

.tool-btn.active .tool-icon {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.4);
}

.tool-text {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.tool-text strong {
  font-size: 0.95rem;
  font-weight: 600;
}

.tool-text small {
  color: var(--muted);
  font-size: 0.75rem;
}

.site-footer {
  margin-top: 1.5rem;
  padding: 1.1rem 0.25rem 0.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  animation: rise 0.7s ease both 0.15s;
}

.site-footer strong {
  color: var(--ink-soft);
}

.site-footer p {
  margin: 0 0 0.45rem;
}

.footer-nav {
  margin: 0.35rem 0 0.75rem;
}

.affiliate-cta {
  margin-top: 1rem;
  padding: 1rem 1.05rem;
  border-radius: 14px;
  border: 1px dashed rgba(14, 165, 233, 0.45);
  background: rgba(14, 165, 233, 0.08);
}

.affiliate-title {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}

.affiliate-text {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.btn-affiliate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  text-decoration: none;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(160deg, var(--warm), #d97706);
  transition: filter 0.15s ease, transform 0.12s ease;
}

.btn-affiliate:hover {
  filter: brightness(1.05);
}

.btn-affiliate:active {
  transform: scale(0.98);
}

.affiliate-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.legal-page {
  max-width: 720px;
}

.legal-page h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.legal-page h2 {
  margin: 1.4rem 0 0.5rem;
  font-size: 1.15rem;
}

.legal-page p,
.legal-page li {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.98rem;
}

.legal-page ul {
  margin: 0.4rem 0 0.8rem;
  padding-left: 1.2rem;
}

.legal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.35rem 1.6rem;
}

.back-home {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent-deep);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.92rem;
}

.back-home:hover {
  text-decoration: underline;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse-mark {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(14, 165, 233, 0.06);
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
    position: static;
    max-height: none;
  }

  .tool-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .topbar-right {
    justify-items: start;
  }

  .tagline {
    text-align: left;
  }

  .workspace {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .app {
    width: calc(100% - 1.25rem);
    padding-top: 1rem;
  }

  .tool-nav {
    grid-template-columns: 1fr;
  }

  .result-grid,
  .result-grid-3 {
    grid-template-columns: 1fr;
  }

  .currency-row {
    grid-template-columns: 1fr;
  }

  .btn-swap {
    justify-self: center;
    margin: 0;
  }
}
