/* ============================================================
   PhotoCalc — Hasselblad-inspired minimal design system
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --bg:           #eeeeee;
  --surface:      #ffffff;
  --surface-2:    #ffffff;
  --surface-3:    #f5f5f5;
  --text:         #111111;
  --text-muted:   #555555;
  --text-dim:     #777777;
  --border:       rgba(0,0,0,0.15);
  --border-light: rgba(0,0,0,0.08);
  --accent:       #ffcc00;
  --accent-dim:   rgba(255,204,0,0.32);
  --danger:       #ff4d4d;
  --success:      #2e7d32;
  --radius:       8px;
  --font:         'Inter', -apple-system, sans-serif;
  --ease:         cubic-bezier(0.25, 0.8, 0.25, 1);
  --dur:          0.22s;
  --sidebar-w:    240px;
  --pattern-color: hsla(215, 20%, 70%, 0.18);
  --anim-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-light {
  --bg:           #eeeeee;
  --surface:      #ffffff;
  --surface-2:    #ffffff;
  --surface-3:    #f5f5f5;
  --text:         #111111;
  --text-muted:   #555555;
  --text-dim:     #777777;
  --border:       rgba(0,0,0,0.15);
  --border-light: rgba(0,0,0,0.08);
  --accent:       #ffcc00;
  --accent-dim:   rgba(255,204,0,0.32);
  --danger:       #cc0000;
  --success:      #009933;
  --pattern-color: hsla(215, 20%, 70%, 0.18);
}

.theme-dark {
  --bg:           #121212;
  --surface:      #1e1e1e;
  --surface-2:    #1e1e1e;
  --surface-3:    #2d2d2d;
  --text:         #eeeeee;
  --text-muted:   #aaaaaa;
  --text-dim:     #777777;
  --border:       rgba(255,255,255,0.15);
  --border-light: rgba(255,255,255,0.08);
  --accent:       #ffcc00;
  --accent-dim:   rgba(255,204,0,0.32);
  --danger:       #ff4d4d;
  --success:      #2e7d32;
  --pattern-color: hsla(215, 20%, 60%, 0.10);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- Navbar --- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
  flex-shrink: 0;
  background: var(--surface);
  z-index: 10;
}

.logo {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text);
}

.sidebar-logo-container:hover .iris-logo {
  transform: rotate(30deg);
}

.controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.lang-select {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 1px;
  cursor: pointer;
  outline: none;
  appearance: none;
  padding: 0 8px;
  transition: color var(--dur);
}
.lang-select:hover { color: var(--text); }
.lang-select option { background: var(--surface-2); color: var(--text); }

.theme-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius);
  transition: color var(--dur);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 24px; height: 24px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
  max-width: 100%;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-2);
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  opacity: 0;
}

.sidebar.animate-in {
  animation: slide-in-side 0.6s var(--ease) forwards;
}

@keyframes slide-in-side {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.sidebar-copyright {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  padding: 24px;
  margin-top: auto;
  border-top: 1px solid var(--surface-3);
  opacity: 0.7;
}

.sidebar-group-label {
  padding: 24px 24px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar nav ul {
  list-style: none;
  margin-bottom: 8px;
}

.sidebar nav ul li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  font-size: 16px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur), background var(--dur), font-weight var(--dur);
  white-space: nowrap;
}
.sidebar nav ul li a .nav-icon {
  width: 16px;
  height: 16px;
}
.sidebar nav ul li a:hover { color: var(--text); background: var(--surface-3); }
.sidebar nav ul li a.active {
  color: #111111 !important;
  background: var(--accent);
  font-weight: 700;
}
.sidebar nav ul li a.active svg {
  color: #111111 !important;
}

/* --- Content --- */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 16px;
  padding: 16px;
  height: 100vh;
  box-sizing: border-box;
  min-width: 0;
}

.calculator-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.calc-card-inputs,
.calc-card-results,
.calc-card-info,
.calc-card-appearance,
.visualization-container,
.results-panel {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  min-width: 0;
  opacity: 0;
  transform: translateY(20px);
}

.animate-card {
  animation: slide-in-bottom-fade 0.5s var(--anim-ease) forwards;
}

@keyframes slide-in-bottom-fade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }
.stagger-7 { animation-delay: 0.7s; }

/* Hide scrollbar for Chrome, Safari, and Opera */
.calc-card-inputs::-webkit-scrollbar,
.calc-card-results::-webkit-scrollbar,
.calc-card-info::-webkit-scrollbar,
.calc-card-appearance::-webkit-scrollbar,
.visualization-container::-webkit-scrollbar,
.results-panel::-webkit-scrollbar {
  display: none;
}

.calc-card-inputs {
  grid-column: 1;
  grid-row: 1;
  height: auto;
}

.calc-card-results {
  grid-column: 2;
  grid-row: 1;
  height: auto;
}

.calc-card-info {
  grid-column: 1;
  grid-row: 2;
  height: auto;
}

.visualization-container {
  background: var(--surface-2);
  align-items: center;
  justify-content: center;
  position: static;
  height: 180px;
  min-height: 180px;
  max-height: 180px;
  overflow: hidden;
  width: 100%;
  padding: 0 !important;
  grid-column: 1 / span 2;
}

.calc-card-appearance {
  grid-column: 2;
  grid-row: 2;
  height: auto;
}

/* --- Settings Page Specific Overrides --- */
.is-settings-page .visualization-container {
  display: none !important;
}

/* --- Table Page Specific Overrides --- */
.is-table-page .calc-card-inputs,
.is-table-page .calc-card-info {
  height: auto !important;
}
.is-table-page .calc-card-info {
  grid-column: 2;
  grid-row: 1;
}
.is-table-page .results-panel {
  grid-column: 1 / span 2;
  grid-row: 2;
  height: auto !important;
}
.is-table-page .visualization-container {
  display: none !important;
}

/* --- Optics Page Specific Overrides --- */
.is-optics-page .visualization-container {
  display: none !important;
}
.is-optics-page .calc-card-info {
  display: none !important;
}

/* --- Exposure Page Specific Overrides --- */
.is-exposure-page .visualization-container {
  display: none !important;
}
.is-exposure-page .calc-card-info {
  display: none !important;
}

/* --- DoF Page Specific Overrides --- */
.is-dof-page .calc-card-inputs,
.is-dof-page .calc-card-results,
.is-dof-page .results-panel {
  height: auto !important;
}
.is-dof-page .calc-card-info {
  display: none !important;
}
.is-dof-page .visualization-container {
  height: 180px !important;
  min-height: 180px !important;
  max-height: 180px !important;
  padding: 0 !important;
}
.is-dof-page .visualization-container svg {
  width: 100%;
  max-width: none;
  height: 180px;
}
.visualization-container svg text {
  letter-spacing: 0.5px;
}

/* ============================================================
   CALCULATOR COMPONENTS
   ============================================================ */

/* --- Title --- */
.calc-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.calc-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* --- Section divider --- */
.calc-section {
  background: var(--surface-2);
  padding: 24px;
  border-radius: 0.5rem;
  margin-top: 24px;
}
.calc-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* --- iOS-style Segmented Control --- */
.option-row {
  display: flex;
  padding: 4px;
  background: var(--surface-3);
  border-radius: 9999px;
  gap: 4px;
  margin-bottom: 24px;
  position: relative;
}
.option-pill {
  flex: 1;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font);
  transition: color var(--dur);
  text-align: center;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}
.option-pill:hover {
  color: var(--text);
}
.option-pill.active {
  color: var(--text);
  font-weight: 700;
}
.option-slider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  z-index: 1;
  background: var(--surface-2);
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1), width 0.28s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

/* --- iOS Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-3);
  transition: var(--dur);
  border-radius: 24px;
}
.slider-switch:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: var(--dur);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider-switch {
  background-color: var(--accent);
}
input:checked + .slider-switch:before {
  transform: translateX(20px);
}

/* --- Toggle switch --- */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.toggle-label {
  font-size: 16px;
  color: var(--text-muted);
}
.toggle {
  width: 40px;
  height: 24px;
  background: var(--surface-3);
  border: none;
  border-radius: 24px;
  cursor: pointer;
  position: relative;
  transition: background var(--dur);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur), background var(--dur);
}
.toggle.on { background: var(--accent-dim); }
.toggle.on::after { transform: translateX(16px); background: var(--accent); }

/* --- Form group (label + slider + number) --- */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-group label .unit {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: none;
  font-weight: 400;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.form-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  background: var(--surface-3);
  outline: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform var(--dur);
}
.form-slider::-webkit-slider-thumb:hover { transform: scale(1.1); }
.form-slider::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  cursor: pointer;
}

.form-number {
  width: 80px;
  background: var(--surface-3);
  border: none;
  color: var(--text);
  font-size: 16px;
  padding: 8px 16px;
  font-family: var(--font);
  text-align: right;
  border-radius: var(--radius);
  outline: none;
  -moz-appearance: textfield;
}
.form-number::-webkit-outer-spin-button,
.form-number::-webkit-inner-spin-button { -webkit-appearance: none; }

.form-select {
  width: 100%;
  background: var(--surface-3);
  border: none;
  color: var(--text);
  font-size: 16px;
  padding: 16px;
  font-family: var(--font);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}
.form-select option { background: var(--surface-3); }

/* Lock button (for framing lock) */
.lock-btn {
  background: var(--surface-3);
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 16px;
  font-size: 16px;
  font-family: var(--font);
  transition: all var(--dur);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.lock-btn:hover { color: var(--text); background: var(--surface); }
.lock-btn.locked { color: var(--accent); background: var(--accent-dim); }
.lock-btn svg { width: 16px; height: 16px; }

/* ============================================================
   RESULTS PANEL
   ============================================================ */
.results-panel {
  grid-column: 2;
  grid-row: 1;
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
}

.info-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 24px;
  height: fit-content;
}

.info-container:has(.lock-btn) {
  grid-template-columns: 1fr auto 1fr;
}

.info-slanted-card {
  padding: 12px 20px;
  border-radius: 0.5rem;
  background: var(--surface-2);
  height: 100%;
  box-sizing: border-box;
}

/* Custom layout for stacked lock button in info container row */
.info-slanted-card.lock-btn {
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  background-color: rgba(255, 204, 0, 0.18) !important; /* light yellow background */
  padding: 12px 20px !important;
  border: none !important;
  color: #111111 !important; /* neutral dark text */
  display: flex !important;
  width: fit-content !important; /* hug contents */
  height: 100% !important; /* match height on both sides */
  box-sizing: border-box !important;
  transition: all var(--dur) !important;
}
.theme-dark .info-slanted-card.lock-btn {
  background-color: rgba(255, 204, 0, 0.12) !important;
  color: var(--accent) !important; /* high contrast bright yellow in dark mode */
}
.info-slanted-card.lock-btn span {
  text-align: center !important;
  line-height: 1.2 !important;
  display: block !important;
}
.info-slanted-card.lock-btn:not(.locked):hover {
  color: #111111 !important;
  background-color: var(--accent) !important; /* hover accent colored */
}
.info-slanted-card.lock-btn.locked {
  color: #111111 !important;
  background-color: var(--accent) !important; /* triggered background remains accent colored */
}
.info-slanted-card.lock-btn.locked:hover {
  color: #111111 !important;
  background-color: rgba(255, 204, 0, 0.18) !important;
}
.theme-dark .info-slanted-card.lock-btn.locked:hover {
  color: var(--accent) !important;
  background-color: rgba(255, 204, 0, 0.12) !important;
}
.info-slanted-card.lock-btn svg {
  width: 16px !important;
  height: 16px !important;
  margin-bottom: 2px !important;
}

.slanted-pattern {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    var(--pattern-color) 3px,
    var(--pattern-color) 4px
  );
  border: none;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.results-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.results-grid.cols-1 { grid-template-columns: 1fr; }

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

.result-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.result-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}
.result-value.accent { color: var(--text); font-weight: 600; }
.result-value.muted { font-size: 16px; color: var(--text-muted); }
.result-value.large { font-size: 24px; }
.result-unit {
  font-size: 16px;
  color: var(--text-dim);
  margin-left: 8px;
}

/* DoF bar */
.dof-bar-container {
  margin-top: 24px;
  padding: 16px;
  background: var(--surface-3);
  border-radius: 0.5rem;
}
.dof-bar-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.dof-bar-track {
  height: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.dof-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--accent);
  border-radius: var(--radius);
  transition: left var(--dur), width var(--dur);
}
.dof-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Blur quality indicator */
.blur-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.blur-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}
.blur-dot.good { background: var(--success); }
.blur-dot.neutral { background: var(--accent); }
.blur-dot.bad { background: var(--danger); }
.blur-quality-text { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   TABLE STYLES
   ============================================================ */
.calc-table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
  border-radius: 0.5rem;
  background: var(--surface-2);
}
.calc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 16px;
}
.calc-table th {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    var(--pattern-color) 3px,
    var(--pattern-color) 4px
  );
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 16px;
  text-align: right;
  white-space: nowrap;
}
.calc-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface-2);
  border-right: 1px solid var(--border-light);
}
.calc-table td {
  padding: 16px;
  text-align: right;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.calc-table td:first-child {
  text-align: left;
  color: var(--text);
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
  border-right: 1px solid var(--border-light);
}
.calc-table tr:nth-child(even) td { background: var(--surface); }
.calc-table tr:nth-child(even) td:first-child { background: var(--surface); }
.calc-table tr:hover td { background: var(--surface-3); }
.calc-table tr:hover td:first-child { background: var(--surface-3); }
.calc-table .cell-accent { color: var(--accent); font-weight: 600; }
.calc-table .cell-inf { color: var(--text-dim); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* --- Sidebar Scaling and 2-Column Results (1025px - 1440px) ---
   Lateral menu remains. When space is tight, results drop to 2 columns.
   ------------------------------------------------ */
@media (max-width: 1350px) {
  .results-grid.cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* --- Hamburger Menu Breakpoint (<= 1024px) ---
   Sidebar converts to fixed header with hamburger toggle.
   Cards stack vertically.
   ------------------------------------------------ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 100%; }
  
  /* Fixed Mobile Sidebar Header */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    padding: 0 20px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: transparent !important;
    border-bottom: none !important;
    z-index: 1000 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }
  
  /* Flat white header background stacked above the nav but below logo/button */
  .sidebar::before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 70px !important;
    background: var(--surface) !important;
    z-index: 5 !important;
  }
  
  .sidebar-logo-container {
    padding: 0 !important;
    margin-bottom: 0 !important;
    border-bottom: none !important;
    order: 1 !important;
    position: relative !important;
    z-index: 10 !important;
  }
  
  .sidebar-logo-container .tagline {
    display: none !important;
  }
  
  /* Hamburger Menu Toggle Button */
  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none !important;
    border: none !important;
    color: var(--text) !important;
    order: 2 !important;
    cursor: pointer !important;
    padding: 8px !important;
    transition: color var(--dur) !important;
    position: relative !important;
    z-index: 10 !important;
  }
  .menu-toggle:hover {
    color: var(--accent) !important;
  }
  
  .menu-toggle svg line {
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease) !important;
    transform-origin: 12px 12px !important;
    transform-box: viewBox !important;
  }
  
  .sidebar.menu-open .menu-toggle .line-mid {
    opacity: 0 !important;
  }
  
  .sidebar.menu-open .menu-toggle .line-top {
    transform: rotate(45deg) translateY(6px) !important;
  }
  
  .sidebar.menu-open .menu-toggle .line-bot {
    transform: rotate(-45deg) translateY(-6px) !important;
  }
  
  /* Hide copyright on mobile */
  .sidebar-copyright {
    display: none !important;
  }
  
  .sidebar-group-label {
    display: block !important;
    padding: 12px 24px 4px !important;
  }
  
  /* Dropdown Navigation Menu (Open from Top-Down) */
  .sidebar nav {
    position: fixed !important;
    top: 70px !important;
    left: 0 !important;
    width: 100% !important;
    background: var(--surface) !important;
    padding: 16px 0 24px 0 !important;
    box-sizing: border-box !important;
    z-index: 1 !important;
    max-height: calc(100vh - 70px) !important;
    overflow-y: auto !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    border-bottom: 1px solid var(--surface-3) !important;
    
    /* Animation: slide down and fade in from behind header */
    display: block !important;
    opacity: 1 !important;
    transform: translateY(-100%) !important;
    pointer-events: none !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  
  .sidebar.menu-open nav {
    transform: translateY(0) !important;
    pointer-events: auto !important;
  }
  
  .sidebar nav ul {
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    gap: 0 !important;
  }
  
  .sidebar nav ul li {
    width: 100% !important;
  }
  
  .sidebar nav ul li a {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 16px 24px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    transition: color var(--dur), background var(--dur) !important;
    border-radius: 0 !important;
  }
  
  .sidebar nav ul li a:hover {
    color: var(--text) !important;
    background: var(--surface-3) !important;
  }
  
  .sidebar nav ul li a.active {
    background: var(--accent) !important;
    color: #111111 !important;
    font-weight: 700 !important;
  }
  
  .sidebar nav ul li a.active svg {
    color: #111111 !important;
  }
  
  /* Shift App Layout for Fixed Hamburger Header */
  .app-container {
    height: auto !important;
  }
  
  .content-area {
    padding-top: 86px !important; /* 70px header + 16px standard padding */
    height: auto !important;
  }

  /* Keep side-by-side for tablets */
  .main-layout {
    flex-direction: row !important;
  }
  .calculator-container {
    grid-template-columns: 1fr 1fr !important;
  }
  .results-grid.cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* --- Stacked Cards & Layout Adjustments (<= 768px) ---
   ------------------------------------------------ */
@media (max-width: 768px) {
  .content-area {
    padding-top: 86px !important;
  }
  .main-layout {
    flex-direction: column !important;
  }
  .calculator-container {
    grid-template-columns: 1fr !important;
  }
  .results-grid.cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
  
  .content-area,
  .content-area.is-dof-page,
  .content-area.is-settings-page,
  .content-area.is-table-page {
    display: flex !important;
    flex-direction: column !important;
    padding: 16px !important;
    gap: 16px !important;
  }
  
  .calc-card-inputs,
  .calc-card-results,
  .results-panel,
  .calc-card-info,
  .calc-card-appearance {
    width: 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    grid-column: auto !important;
    grid-row: auto !important;
  }
  
  .calc-title {
    font-size: 20px !important;
  }
}

/* --- 2-Column Results Grid (<= 767px) ---
   Results grid drops from 3 columns to 2 columns.
   ------------------------------------------------ */
@media (max-width: 767px) {
  .results-grid.cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* --- Dedicated Mobile Phone Breakpoint (<= 480px) --- */
@media (max-width: 480px) {
  /* Stack telemetry/slanted card metadata container rows */
  .info-container,
  .info-container:has(.lock-btn) {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }

  .info-slanted-card.lock-btn {
    width: 100% !important;
    height: auto !important;
    padding: 12px 16px !important;
  }

  /* Prevent labels and units from clashing/overlapping by stacking them vertically */
  .form-group label {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
  }

  /* Premium horizontal scroll-swipe track for segmented choice pills */
  .option-row {
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important; /* Hide scrollbars */
  }
  .option-row::-webkit-scrollbar {
    display: none !important; /* Hide scrollbars Chrome/Safari */
  }
  .option-pill {
    flex: 1 0 auto !important; /* Do not let pills shrink past natural readable width */
    white-space: nowrap !important;
    padding: 8px 14px !important;
  }
}

/* --- 1-Column Results Grid (<= 374px) ---
   Results grid drops to single column for smallest screens (320px).
   ------------------------------------------------ */
@media (max-width: 374px) {
  .results-grid,
  .results-grid.cols-3,
  .results-grid.cols-1 {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.items-center { align-items: center; }

/* ============================================================
   CALCULATOR GUIDE & WALKTHROUGHS
   ============================================================ */
.calculator-guide-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2.5rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 20px rgba(0,0,0,0.02);
  opacity: 0;
  transform: translateY(20px);
}

.calculator-about-card {
  grid-column: 1;
}

.calculator-how-card {
  grid-column: 2;
}

@media (max-width: 768px) {
  .calculator-about-card,
  .calculator-how-card {
    grid-column: 1 / span 1 !important;
  }
}

.guide-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.5px;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.guide-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  stroke-width: 2.5;
  flex-shrink: 0;
}

.guide-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.guide-theory-box {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 1.25rem;
}

.guide-theory-box strong {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}

.step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.step-list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.22s var(--ease);
}

.step-list li:hover .step-number {
  background: var(--accent);
  color: #111111;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-content strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.step-content span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
