:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #eef2ff;
  --surface: rgba(255,255,255,0.92);
  --surface-strong: rgba(255,255,255,.98);
  --text: #0f172a;
  --muted: #475569;
  --accent: #3b82f6;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(59,130,246,.16);
  --border: rgba(15,23,42,.12);
  --shadow: 0 24px 80px rgba(15,23,42,.08);
  background: #eef2ff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at top left, rgba(59,130,246,.18), transparent 22%),
              radial-gradient(circle at top right, rgba(16,185,129,.12), transparent 18%),
              radial-gradient(circle at bottom, rgba(99,102,241,.08), transparent 28%),
              var(--bg);
  color: var(--text);
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 44px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1.35rem 1.6rem;
  background: linear-gradient(135deg, rgba(255,255,255,.98), rgba(240,246,255,.95));
  border: 1px solid rgba(148,163,184,.14);
  border-radius: 34px;
  box-shadow: 0 26px 70px rgba(59,130,246,.08);
}

.topbar h1 {
  letter-spacing: -.04em;
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.eyebrow {
  margin: 0;
  font-size: .85rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #64748b;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 3.5rem);
}

h2 {
  font-size: clamp(1.6rem, 2.1vw, 2.1rem);
}

.layout {
  display: grid;
  gap: 26px;
  margin-top: 32px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.panel__header {
  display: grid;
  gap: .75rem;
}

.panel__intro {
  max-width: 680px;
  color: #475569;
}

.converter-card, .result-card {
  display: grid;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(240,246,255,.95));
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 34px;
  padding: 1.6rem;
  box-shadow: 0 26px 80px rgba(59,130,246,.08);
}

.field-group {
  display: grid;
  gap: .65rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: flex-end;
}

label {
  color: #334155;
  font-weight: 600;
}

input, select {
  width: 100%;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 18px;
  background: #fff;
  color: #0f172a;
  padding: 16px 18px;
  transition: border-color .25s ease, transform .2s ease, background .25s ease;
}

input[type="search"] {
  padding-right: 16px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 5px rgba(59,130,246,.12);
  transform: translateY(-1px);
}

.swap-button, .primary-button, .secondary-button, .icon-button {
  border: none;
  border-radius: 18px;
  padding: 1rem 1.25rem;
  background: #f8fbff;
  color: #0f172a;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.swap-button {
  min-width: 4rem;
  font-size: 1.25rem;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.08);
}

.swap-button:hover,
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.chip:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 18px 40px rgba(59,130,246,.23);
}

.secondary-button {
  background: #eef2ff;
  color: #1d4ed8;
}

.icon-button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: #fff;
  box-shadow: 0 16px 30px rgba(15,23,42,.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.lang-select {
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  height: 46px;
  font-weight: 600;
  cursor: pointer;
}

.auth-area {
  display: flex;
  gap: .75rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.status-message {
  min-height: 1.5rem;
  color: #334155;
}

.status-message.error {
  color: #ef4444;
}

.result-text {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  font-weight: 800;
}

.rate-text {
  margin: .4rem 0 0;
  color: #64748b;
}

.quick-panel {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.quick-group {
  background: rgba(244,247,255,.92);
  padding: 1rem;
  border-radius: 24px;
  border: 1px solid rgba(59,130,246,.14);
}

.quick-title {
  margin: 0 0 .75rem;
  font-size: .95rem;
  font-weight: 700;
  color: #334155;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .85rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(59,130,246,.16);
  background: #fff;
  color: #0f172a;
  font-weight: 600;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.mini-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-radius: 28px;
  padding: 1.35rem;
  min-height: auto;
  border: 1px solid rgba(59,130,246,.12);
  box-shadow: 0 18px 40px rgba(59,130,246,.08);
  overflow: hidden;
  position: relative;
}

.card > canvas,
.card canvas {
  width: 100% !important;
  height: 220px !important;
  max-height: 220px !important;
  display: block;
  box-sizing: border-box;
}

.list {
  list-style: none;
  padding: 0;
  margin: .75rem 0 0;
  display: grid;
  gap: .75rem;
}

.list button {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  padding: 1rem;
  border-radius: 18px;
}

.caption {
  margin: .75rem 0 0;
  color: #64748b;
}

.feature-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.feature-card {
  border-radius: 24px;
  padding: 1.3rem;
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
}

.feature-card h3 {
  margin-bottom: .75rem;
}

.feature-card--premium {
  background: linear-gradient(135deg, rgba(59,130,246,.12), rgba(255,255,255,.94));
  border-color: rgba(59,130,246,.18);
}

.account-card {
  min-height: 250px;
}

.sync-block {
  margin-top: 1rem;
}

.sync-key {
  user-select: all;
  width: 100%;
  margin: .6rem 0;
  padding: 1rem;
  border-radius: 18px;
  background: #f1f5f9;
  border: 1px solid rgba(148,163,184,.24);
  color: #0f172a;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(15,23,42,.55);
  padding: 1.5rem;
}

.hidden {
  display: none !important;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(560px, 100%);
  border-radius: 32px;
  background: rgba(255,255,255,.98);
  border: 1px solid rgba(15,23,42,.08);
  padding: 2rem;
  box-shadow: var(--shadow);
  position: relative;
}

.pill,
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .9rem;
  border-radius: 999px;
  background: rgba(59,130,246,.12);
  color: #1e3a8a;
  font-weight: 700;
  font-size: .92rem;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--text);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid rgba(15,23,42,.1);
  background: #f8fbff;
  color: #0f172a;
  padding: .75rem 1rem;
  border-radius: 18px;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.form-row {
  display: grid;
  gap: .5rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.form-row--inline {
  align-items: center;
  grid-template-columns: 1fr;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: #475569;
}

.auth-message {
  margin: 0;
  color: #475569;
  min-height: 1.4rem;
}

.footer {
  margin-top: 1.75rem;
  padding: 1rem 0 0;
  color: #64748b;
  text-align: center;
}

@media (max-width: 900px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 1.1rem 1.2rem;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .brand-group {
    flex-direction: column;
    align-items: flex-start;
  }
  .action-row {
    flex-direction: column;
  }
}

body.dark {
  --bg: #020814;
  --surface: rgba(9,17,34,.95);
  --surface-strong: rgba(6,12,24,.98);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --accent-strong: #38bdf8;
  --accent-soft: rgba(96,165,250,.16);
  --border: rgba(96,165,250,.14);
  background: radial-gradient(circle at top left, rgba(59,130,246,.16), transparent 18%),
              radial-gradient(circle at top right, rgba(16,185,129,.12), transparent 16%),
              linear-gradient(180deg, rgba(3,7,18,.96), #020814 80%);
}

body.dark .app-shell,
body.dark .panel,
body.dark .card,
body.dark .quick-group,
body.dark .feature-card,
body.dark .modal-panel,
body.dark .converter-card,
body.dark .result-card {
  background: rgba(10,18,34,.96);
  border-color: rgba(96,165,250,.14);
  box-shadow: 0 28px 80px rgba(0,0,0,.24);
}

body.dark .card canvas {
  background: linear-gradient(180deg, rgba(6,10,20,.86), rgba(2,6,23,.92));
}

body.dark input,
body.dark select {
  background: rgba(15,23,42,.97);
  border-color: rgba(96,165,250,.18);
  color: #e2e8f0;
}

body.dark input::placeholder,
body.dark select::placeholder {
  color: #94a3b8;
}

body.dark .swap-button,
body.dark .secondary-button,
body.dark .icon-button,
body.dark .tab {
  background: rgba(15,23,42,.98);
  color: #e2e8f0;
  border: 1px solid rgba(96,165,250,.16);
}

body.dark .primary-button {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
}

body.dark .topbar {
  background: rgba(7,13,27,.96);
  border-color: rgba(96,165,250,.14);
}

body.dark .eyebrow,
body.dark .rate-text,
body.dark .caption,
body.dark .status-message,
body.dark .auth-message,
body.dark .checkbox-label {
  color: #94a3b8;
}

body.dark h1,
body.dark h2,
body.dark h3,
body.dark label,
body.dark .chip,
body.dark .brand-pill {
  color: #f8fafc;
}

body.dark .chip {
  background: rgba(30,41,59,.8);
  border-color: rgba(96,165,250,.18);
}

body.dark .sync-key {
  background: rgba(15,23,42,.96);
  color: #e2e8f0;
  border-color: rgba(148,163,184,.16);
}

body.dark .secondary-button,
body.dark .swap-button {
  background: rgba(15,23,42,.96);
}

body.dark .rate-text,
body.dark .caption,
body.dark .eyebrow,
body.dark .status-message {
  color: #94a3b8;
}
