:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1c1e26;
  --muted: #667085;
  --border: #e3e6ee;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1e29;
    --panel: #262835;
    --text: #eef0f6;
    --muted: #a8afc2;
    --border: #383c4e;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #2c3049;
    --link: #60a5fa;
    --link-hover: #93c5fd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-family: 'Baloo 2', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 2.15rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: #818cf8;
  background: linear-gradient(90deg, #4ade80, #facc15, #fb923c, #f472b6, #c084fc, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

nav.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

nav.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--text);
}

nav.site-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Bubble quick-jump nav (all tools live on one page; these just scroll to a section) */
nav.bubble-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

nav.bubble-nav a {
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

nav.bubble-nav a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

nav.bubble-nav a.nav-active {
  background: #facc15;
  border-color: #eab308;
  color: #1c1e26;
}

nav.bubble-nav a.nav-active:hover {
  background: #fbd949;
  color: #1c1e26;
}

section {
  scroll-margin-top: 20px;
}

.section-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 44px 0;
}

main {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.page-grid {
  display: grid;
  grid-template-columns: 5fr 4fr 4fr;
  gap: 40px;
  align-items: start;
}

.tool-section.col-separated {
  margin-right: -6px;
}

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

  .tool-section.col-separated {
    grid-column: 1 / -1;
    margin-right: -6px;
    margin-bottom: 14px;
  }
}

@media (max-width: 700px) {
  .page-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .tool-section.col-separated {
    margin-bottom: -6px;
  }
}

.col-right {
  display: flex;
  flex-direction: column;
}

.col-right .page-title {
  font-size: 1.25rem;
}

.col-right .page-subtitle {
  font-size: 0.85rem;
}

.col-right .card {
  padding: 16px;
}

.col-right input[type="text"],
.col-right input[type="number"],
.col-right select {
  padding: 9px 12px;
  font-size: 0.9rem;
}

.col-right label {
  font-size: 0.78rem;
}

.col-right .row {
  gap: 10px;
}

.col-right .field {
  min-width: 110px;
}

.col-right button {
  padding: 9px 14px;
  font-size: 0.88rem;
}

.col-right .swap-btn {
  width: 38px;
  height: 38px;
}

.col-right .category-tabs button {
  padding: 6px 8px;
  font-size: 0.76rem;
}

.col-right .result-to,
.col-right .big-result {
  font-size: 1.6rem;
}

.col-right .result-from {
  font-size: 0.9rem;
}

.col-divider {
  margin: 28px 0;
}

.intro {
  min-height: 154px;
}

@media (max-width: 800px) {
  .page-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.page-title {
  margin: 0 0 4px;
  font-size: 1.55rem;
}

.page-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.tool-section {
  border: 2px solid transparent;
  border-radius: calc(var(--radius) + 6px);
  padding: 6px;
  margin: -6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-section.section-active {
  border-color: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.18), 0 0 22px rgba(234, 179, 8, 0.45);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: end;
}

.field {
  flex: 1;
  min-width: 160px;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 8px;
}

.result-count {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-chip {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.swap-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1.1rem;
  flex: 0 0 auto;
}

.swap-btn:hover { background: var(--accent-soft); }

.big-result {
  font-size: 2rem;
  font-weight: 700;
  margin: 4px 0;
}

.result-from {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.result-to {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.result-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  margin-bottom: 18px;
}

.category-tabs button {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 600;
  padding: 8px 10px;
  font-size: 0.82rem;
  flex: 1 1 auto;
  min-width: 72px;
  white-space: nowrap;
}

.category-tabs button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

footer.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  gap: 16px;
}

footer.site-footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

footer.site-footer a:hover {
  color: var(--accent);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
