/* ─── BendWyze Design System ─────────────────────────────────────────────── */
/* Dark industrial theme — amber accent, charcoal surfaces, white text        */

/* ─── Font Loading ──────────────────────────────────────────────────────────── */
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600&f[]=cabinet-grotesk@700,800&display=swap');

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overscroll-behavior: none;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1,h2,h3,h4,h5,h6 { line-height: 1.2; }
p, li { max-width: 72ch; text-wrap: pretty; }
button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ─── Design Tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Fonts */
  --font-body:    'General Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', Arial, sans-serif;

  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* BendWyze Palette — Dark Industrial */
  --color-bg:          #121212;
  --color-surface:     #1a1a1a;
  --color-surface-2:   #222222;
  --color-surface-3:   #2a2a2a;
  --color-border:      #333333;
  --color-divider:     #2a2a2a;

  --color-text:        #f0f0f0;
  --color-text-muted:  #999999;
  --color-text-faint:  #666666;

  /* Amber / Orange accent */
  --color-amber:       #FF8C00;
  --color-amber-dim:   #E67E22;
  --color-amber-glow:  rgba(255, 140, 0, 0.15);
  --color-amber-glow-strong: rgba(255, 140, 0, 0.25);
  --color-amber-text:  #FFB347;

  /* Status */
  --color-success: #4CAF50;
  --color-error:   #EF5350;
  --color-info:    #42A5F5;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  --shadow-amber: 0 0 20px rgba(255, 140, 0, 0.2);

  /* Layout */
  --bottom-nav-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── App Shell ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
}

.logo-svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

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

.header-actions {
  display: flex;
  gap: var(--space-2);
}

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  -webkit-overflow-scrolling: touch;
}

/* ─── Tab Panels ─────────────────────────────────────────────────────────────── */
.tab-panel {
  display: none;
  animation: fadeIn 200ms ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Bottom Navigation ──────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-1);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: 500;
  transition: color var(--transition);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-tab:active {
  background: rgba(255, 140, 0, 0.05);
}

.nav-tab.active {
  color: var(--color-amber);
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--color-amber);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.nav-tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tab.active svg {
  stroke-width: 2;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ─── Calculator Tab ─────────────────────────────────────────────────────────── */
.calc-header {
  padding: var(--space-4);
  padding-bottom: 0;
}

.calc-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-amber);
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.calc-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Calculator Selector Grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-4);
}

.calc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.calc-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-amber-glow);
  opacity: 0;
  transition: opacity var(--transition);
}

.calc-card:active::before {
  opacity: 1;
}

.calc-card:active {
  border-color: var(--color-amber-dim);
  transform: scale(0.98);
}

.calc-card-icon {
  font-size: 22px;
  line-height: 1;
}

.calc-card-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.calc-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* ─── Active Calculator Panel ────────────────────────────────────────────────── */
.calculator-panel {
  display: none;
  padding: var(--space-4);
  gap: var(--space-5);
  flex-direction: column;
}

.calculator-panel.active {
  display: flex;
}

.calc-back-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-amber);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) 0;
  margin-bottom: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.calc-back-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calc-panel-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1;
}

.calc-panel-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: var(--space-1);
}

/* ─── Input Groups ───────────────────────────────────────────────────────────── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-wrap {
  position: relative;
}

.field-input {
  width: 100%;
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 54px;
  line-height: 1;
}

.field-input:focus {
  outline: none;
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px var(--color-amber-glow-strong);
}

.field-input::placeholder {
  color: var(--color-text-faint);
}

.input-unit {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  pointer-events: none;
}

/* Angle Selector */
.angle-selector {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.angle-btn {
  flex: 1;
  min-width: 56px;
  padding: var(--space-3) var(--space-2);
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.angle-btn:active, .angle-btn.selected {
  background: var(--color-amber-glow);
  border-color: var(--color-amber);
  color: var(--color-amber);
  box-shadow: 0 0 0 1px var(--color-amber-dim);
}

/* Select Dropdown */
.field-select {
  width: 100%;
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  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='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  min-height: 54px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-select:focus {
  outline: none;
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px var(--color-amber-glow-strong);
}

/* Fraction Quick-Pick */
.fraction-chips {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: var(--space-1);
}

.frac-chip {
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.frac-chip:active {
  background: var(--color-amber-glow);
  border-color: var(--color-amber);
  color: var(--color-amber);
}

/* ─── Results Section ────────────────────────────────────────────────────────── */
.results-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.results-header {
  padding: var(--space-4);
  background: rgba(255, 140, 0, 0.05);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.results-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-amber);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.copy-btn:active {
  background: var(--color-amber-glow);
  color: var(--color-amber);
  border-color: var(--color-amber);
}

.copy-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.results-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.result-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.result-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.result-values {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.result-fraction {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.result-decimal {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.result-empty {
  color: var(--color-text-faint);
  font-size: var(--text-base);
  padding: var(--space-4) 0;
  text-align: center;
}

.result-error {
  color: var(--color-error);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  background: rgba(239, 83, 80, 0.1);
  border-radius: var(--radius-md);
}

/* Results Table (for parallel offsets) */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.results-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

.results-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table tr:first-child td {
  color: var(--color-amber);
  font-weight: 600;
}

/* ─── Steps Section ──────────────────────────────────────────────────────────── */
.steps-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.steps-header {
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.steps-list {
  list-style: none;
  padding: var(--space-3) 0;
}

.steps-list li {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: none;
}

.steps-list li::before {
  content: attr(data-step);
  min-width: 22px;
  height: 22px;
  background: var(--color-surface-3);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-amber);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Why This Works (collapsible) ──────────────────────────────────────────── */
.why-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.why-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.why-toggle:active {
  background: var(--color-surface-2);
}

.why-toggle-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.why-icon {
  width: 28px;
  height: 28px;
  background: var(--color-amber-glow);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.why-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.why-chevron {
  width: 20px;
  height: 20px;
  stroke: var(--color-text-faint);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.why-toggle[aria-expanded="true"] .why-chevron {
  transform: rotate(180deg);
}

.why-content {
  display: none;
  padding: var(--space-4);
  padding-top: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.why-content.open {
  display: block;
}

.why-content p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-3);
}

.why-content p:last-child { margin-bottom: 0; }

.formula-display {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-amber);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-3) var(--space-4);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: var(--text-sm);
  color: var(--color-amber-text);
  margin: var(--space-3) 0;
}

/* Field Tips */
.tips-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-amber-dim);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.tips-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-amber);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tips-list li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-left: var(--space-4);
  position: relative;
  line-height: 1.5;
  max-width: none;
}

.tips-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--color-amber-dim);
}

/* ─── Learn Tab ──────────────────────────────────────────────────────────────── */
.learn-list {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.learn-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
}

.learn-card:active {
  background: var(--color-surface-2);
  border-color: var(--color-amber-dim);
}

.learn-icon {
  width: 42px;
  height: 42px;
  background: var(--color-amber-glow);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  color: var(--color-amber);
  font-weight: 700;
}

.learn-card-info {
  flex: 1;
}

.learn-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.learn-card-summary {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
  max-width: none;
}

.learn-chevron {
  width: 16px;
  height: 16px;
  stroke: var(--color-text-faint);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Learn Article View */
.article-panel {
  display: none;
  padding: var(--space-4);
}

.article-panel.active {
  display: block;
}

.article-back {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-amber);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) 0;
  margin-bottom: var(--space-5);
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.article-back svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.article-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--space-5);
}

.article-content h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-amber);
  margin: var(--space-6) 0 var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-content h3:first-child {
  margin-top: 0;
}

.article-content h4 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin: var(--space-4) 0 var(--space-2);
}

.article-content p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-3);
}

.article-content ul, .article-content ol {
  padding-left: var(--space-5);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.article-content li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: none;
}

.article-content strong {
  color: var(--color-text);
  font-weight: 600;
}

.article-content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9em;
  background: var(--color-surface-3);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: var(--color-amber-text);
}

/* Parts diagram */
.parts-diagram {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin: var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.part-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-divider);
}

.part-item:last-child { border-bottom: none; }

.part-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-amber);
  min-width: 100px;
  padding-top: 2px;
}

.part-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: none;
}

/* Marks guide */
.marks-guide {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.mark-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-4);
}

.mark-symbol {
  font-size: 28px;
  color: var(--color-amber);
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.mark-info h4 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.mark-info p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-1);
  max-width: none;
}

/* SVG Diagram */
.svg-diagram {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin: var(--space-3) 0;
  overflow: hidden;
}

.svg-diagram svg {
  width: 100%;
  height: auto;
}

/* Mistake list */
.mistake-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.mistake-item {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-4);
}

.mistake-number {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-amber-dim);
  opacity: 0.5;
  min-width: 32px;
  flex-shrink: 0;
}

.mistake-body h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.mistake-body p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-2);
  max-width: none;
}

.mistake-body p:last-child { margin-bottom: 0; }

/* Example box */
.example-box {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-info);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-4);
  margin: var(--space-3) 0;
}

.example-box p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-2);
}

.example-box p:last-child { margin-bottom: 0; }

/* ─── Reference Tab ──────────────────────────────────────────────────────────── */
.ref-section {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.ref-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.ref-card-header {
  padding: var(--space-4);
  background: rgba(255, 140, 0, 0.04);
  border-bottom: 1px solid var(--color-border);
}

.ref-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-amber);
  margin-bottom: var(--space-1);
}

.ref-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.ref-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ref-table {
  width: 100%;
  min-width: 400px;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.ref-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  white-space: nowrap;
}

.ref-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text-muted);
  vertical-align: top;
  line-height: 1.4;
}

.ref-table tr:last-child td {
  border-bottom: none;
}

.ref-table td:first-child {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.ref-formula {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: var(--text-xs);
  color: var(--color-amber-text);
}

.ref-note {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.5;
}

/* ─── Settings Tab ───────────────────────────────────────────────────────────── */
.settings-section {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.settings-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.settings-group-title {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  min-height: 60px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-info {
  flex: 1;
  padding-right: var(--space-4);
}

.settings-row-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.settings-row-desc {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.3;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-surface-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--color-text-faint);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-amber-glow);
  border-color: var(--color-amber);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--color-amber);
}

/* Segmented Control */
.seg-control {
  display: flex;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.seg-btn.active {
  background: var(--color-surface);
  color: var(--color-amber);
  box-shadow: var(--shadow-sm);
}

/* About section */
.about-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
}

.about-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.about-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}

.about-version {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
}

.about-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.6;
  max-width: 40ch;
  margin: 0 auto var(--space-4);
}

/* ─── Section Headings ───────────────────────────────────────────────────────── */
.tab-section-header {
  padding: var(--space-4) var(--space-4) var(--space-2);
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.tab-section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.tab-section-count {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  padding: var(--space-4);
  text-align: center;
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-4);
}

.app-footer a {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-decoration: none;
  transition: color var(--transition);
}

.app-footer a:hover {
  color: var(--color-text-muted);
}

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.amber { color: var(--color-amber); }
.muted { color: var(--color-text-muted); }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border-width: 0;
}

/* Divider line in results */
.result-divider {
  height: 1px;
  background: var(--color-divider);
  margin: var(--space-1) 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 430px) {
  .calc-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 540px) {
  .calc-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Ensure last row of calc grid fills nicely */
.calc-card:nth-child(7),
.calc-card:nth-child(8) {
  /* Let them flow naturally */
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  white-space: nowrap;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Reduced Motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── v2.0 New Styles ─────────────────────────────────────────────────────── */

/* ─── Diagram Panel ──────────────────────────────────────────────────────── */
.diagram-panel {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.diagram-header {
  padding: var(--space-3) var(--space-4);
  background: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.diagram-header svg {
  width: 14px;
  height: 14px;
  stroke: #3b82f6;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.diagram-body {
  padding: var(--space-4);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diagram-body svg {
  width: 100%;
  height: auto;
  max-height: 340px;
  transition: all 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Animation Carousel ─────────────────────────────────────────────────── */
.anim-carousel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.anim-header {
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 140, 0, 0.07);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-amber);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.anim-header svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.anim-step-count {
  margin-left: auto;
  font-weight: 500;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.anim-frame-area {
  min-height: 170px;
  position: relative;
  overflow: hidden;
}

.anim-frame {
  display: flex;
  flex-direction: column;
  animation: frameSlideIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes frameSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.anim-svg-wrap {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
}

.anim-svg-wrap svg {
  width: 100%;
  height: auto;
  max-height: 130px;
  display: block;
}

.anim-caption {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.anim-subcaption {
  padding: 0 var(--space-4) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.anim-mark-badge {
  display: inline-flex;
  align-items: center;
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-1) var(--space-3);
  background: var(--color-amber-glow);
  border: 1px solid var(--color-amber);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-amber);
  letter-spacing: 0.05em;
}

.anim-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.anim-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.anim-dot.active {
  background: var(--color-amber);
  border-color: var(--color-amber);
  transform: scale(1.2);
}

.anim-nav {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.anim-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.anim-nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.anim-nav-btn:not(:disabled):active {
  background: var(--color-amber-glow);
  border-color: var(--color-amber);
  color: var(--color-amber);
}

.anim-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.anim-auto-btn {
  width: calc(100% - var(--space-8));
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-faint);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.anim-auto-btn:active {
  background: var(--color-amber-glow);
  color: var(--color-amber);
  border-color: var(--color-amber);
}

/* ─── SVG Card Icons (replaces Unicode) ───────────────────────────────────── */
.calc-card-icon {
  display: flex;
  align-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.calc-card-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--color-amber);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ─── Tab Slide Transitions ─────────────────────────────────────────────────── */
.tab-panel {
  animation: tabFadeIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.calculator-panel.active {
  animation: calcPanelIn 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes calcPanelIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Results section animates in */
.results-section {
  animation: resultsIn 200ms ease;
}

@keyframes resultsIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Active Input Glow ──────────────────────────────────────────────────────── */
.field-input:focus,
.field-select:focus {
  box-shadow: 0 0 0 3px var(--color-amber-glow-strong), 0 0 12px var(--color-amber-glow);
}

/* ─── Long-press copy (result rows) ─────────────────────────────────────────── */
.result-row {
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  padding: var(--space-1) var(--space-2);
  margin: 0 calc(-1 * var(--space-2));
}

.result-row:active {
  background: var(--color-amber-glow);
}

/* ─── Calc grid card — active hover state ────────────────────────────────────── */
@media (hover: hover) {
  .calc-card:hover {
    border-color: var(--color-amber-dim);
    background: var(--color-surface-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-amber);
  }
}

/* ─── Version badge v2.0 ─────────────────────────────────────────────────────── */
.version-badge {
  font-size: var(--text-xs);
  color: var(--color-amber);
  padding: 2px 8px;
  background: var(--color-amber-glow);
  border: 1px solid var(--color-amber);
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ─── Tablet/desktop layout for diagram ─────────────────────────────────────── */
@media (min-width: 560px) {
  .diagram-body {
    min-height: 180px;
  }
  .anim-svg-wrap svg {
    max-height: 160px;
  }
}

/* ─── Pull-to-refresh visual cue (cosmetic) ──────────────────────────────────── */
.app-content {
  overscroll-behavior-y: contain;
}

/* ─── Tips list SVG bullet (replaces ▸ unicode) ──────────────────────────────── */
.tips-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-amber-dim);
  position: absolute;
  left: 2px;
  top: 8px;
}

/* ─── Why icon uses SVG now ───────────────────────────────────────────────────── */
.why-icon {
  font-size: 0;
}
.why-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-amber);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ─── Calc-count update for 11 ────────────────────────────────────────────────── */
.calc-grid-count {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 500;
}
