/* ===== Arbor Converter — Styles ===== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #64748b;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-soft: #dcfce7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, .08);
  --header-h: 62px;
}

* { box-sizing: border-box; }

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

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ===== App layout ===== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.logo span { color: var(--accent); }

.header-spacer { flex: 1; }

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}

/* ===== Language dropdown ===== */
.lang-dropdown { position: relative; }

.lang-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

.lang-dropdown-toggle:hover { border-color: #cbd5e1; }

.flag-icon { height: 15px; width: auto; border-radius: 2px; display: block; }

.lang-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 40;
}

.lang-dropdown-menu.visible { display: block; }

.lang-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: background .15s;
}

.lang-dropdown-item:hover { background: var(--bg); }

.lang-dropdown-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

/* ===== Main / Sidebar / Content ===== */
.main {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - var(--header-h));
  padding: 20px 14px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
}

.sidebar-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  padding: 0 10px 12px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.sidebar-link:hover { background: var(--bg); }

.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.sidebar-icon { font-size: 18px; line-height: 1; }

.content {
  flex: 1;
  min-width: 0;
  padding: 28px 24px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
  z-index: 25;
}

.overlay.visible { opacity: 1; visibility: visible; }

/* ===== Converter page ===== */
.converter-page {
  max-width: 640px;
  margin: 0 auto;
}

.page-header { margin-bottom: 24px; }

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.converter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.converter-form { display: flex; flex-direction: column; gap: 18px; }

.input-group { display: flex; flex-direction: column; gap: 8px; }

.input-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input,
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  appearance: auto;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}

.unit-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-hover);
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .3s, background .15s, border-color .15s;
}

.swap-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: rotate(180deg);
}

.result-group { display: flex; flex-direction: column; gap: 8px; }

.result-label { margin-top: 4px; }

/* ===== Home page ===== */
.home-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  align-items: stretch;
}

.home-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px 32px;
  width: 100%;
}

.home-header { margin-bottom: 24px; }

.home-title {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.card-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.card-body { min-width: 0; }

.card-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
}

.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  margin-left: auto;
  font-size: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform .15s, color .15s;
}

.category-card:hover .card-arrow {
  transform: translateX(3px);
  color: var(--accent);
}

/* ===== Privacy page ===== */
.privacy-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 0;
}

.privacy-page h1 { font-size: 28px; font-weight: 800; }

.privacy-page h2 { font-size: 18px; font-weight: 700; margin-top: 24px; }

.privacy-page p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

/* ===== Footer ===== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);

}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.footer-text { margin: 0; font-size: 13px; color: var(--text-secondary); }

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

.footer-link {
  font-size: 13px;
  color: var(--accent-hover);
  text-decoration: none;
}

.footer-link:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .menu-toggle { display: flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 26;
    transform: translateX(-100%);
    transition: transform .25s ease;
    min-height: 0;
    overflow-y: auto;
  }

  .sidebar.open { transform: translateX(0); }

  .content { padding: 20px 16px; }

  .category-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .unit-row { grid-template-columns: 1fr; }
  .swap-btn {
    width: 100%;
    transform: rotate(90deg);
  }
  .swap-btn:hover { transform: rotate(90deg); }
  .converter-card { padding: 20px; }
  .result-value { font-size: 26px; }
  .home-title { font-size: 26px; }
  .home-section-title { font-size: 24px; }
}


/* ===== Result box ===== */
.result-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 16px 20px;
  min-height: 68px;
}

.result-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  word-break: break-word;
}

.result-unit {
  font-size: 18px;
  font-weight: 500;
  color: var(--accent-hover);
}

/* ===== Convert button ===== */
.convert-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: #059669;
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.convert-btn:hover {
  background: #047857;
}

.convert-btn:active {
  transform: scale(.97);
}

.convert-btn svg {
  flex-shrink: 0;
}

/* ===== Copy button ===== */
.copy-btn {
  flex-shrink: 0;
  margin-left: auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(22, 163, 74, .2);
  background: transparent;
  color: rgba(22, 163, 74, .55);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}

.copy-btn:hover {
  background: rgba(22, 163, 74, .08);
  border-color: rgba(22, 163, 74, .4);
  color: #16a34a;
}

.copy-btn:active {
  transform: scale(.92);
}

.copy-btn.copied {
  background: rgba(22, 163, 74, .12);
  border-color: #16a34a;
  color: #15803d;
}

/* ===== Empty result state ===== */
  display: flex;
}

/* ===== Cookie consent banner ===== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, .1);
  padding: 16px 20px;
}

.cookie-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.cookie-banner-text {
  flex: 1;
  min-width: 280px;
}

.cookie-banner-text p {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.cookie-banner-text a {
  font-size: 13px;
  color: var(--accent-hover);
  text-decoration: underline;
}

.cookie-banner-text a:hover {
  color: var(--accent);
}

.cookie-banner-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.cookie-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cookie-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.cookie-btn-secondary {
  color: var(--text-secondary);
}

.cookie-btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-secondary);
  color: var(--text);
}

@media (max-width: 600px) {
  .cookie-banner-inner {
    flex-direction: column;
    align-items: flex-start;
    text-align: center;
  }
  .cookie-banner-actions {
    justify-content: center;
  }
}

/* ===== Category description (below converter) ===== */
.category-description {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  line-height: 1.7;
  font-size: 14px;
  color: var(--text-secondary);
}

.category-description p {
  margin: 0 0 12px;
}

.category-description p:last-child {
  margin-bottom: 0;
}

.category-description strong {
  color: var(--text);
  font-weight: 600;
}

/* ===== Extended units toggle ===== */
.extended-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
}

.extended-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.extended-toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.extended-toggle:hover .extended-toggle-label {
  color: var(--text);
}

/* ===== Units list section (below description) ===== */
.units-list-section {
  margin-top: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  line-height: 1.6;
}

.units-list-label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.units-list-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== Units lists (below description) ===== */
.units-lists {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.units-list-section {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.units-list-label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.units-list-items {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
  columns: 4;
  column-gap: 20px;
}

.units-list-items li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  break-inside: avoid;
  padding-right: 8px;
}

.units-list-items-extended {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
  columns: 4;
  column-gap: 20px;
}

.units-list-items-extended li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  break-inside: avoid;
  padding-right: 8px;
}

@media (max-width: 900px) {
  .units-list-items,
  .units-list-items-extended {
    columns: 3;
  }
}

@media (max-width: 560px) {
  .units-list-items,
  .units-list-items-extended {
    columns: 2;
  }
}

/* ===== Header navigation links ===== */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 16px;
}

.header-nav-link {
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.header-nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent);
  font-weight: 600;
}

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



/* ===== Calculator ===== */
.calculator-page {
  margin: 0 auto;
}

.calculator-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.calculator-display {
  background: #0f172a;
  color: #fff;
  padding: 24px 24px 20px;
  text-align: right;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

.calc-expression {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  font-weight: 400;
  min-height: 24px;
  word-break: break-all;
  line-height: 1.3;
}

.calc-result {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  word-break: break-all;
  transition: font-size .1s;
}

.calculator-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: var(--border);
  padding: 2px;
}

.calc-btn {
  border: none;
  background: var(--surface);
  padding: 20px 8px;
  font-size: 22px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .1s;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  border-radius: 4px;
}

.calc-btn-num {
  font-size: 32px;
  font-weight: 500;
}

.calc-btn-equals {
  font-size: 28px;
}

/* ===== Calculator copy button ===== */
.calc-copy-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  padding: 0;
}

.calc-copy-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.7);
}

.calc-copy-btn:active {
  transform: scale(0.92);
}

.calc-copy-btn.copied {
  background: rgba(22, 163, 74, 0.3);
  border-color: rgba(22, 163, 74, 0.5);
  color: #4ade80;
}

/* ===== Calculator layout with history ===== */
.calculator-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 900px;
  margin: 0 auto;
}

.calculator-page {
  flex: 1;
  min-width: 0;
  max-width: none;
}



.calculator-history {
  width: 280px;
  flex-shrink: 0;
  background: #f8fafc;
  border: 1px solid #e9edf2;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.calc-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e9edf2;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.calc-history-clear {
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.calc-history-clear:hover {
  background: var(--bg);
  color: #ef4444;
}

.calc-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.calc-history-list::-webkit-scrollbar {
  width: 5px;
}

.calc-history-list::-webkit-scrollbar-track {
  background: transparent;
}

.calc-history-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.calc-history-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.calc-history-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 4px;
}

.calc-history-item:hover {
  background: #eef2f6;
}

.calc-history-item:active {
  background: #e2e8f0;
}

.calc-history-item:last-child {
  margin-bottom: 0;
}

.calc-history-expr {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.3;
}

.calc-history-result {
  font-size: 16px;
  font-weight: 700;
  color: #334155;
  margin-top: 2px;
}

.calc-history-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
}

/* ===== Calculator description ===== */
.calculator-description {
  max-width: 820px;
  margin: 20px auto 0;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.calculator-description h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}



@media (max-width: 750px) {
  .calculator-layout {
    flex-direction: column-reverse;
    align-items: flex-start;
  }
  .calculator-history {
    width: 100%;
    max-height: 200px;
  }
  .calculator-description ul li {
    width: 100%;
  }
}

/* ===== Calculator description divider ===== */
.calc-features-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.calc-features-subtitle {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.calc-features-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
}

.calc-features-list li {
  width: 50%;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 18px;
  position: relative;
}

.calc-features-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 750px) {
  .calc-features-list li {
    width: 100%;
  }
}

/* ===== Mobile nav toggle ===== */
.mobile-nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.header-nav-mobile {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  z-index: 30;
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: flex;
  }
  
  .header-nav {
    display: none;
  }
  
  .header-nav-mobile {
    display: none;
  }
  
  .header-nav-mobile.open {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .header-nav-mobile .header-nav-link {
    display: block;
    padding: 12px 16px;
    font-size: 15px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
  }
  
  .header-nav-mobile .header-nav-link:hover,
  .header-nav-mobile .header-nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: var(--accent);
  }
}

/* ===== Engineering Calculator ===== */
.eng-page {
  max-width: 100%;
  margin: 0 auto;
  padding-top: 0;
}

.eng-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.eng-calculator {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.eng-display {
  position: relative;
  background: #0f172a;
  color: #fff;
  padding: 20px 24px 16px;
  text-align: right;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.eng-mode-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.eng-copy-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px; height: 32px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  padding: 0;
}

.eng-copy-btn:hover {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.35);
}

.eng-copy-btn:active { transform: scale(0.92); }

.eng-copy-btn.copied {
  background: rgba(22, 163, 74, 0.3);
  color: #4ade80;
  border-color: rgba(22, 163, 74, 0.5);
}

.eng-expression {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
  font-weight: 400;
  min-height: 20px;
  word-break: break-all;
  line-height: 1.3;
}

.eng-result {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  word-break: break-all;
  min-height: 52px;
}

.eng-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
}

.eng-btn {
  border: none;
  background: var(--surface);
  padding: 14px 6px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .1s;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.eng-btn:hover { background: #f1f5f9; }
.eng-btn:active { background: #e2e8f0; }

.eng-btn-num { font-size: 17px; font-weight: 600; }

.eng-btn-op {
  background: #f8fafc;
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
}

.eng-btn-op:hover { background: #f0fdf4; }
.eng-btn-op:active { background: #dcfce7; }

.eng-btn-sci {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
}

.eng-btn-sci:hover { background: #eef2f6; }
.eng-btn-sci:active { background: #e2e8f0; }

/* Engineering color groups */
.eng-btn-trig {
  background: #eff6ff;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 600;
}
.eng-btn-trig:hover { background: #dbeafe; }
.eng-btn-trig:active { background: #bfdbfe; }

.eng-btn-power {
  background: #f5f3ff;
  color: #8b5cf6;
  font-size: 13px;
  font-weight: 600;
}
.eng-btn-power:hover { background: #ede9fe; }
.eng-btn-power:active { background: #ddd6fe; }

.eng-btn-log {
  background: #fffbeb;
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
}
.eng-btn-log:hover { background: #fef3c7; }
.eng-btn-log:active { background: #fde68a; }

.eng-btn-hyper {
  background: #ecfeff;
  color: #06b6d4;
  font-size: 11px;
  font-weight: 600;
}
.eng-btn-hyper:hover { background: #cffafe; }
.eng-btn-hyper:active { background: #a5f3fc; }

.eng-btn-special {
  background: #fdf2f8;
  color: #ec4899;
  font-size: 12px;
  font-weight: 600;
}
.eng-btn-special:hover { background: #fce7f3; }
.eng-btn-special:active { background: #fbcfe8; }

.eng-btn-clear {
  color: #ef4444;
  font-weight: 700;
  font-size: 15px;
}

.eng-btn-clear:hover { background: #fef2f2; }

.eng-btn-func {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
}

.eng-btn-mode {
  color: #6366f1;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.eng-btn-mode:hover { background: #eef2ff; }

.eng-btn-mem {
  font-size: 11px;
  font-weight: 600;
  color: #6366f1;
}

.eng-btn-mem:hover { background: #eef2ff; }

.eng-btn-equals {
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.eng-btn-equals:hover { background: var(--accent-hover); }
.eng-btn-equals:active { background: #047857; }

/* ===== Engineering History ===== */
.eng-history {
  margin-top: 20px;
  background: #f8fafc;
  border: 1px solid #e9edf2;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.eng-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e9edf2;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.eng-history-clear {
  border: none;
  background: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.eng-history-clear:hover {
  background: #f1f5f9;
  color: #ef4444;
}

.eng-history-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px 12px;
}

.eng-history-list::-webkit-scrollbar { width: 5px; }
.eng-history-list::-webkit-scrollbar-track { background: transparent; }
.eng-history-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.eng-history-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 2px;
}

.eng-history-item:hover { background: #eef2f6; }

.eng-history-expr {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.3;
}

.eng-history-result {
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  margin-top: 1px;
}

.eng-history-empty {
  padding: 30px 20px;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
}

/* ===== Engineering color legend ===== */
.eng-color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.eng-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.eng-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .eng-buttons {
    grid-template-columns: repeat(5, 1fr);
  }
  .eng-result { font-size: 30px; }
  .eng-btn { padding: 12px 4px; font-size: 12px; }
  .eng-btn-num { font-size: 15px; }
}

@media (max-width: 480px) {
  .eng-buttons {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Placeholder page ===== */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  min-height: 50vh;
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 24px;
  line-height: 1;
}

.placeholder-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--text);
}

.placeholder-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 0;
}

/* ===== Header nav links ===== */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-nav-link {
  display: block;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.header-nav-link:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.header-nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

/* Ensure nav doesn't wrap on smaller screens */
@media (max-width: 900px) {
  .header-nav-link {
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .header-nav {
    display: none;
  }
}

/* ===== Home calculators section ===== */
.home-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0 24px;
}

.home-section-header {
  margin-bottom: 24px;
}

.home-section-title {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

/* ===== Scroll to Top Button ===== */
.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity .25s ease, visibility .25s ease, transform .25s ease, background .15s;
  z-index: 100;
  padding: 0;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.45);
}

.scroll-top-btn:active {
  transform: scale(0.92);
}

.scroll-top-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
