:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #1f2430;
  --text-muted: #6b7280;
  --border: #e3e6ee;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #eef2ff;
  --shadow: 0 10px 30px rgba(20, 24, 40, 0.08);
  --radius: 16px;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1b2438;
  --surface-2: #232f49;
  --text: #e8ecf5;
  --text-muted: #9aa6c0;
  --border: #2c3852;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --accent: #232f49;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .25s ease, color .25s ease;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 18px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.lang-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent); }
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  transition: background-color .2s ease, transform .1s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(.94); }

/* Layout */
.container { flex: 1; max-width: 720px; width: 100%; margin: 0 auto; padding: 16px 20px 48px; }
.title { font-size: clamp(26px, 6vw, 38px); font-weight: 800; margin: 18px 0 6px; letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 16px; }

/* Converter card */
.converter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.converter-body { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.unit-select, .value-input, .value-output {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.unit-select:focus, .value-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent); }
.value-input { font-weight: 600; }
.value-output {
  display: flex; align-items: center;
  font-weight: 700; font-size: 18px; min-height: 48px; word-break: break-all;
}
.swap-btn {
  align-self: center; margin-bottom: 2px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--primary); font-size: 20px; cursor: pointer;
  transition: transform .2s ease, background-color .15s ease;
}
.swap-btn:hover { background: var(--accent); }
.swap-btn:active { transform: rotate(180deg); }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.copy-btn {
  border: none; background: var(--primary); color: #fff;
  font-weight: 600; padding: 10px 18px; border-radius: 10px;
  cursor: pointer; font-size: 14px; transition: background-color .15s ease;
}
.copy-btn:hover { background: var(--primary-hover); }
.status-msg { font-size: 13px; color: var(--text-muted); }

/* SEO section */
.seo-section {
  margin-top: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.seo-section h2 { margin-top: 0; font-size: 20px; }
.intro { color: var(--text-muted); font-size: 16px; }
.feature-list { margin: 12px 0 0; padding-left: 20px; color: var(--text-muted); }
.feature-list li { margin: 6px 0; }

/* Category grid (hub) */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.cat-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.cat-card .cat-icon { font-size: 22px; }
.cat-card .cat-name { display: block; margin-top: 8px; font-weight: 700; }
.cat-card .cat-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--text-muted); }

.footer { text-align: center; color: var(--text-muted); font-size: 13px; padding: 24px 20px; }
.footer a { color: var(--primary); text-decoration: none; }

/* Ad slots */
.ad-slot { margin: 22px 0; min-height: 100px; display: flex; justify-content: center; }
.ad-slot ins { width: 100%; }
.ad-placeholder {
  margin: 22px 0;
  min-height: 110px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: var(--text-muted);
}
.ad-placeholder span { font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.ad-placeholder small { font-size: .72rem; opacity: .7; }

/* X→Y long-tail pages: hide the category tabs, show pair-specific blocks */
.pair .tabs { display: none; }
.pair-result {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  margin: 18px 0 6px;
  color: var(--text);
}
.pair-result .num { color: var(--primary); }
.pair-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 6px;
  font-size: 0.95rem;
}
.pair-table th, .pair-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.pair-table th:first-child, .pair-table td:first-child { text-align: left; }
.pair-table thead th { color: var(--text-muted); font-weight: 600; }
.swap-link {
  display: inline-block;
  margin: 8px 0 2px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.swap-link:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 560px) {
  .converter-body { grid-template-columns: 1fr; gap: 12px; }
  .swap-btn { justify-self: center; transform: rotate(90deg); }
  .swap-btn:active { transform: rotate(270deg); }
}
