*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background-color: #FFFFFF;
  color: #09090B;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono, .data-digit {
  font-family: 'JetBrains Mono', monospace;
}

/* Nav Bar */
.top-header {
  border-bottom: 1px solid #E4E4E7;
  background-color: #FFFFFF;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-badge {
  background-color: #09090B;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #09090B;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  color: #71717A;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: #09090B;
}

.btn-sm-black {
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sm-black:hover {
  background: #27272A;
}

/* Wrapper */
.main-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-width: 0;
}

/* Page Intro */
.page-intro {
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #09090B;
  margin-bottom: 6px;
}

.page-desc {
  font-size: 14px;
  color: #71717A;
  max-width: 760px;
}

/* Grid Layout */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.app-grid > * {
  min-width: 0;
}

.panel-card {
  background: #FAFAFA;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 20px;
  min-width: 0;
}

.panel-header {
  border-bottom: 1px solid #E4E4E7;
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #09090B;
  text-transform: uppercase;
}

.panel-indicator {
  font-size: 11px;
  color: #71717A;
  font-family: 'JetBrains Mono', monospace;
}

/* Segmented Controls */
.segment-group {
  margin-bottom: 16px;
}

.segment-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #09090B;
  margin-bottom: 6px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  background: #E4E4E7;
  padding: 2px;
  border-radius: 4px;
  gap: 2px;
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #71717A;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.segment-btn.active {
  background: #FFFFFF;
  color: #09090B;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Input Styles */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #09090B;
  margin-bottom: 6px;
}

.form-label span.sub {
  font-size: 11px;
  color: #71717A;
  font-weight: 400;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
  color: #09090B;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.input-control:focus {
  outline: none;
  border-color: #09090B;
}

.unit-select {
  width: 80px;
  flex-shrink: 0;
  padding: 8px;
  font-size: 12px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
  color: #09090B;
  font-weight: 600;
}

/* Clinical Toggles and Checkbox */
.checkbox-card {
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FFFFFF;
  padding: 12px;
  margin-bottom: 16px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #09090B;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}

.sub-input-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #E4E4E7;
  display: none;
}

.sub-input-section.active {
  display: block;
}

/* Drip Metronome Visualizer */
.drip-chamber {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drip-view {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chamber-graphic {
  width: 32px;
  height: 48px;
  border: 2px solid #09090B;
  border-radius: 4px;
  position: relative;
  background: #FAFAFA;
}

.chamber-fluid-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: #E4E4E7;
  border-top: 1px solid #71717A;
}

.chamber-drop {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #09090B;
  position: absolute;
  left: 11px;
  top: 4px;
  opacity: 0;
  transform: translateY(0);
}

.chamber-drop.animate-drop {
  animation: dripAnim 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dripAnim {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; transform: translateY(18px) scale(0.9); }
  100% { opacity: 0; transform: translateY(22px) scale(0.6); }
}

.drip-stats-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #71717A;
}

.drip-stats-val {
  font-size: 18px;
  font-weight: 800;
  color: #09090B;
  font-family: 'JetBrains Mono', monospace;
}

/* Results Display */
.metric-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.metric-box {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  padding: 12px;
  border-radius: 4px;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: #71717A;
  text-transform: uppercase;
}

.metric-val {
  font-size: 22px;
  font-weight: 800;
  color: #09090B;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

.metric-unit {
  font-size: 11px;
  font-weight: 500;
  color: #71717A;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
}

.breakdown-table th, .breakdown-table td {
  padding: 8px 12px;
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid #E4E4E7;
}

.breakdown-table th {
  background: #FAFAFA;
  font-weight: 600;
  color: #71717A;
}

.breakdown-table tr:last-child td {
  border-bottom: none;
}

.breakdown-table td.data-num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* Quick Action / Clinical Presets */
.preset-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.preset-chip {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  color: #09090B;
}

.preset-chip:hover {
  background: #E4E4E7;
}

.action-row {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  flex: 1;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  color: #09090B;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.btn-secondary:hover {
  background: #E4E4E7;
}

/* Clinical Warnings */
.warning-badge-box {
  background: #FFFFFF;
  border: 1px solid #09090B;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 16px;
  display: none;
}

.warning-badge-box.show {
  display: block;
}

.warning-title {
  font-size: 12px;
  font-weight: 700;
  color: #09090B;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.warning-text {
  font-size: 11px;
  color: #71717A;
}

/* Methodological E-E-A-T Technical Section */
.methodology-section {
  margin-top: 32px;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  background: #FAFAFA;
  padding: 24px;
}

.methodology-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.methodology-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}

.methodology-col h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.methodology-col p, .methodology-col ul {
  font-size: 12px;
  color: #71717A;
  line-height: 1.6;
}

.methodology-col ul {
  padding-left: 18px;
}

.formula-display {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  margin: 6px 0 12px;
  color: #09090B;
}

/* Ad Placement Zone */
.ad-slot-zone {
  margin: 32px 0;
  padding: 16px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  text-align: center;
}

.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #71717A;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: block;
}

.ad-card-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #FAFAFA;
  border: 1px dashed #E4E4E7;
  border-radius: 4px;
}

.ad-copy-title {
  font-size: 13px;
  font-weight: 700;
  color: #09090B;
  text-align: left;
}

.ad-copy-sub {
  font-size: 11px;
  color: #71717A;
  text-align: left;
}

/* Micro Affiliate Box */
.micro-affiliate-box {
  margin-top: 16px;
  padding: 12px;
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.affiliate-link-btn {
  font-size: 11px;
  font-weight: 600;
  color: #09090B;
  text-decoration: underline;
  padding: 4px 6px;
}

/* Floating Coffee Support */
.support-widget-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #000000;
  color: #FFFFFF;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 30px;
  border: 1px solid #000000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
  transition: transform 0.15s ease;
}

.support-widget-float:hover {
  transform: translateY(-2px);
}

/* Modal Overlay */
.modal-scrim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-scrim.hidden {
  display: none !important;
}

.modal-container {
  background: #FFFFFF;
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #E4E4E7;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: #71717A;
  cursor: pointer;
}

.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: #E4E4E7;
  padding: 2px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.modal-tab-btn {
  border: none;
  background: transparent;
  font-size: 11px;
  padding: 6px 4px;
  font-weight: 600;
  color: #71717A;
  border-radius: 3px;
  cursor: pointer;
}

.modal-tab-btn.active {
  background: #FFFFFF;
  color: #09090B;
}

/* Structural Footer */
.site-footer {
  border-top: 1px solid #E4E4E7;
  background: #FAFAFA;
  padding: 32px 20px 48px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-author-box p {
  font-size: 12px;
  color: #71717A;
  margin-bottom: 4px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  font-size: 12px;
  color: #71717A;
  text-decoration: none;
}

.footer-links a:hover {
  color: #09090B;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  .methodology-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .main-wrapper {
    padding: 16px 12px 36px;
  }
  .panel-card {
    padding: 14px;
  }
  .segmented-control {
    grid-template-columns: 1fr 1fr;
  }
  .header-container {
    padding: 10px 12px;
  }
  .ad-card-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}