:root {
  --bg-primary: #12100e;
  --bg-secondary: #1c1917;
  --bg-card: #292524;
  --bg-card-hover: #342e2b;
  --bg-input: #171412;
  --border-color: #44403c;
  --border-focus: #f59e0b;
  --text-primary: #fafaf9;
  --text-secondary: #a8a29e;
  --text-muted: #78716c;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-light: rgba(245, 158, 11, 0.12);
  --coffee-crema: #fbbf24;
  --coffee-dark: #78350f;
  --success: #10b981;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #fcfbf9;
  --bg-secondary: #f5f4f0;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f4;
  --bg-input: #f5f4f0;
  --border-color: #e7e5e4;
  --border-focus: #b45309;
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --accent: #b45309;
  --accent-hover: #92400e;
  --accent-light: rgba(180, 83, 9, 0.1);
  --coffee-crema: #d97706;
  --coffee-dark: #78350f;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* Header */
header {
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-badge {
  font-size: 0.7rem;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 6px;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--accent);
}

.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}
.theme-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Method Selector Tabs / Chips */
.methods-nav {
  margin: 22px 0 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.method-btn {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.method-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.method-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

/* Main Grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

/* Coffee Calculator Core */
.calc-field-group {
  margin-bottom: 20px;
}

.calc-field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

.calc-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.calc-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.step-btn {
  width: 44px;
  height: 54px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.step-btn:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.input-unit-badge {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 32px;
}

/* Ratio Slider */
.ratio-slider-container {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 20px 0;
}

.ratio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.ratio-value-badge {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.ratio-taste-indicator {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ratio-slider {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
  cursor: pointer;
  margin-bottom: 8px;
}

.ratio-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Servings presets */
.servings-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.serving-chip {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.serving-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Interactive Brew Timer Card */
.timer-hero {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.timer-clock {
  font-size: 3.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -1px;
}
.timer-clock.active {
  color: var(--accent);
}

.timer-stage-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.timer-instruction {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  min-height: 32px;
}

.timer-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  margin-top: 14px;
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

/* Timer Controls */
.timer-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.timer-btn-primary {
  flex: 2;
  padding: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  font-weight: 800;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.timer-btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.timer-btn-reset {
  flex: 1;
  padding: 14px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.timer-btn-reset:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Method specs box */
.method-specs-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.spec-cell-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}
.spec-cell-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Sticky Mobile Bar */
.sticky-mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 10px 16px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
  z-index: 900;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 768px) {
  .sticky-mobile-bar {
    display: flex;
  }
}

.sticky-metric {
  display: flex;
  flex-direction: column;
}
.sticky-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.sticky-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.sticky-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Ad Slot Container */
.ad-slot-container {
  margin: 32px 0 24px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  text-align: center;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.ad-disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* SEO Educational Section */
.seo-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 36px 32px;
  margin-top: 32px;
}

.seo-section h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.seo-section h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 28px 0 12px;
}

.seo-section p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.seo-table-wrapper {
  overflow-x: auto;
  margin: 20px 0;
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.seo-table th, .seo-table td {
  padding: 12px 14px;
  border: 1px solid var(--border-color);
}

.seo-table th {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 700;
}

.seo-table tr:nth-child(even) {
  background: var(--bg-input);
}

/* Related Apps Cluster */
.related-cluster {
  margin-top: 32px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.related-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.related-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.related-app-card {
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
}
.related-app-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* FAQ Accordion */
.faq-accordion {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-question:hover {
  color: var(--accent);
}

.faq-chevron {
  transition: transform 0.2s;
  font-size: 0.8rem;
}
.faq-item.active .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 20px 16px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  display: none;
}
.faq-item.active .faq-answer {
  display: block;
}

/* Footer */
footer {
  border-top: 1px solid var(--border-color);
  padding: 24px 0 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-secondary);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
footer a:hover {
  color: var(--accent);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  background: var(--accent);
  color: #000;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media print {
  body { background: #fff !important; color: #000 !important; }
  header, .methods-nav, .timer-controls, .sticky-mobile-bar, .ad-slot-container, .seo-section, .related-cluster, footer, .toast, .step-btn, .servings-row {
    display: none !important;
  }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; background: #fff !important; }
}
