/* =============================================================================
   1. DESIGN TOKENS
   ============================================================================= */
:root {
  /* Base palette */
  --bg:            #f5f4f0;
  --surface:       #ffffff;
  --surface2:      #f0efe9;
  --border:        #e2e0d8;
  --text:          #1a1a18;
  --text2:         #6b6a64;
  --text3:         #9b9a94;

  --accent:        #2d6a4f;
  --accent-light:  #e8f4ee;
  --accent2:       #1b4332;

  --inp-bg:        #fffef5;
  --inp-border:    #d4c97a;

  --warn:          #b04a1f;

  /* aDBS-specific accents (unique to this tool) */
  --high:          #b8302f;     /* red — peak / upper LFP */
  --high-bg:       #fbeceb;
  --high-border:   #e8a7a5;

  --low:           #2c5b8a;     /* blue — trough / lower LFP */
  --low-bg:        #e8f0f7;
  --low-border:    #a9c2dc;

  /* Shape & typography */
  --radius:        14px;
  --radius-sm:     8px;
  --shadow:        0 2px 12px rgba(0,0,0,0.07);
  --font:          'DM Sans', sans-serif;
  --mono:          'DM Mono', monospace;
}

/* =============================================================================
   2. RESET & BASE
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* =============================================================================
   3. DISCLAIMER MODAL
   ============================================================================= */
#disclaimer-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#disclaimer-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.disclaimer-logo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  font-family: var(--font);
}
.disclaimer-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.disclaimer-beta {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  margin-left: 8px;
  vertical-align: 4px;
}
.disclaimer-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 22px 0 28px;
}
.disclaimer-body p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
}
.disclaimer-body strong {
  color: var(--text);
  font-weight: 600;
}
#disclaimer-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}
#disclaimer-btn:hover { background: var(--accent2); }

/* App stays hidden until disclaimer accepted */
.app { display: none; }
.app.visible { display: block; }

/* =============================================================================
   4. LAYOUT
   ============================================================================= */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

header.app-header { margin-bottom: 22px; }

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.beta-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
}

.subtitle {
  color: var(--text2);
  font-size: 14px;
  margin-top: 6px;
}

/* =============================================================================
   5. CARDS
   ============================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.high { background: var(--high); }
.dot.low  { background: var(--low); }

.count-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 10px;
  font-family: var(--mono);
}

/* =============================================================================
   6. INPUT ROWS
   ============================================================================= */
.input-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.row-num {
  font-size: 12px;
  color: var(--text3);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
  font-family: var(--mono);
}

.num-input {
  flex: 1;
  min-width: 0;
  padding: 12px 13px;
  font-size: 15px;
  font-family: var(--mono);
  color: var(--text);
  background: var(--inp-bg);
  border: 1.5px solid var(--inp-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.num-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.remove-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.remove-btn:hover:not(:disabled) {
  background: #fff5f4;
  color: var(--high);
  border-color: var(--high);
}
.remove-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.add-btn {
  margin-top: 12px;
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--accent);
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.add-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* =============================================================================
   7. ACTIONS
   ============================================================================= */
.actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.actions button {
  flex: 1;
  padding: 11px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.actions button:hover {
  background: var(--surface2);
  color: var(--text);
}

/* =============================================================================
   8. RESULTS
   ============================================================================= */
.means-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.mean-tile {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.mean-tile.high {
  background: var(--high-bg);
  border-color: var(--high-border);
}
.mean-tile.low {
  background: var(--low-bg);
  border-color: var(--low-border);
}

.mean-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 6px;
}
.mean-tile.high .mean-label { color: var(--high); }
.mean-tile.low  .mean-label { color: var(--low); }

.mean-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
}
.mean-value.empty {
  color: var(--text3);
  font-weight: 400;
  font-size: 18px;
}

.threshold-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.threshold-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  font-weight: 600;
  margin-bottom: 10px;
}

.threshold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1.5px solid var(--border);
  gap: 12px;
}
.threshold-row.high {
  background: var(--high-bg);
  border-color: var(--high-border);
}
.threshold-row.low {
  background: var(--low-bg);
  border-color: var(--low-border);
}

.threshold-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.threshold-label .formula {
  display: block;
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
  font-family: var(--mono);
  font-weight: 400;
}

.threshold-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
  flex-shrink: 0;
}
.threshold-value.empty {
  color: var(--text3);
  font-weight: 400;
  font-size: 16px;
}

.formula-note {
  font-size: 12px;
  color: var(--text2);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  line-height: 1.55;
}
.formula-note strong {
  color: var(--text);
  font-weight: 600;
  font-family: var(--mono);
}
.formula-note .warn {
  color: var(--warn);
  font-weight: 600;
}

/* =============================================================================
   9. FOOTER
   ============================================================================= */
footer.disclaimer {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin-top: 24px;
  padding: 0 8px;
  line-height: 1.55;
}

footer.disclaimer .copyright {
  font-size: 10px;
  color: var(--text3);
  margin-top: 10px;
  opacity: 0.75;
}

/* =============================================================================
   10. MOBILE
   ============================================================================= */
@media (max-width: 420px) {
  .app { padding: 22px 14px 60px; }
  h1 { font-size: 20px; }
  .means-grid { grid-template-columns: 1fr; }
  .mean-value { font-size: 20px; }
  .threshold-value { font-size: 19px; }
  .threshold-row { padding: 12px; }
}
