:root {
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-bg: #fff7ed;
  --accent-border: #fed7aa;
  --ink: #1c1917;
  --text: #44403c;
  --text-muted: #78716c;
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-m: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-l: 0 12px 28px rgba(0,0,0,0.08);
  --ease: 0.2s ease;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--ease);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 {
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 0.5em;
  font-weight: 700;
}
h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.02em;
}
h2 {
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  font-weight: 600;
}
h3 { font-size: 1rem; font-weight: 600; }

.wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ===== HEADER ===== */
.site-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--accent);
  border-radius: var(--radius) 0 0 var(--radius);
}

.site-header h1, .site-header p { margin: 0; }

.site-header .eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.site-header .sub {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Compact header: one row, ad below */
.site-header-compact {
  padding: 12px 20px 10px;
}
.site-header-compact .site-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}
.site-header-compact .eyebrow {
  margin-bottom: 0;
  flex-shrink: 0;
}
.site-header-compact .site-header-title {
  flex: 1;
  min-width: 0;
  font-size: 1.125rem;
  margin: 0;
}
.site-header-compact .top-nav {
  margin-top: 0;
}
.site-header-compact .quick-menu {
  margin-top: 8px;
}

.top-nav {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.top-nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  color: var(--text);
  background: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all var(--ease);
}
.top-nav a:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
  text-decoration: none;
}

/* ===== QUICK MENU ===== */
.quick-menu {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.quick-menu[open] { background: var(--surface); }
.quick-menu summary {
  cursor: pointer;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 600;
  user-select: none;
  list-style: none;
}
.quick-menu summary::before {
  content: "▸ ";
  color: var(--accent);
}
.quick-menu[open] summary::before { content: "▾ "; }
.quick-menu summary::-webkit-details-marker { display: none; }

.quick-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 8px 14px 14px;
}
.quick-menu-grid a {
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  border: 1px solid var(--border);
  transition: all var(--ease);
}
.quick-menu-grid a:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
  text-decoration: none;
}

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  margin: 16px 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.breadcrumbs a { color: var(--text-muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--accent); }

/* ===== GRID ===== */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
  gap: 20px;
  align-items: start;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.card h2:not(:first-child) { margin-top: 1.75em; }
.card section.card {
  margin-top: 20px;
  border: 1px solid var(--border);
  box-shadow: none;
}
.card section.card:hover { border-color: var(--border-strong); }
.card section.card h2 { font-size: 1.125rem; margin-bottom: 6px; }

.muted {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ===== MAIN CONTENT BLOCK ===== */
.main-content-block {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px 30px 32px;
  margin: 28px 0 32px;
  box-shadow: var(--shadow-m);
}
.main-content-block h2 { margin-top: 0; }
.main-content-block h2:not(:first-child) { margin-top: 1.5em; }

/* ===== RESULT PANEL ===== */
.result-panel {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.result-kicker {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.result-equation {
  margin: 10px 0 6px;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.3;
  color: var(--ink);
  font-weight: 700;
}
.result-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ===== FORM ===== */
.convert-form { display: grid; gap: 14px; }
.convert-form .double {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.convert-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.convert-form input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.convert-form input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.convert-form button {
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  transition: background var(--ease), transform var(--ease);
}
.convert-form button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.convert-form button:active { transform: translateY(0); }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.form-actions button {
  flex: 1;
  min-width: 120px;
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.form-actions button[data-copy-result] {
  border: none;
  background: var(--accent);
  color: #fff;
}
.form-actions button[data-copy-result]:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}
.form-actions button[data-share-page] {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.form-actions button[data-share-page]:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  transform: none;
}

/* ===== LISTS ===== */
.link-cloud, .compact-list, .popular-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.popular-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.link-cloud li, .compact-list li, .popular-grid li {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  font-size: 0.9375rem;
  transition: all var(--ease);
}
.link-cloud li:hover, .compact-list li:hover, .popular-grid li:hover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.link-cloud li a, .compact-list li a, .popular-grid li a {
  display: block;
  color: var(--text);
}
.link-cloud li:hover a, .compact-list li:hover a, .popular-grid li:hover a {
  color: var(--accent);
}

/* ===== TABLE ===== */
.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.matrix th, .matrix td {
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
}
.matrix th {
  background: var(--bg);
  font-weight: 600;
  color: var(--ink);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.matrix tr:last-child td { border-bottom: none; }
.matrix tbody tr:hover td { background: var(--accent-bg); }

/* ===== AD SLOTS ===== */
.ad-slot {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  background: var(--bg);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ad-slot-dynamic { max-height: 80vh; width: 100%; }
.ad-slot-placeholder {
  height: 72vh;
  background: var(--bg);
  border-radius: var(--radius-xs);
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-links a {
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: all var(--ease);
}
.footer-links a:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-bg);
  text-decoration: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .popular-grid { grid-template-columns: 1fr 1fr; }
}

/* Compact header: mobile — stack vertically, no cramped row */
@media (max-width: 768px) {
  .site-header-compact .site-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .site-header-compact .eyebrow {
    margin-bottom: 0;
  }
  .site-header-compact .site-header-title {
    font-size: 1.125rem;
    line-height: 1.3;
    word-break: break-word;
    min-width: 0;
  }
  .site-header-compact .top-nav {
    flex-wrap: wrap;
    gap: 8px;
  }
  .site-header-compact .top-nav a {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .wrapper { padding: 16px 12px 32px; }
  .site-header { padding: 14px 14px 12px; }
  .site-header-compact {
    padding: 14px 14px 10px;
  }
  .site-header-compact .site-header-row {
    gap: 8px;
  }
  .site-header-compact .site-header-title {
    font-size: 1rem;
  }
  .site-header-compact .quick-menu {
    margin-top: 10px;
  }
  .site-header-compact .quick-menu summary {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
  .site-header-compact .quick-menu-grid {
    padding: 6px 10px 10px;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .site-header-compact .quick-menu-grid a {
    padding: 8px 6px;
    font-size: 0.8125rem;
  }
  .card { padding: 16px; }
  .main-content-block { padding: 18px 16px 22px; }
  .convert-form .double { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions button { min-width: 0; }
  .quick-menu-grid { grid-template-columns: 1fr 1fr; }
  .popular-grid { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.0625rem; }
}
