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

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #0a0a0a;
  color: #f4f4f4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input {
  background: none;
  border: none;
  outline: none;
  color: inherit;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

ul {
  list-style: none;
}

/* === App layout === */
#app {
  min-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.screen {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* === Setup screen === */
#setup-screen {
  justify-content: flex-start;
  align-items: center;
  padding: 32px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.setup-content {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: auto 0;
}

.brand {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: center;
  margin-bottom: 4px;
}

#setup-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.field-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9a9a9a;
}

#weight-input,
#custom-oz,
#custom-abv,
#shot-custom-percent,
#time-earlier-input {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 18px;
  width: 100%;
  min-height: 52px;
}

#weight-input:focus,
#custom-oz:focus,
#custom-abv:focus,
#shot-custom-percent:focus,
#time-earlier-input:focus {
  border-color: #4a90e2;
}

#time-earlier-input {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}

.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 4px;
}

.toggle-btn {
  padding: 14px 16px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 500;
  color: #9a9a9a;
  min-height: 48px;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn[aria-pressed="true"] {
  background: #f4f4f4;
  color: #0a0a0a;
  font-weight: 600;
}

.primary-btn {
  background: #f4f4f4;
  color: #0a0a0a;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 600;
  min-height: 52px;
  transition: opacity 0.15s;
}

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

.primary-btn:active:not(:disabled) {
  opacity: 0.8;
}

.ghost-btn {
  background: transparent;
  color: #9a9a9a;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  min-height: 48px;
}

.ghost-btn:active {
  background: #1a1a1a;
  color: #f4f4f4;
}

.danger-btn {
  background: #c0392b;
  color: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  min-height: 48px;
}

.danger-btn:active {
  opacity: 0.8;
}

.disclaimer {
  font-size: 12px;
  line-height: 1.5;
  color: #6a6a6a;
  text-align: center;
  margin-top: 8px;
}

.setup-separator {
  border: none;
  border-top: 1px solid #2a2a2a;
  margin: 8px 0 4px;
}

.legal-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 12px;
}

.legal-title {
  font-size: 18px;
  font-weight: 700;
  color: #f4f4f4;
  letter-spacing: -0.01em;
}

.legal-heading {
  font-size: 15px;
  font-weight: 700;
  color: #f4f4f4;
  margin-top: 6px;
  letter-spacing: -0.01em;
}

.legal-body {
  font-size: 13px;
  line-height: 1.55;
  color: #9a9a9a;
}

/* === Tracker screen === */
#tracker-screen {
  padding: 12px 20px 120px;
  gap: 20px;
}

.tracker-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 44px;
}

.tracker-header .ghost-btn {
  padding: 10px 14px;
  min-height: 40px;
  font-size: 14px;
}

.bac-display {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}

.bac-number {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace;
  font-size: 64px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bac-elapsed {
  font-size: 13px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
  min-height: 16px;
}

/* === Stage card === */
.stage-card {
  border-radius: 18px;
  padding: 24px 22px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.4s ease, color 0.4s ease;
  background: #1f5e3a;
  color: #ffffff;
}

.stage-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stage-range {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.stage-description {
  font-size: 16px;
  line-height: 1.45;
  margin-top: 4px;
}

/* Stage color classes */
.stage-card.stage-sober {
  background: #1f5e3a;
  color: #ffffff;
}
.stage-card.stage-subtle {
  background: #3d8b53;
  color: #ffffff;
}
.stage-card.stage-impaired-judgment {
  background: #d4a017;
  color: #1a1a1a;
}
.stage-card.stage-legally-impaired {
  background: #e07d10;
  color: #ffffff;
}
.stage-card.stage-major {
  background: #c25a07;
  color: #ffffff;
}
.stage-card.stage-severe {
  background: #c0392b;
  color: #ffffff;
}
.stage-card.stage-confusion {
  background: #7d1c14;
  color: #ffffff;
}
.stage-card.stage-stupor {
  background: #5b2a7a;
  color: #ffffff;
}
.stage-card.stage-life-threatening {
  background: #0a0a0a;
  color: #ffffff;
  border: 1px solid #c0392b;
}

/* === Drinks list === */
.drinks-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-heading {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9a9a9a;
}

.drinks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drink-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 52px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s;
}

.drink-item:active {
  background: #232323;
}

.drink-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drink-item-name {
  font-size: 15px;
  font-weight: 600;
}

.drink-item-detail {
  font-size: 12px;
  color: #9a9a9a;
}

.drink-item-time {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

.drinks-empty {
  font-size: 14px;
  color: #6a6a6a;
  padding: 16px 4px;
  text-align: center;
}

/* === Add drink button === */
.add-drink-btn {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #f4f4f4;
  color: #0a0a0a;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, opacity 0.15s;
  z-index: 10;
}

.add-drink-btn:active {
  transform: translateX(-50%) scale(0.97);
  opacity: 0.9;
}

.plus {
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
}

/* === Modals === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #161616;
  border-radius: 20px 20px 0 0;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-top: 1px solid #2a2a2a;
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.drink-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drink-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1f1f1f;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px 18px;
  min-height: 56px;
  text-align: left;
  transition: background 0.15s;
}

.drink-option:active {
  background: #2a2a2a;
}

.drink-option-name {
  font-size: 16px;
  font-weight: 600;
}

.drink-option-meta {
  font-size: 13px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

.modal-cancel {
  margin-top: 4px;
  align-self: stretch;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .ghost-btn,
.modal-actions .primary-btn,
.modal-actions .danger-btn {
  flex: 1;
}

.confirm-content {
  text-align: left;
}

.confirm-message {
  font-size: 15px;
  line-height: 1.5;
  color: #c4c4c4;
}

#custom-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* === Drink option variants === */
.drink-option-default {
  border-color: #4a90e2;
  background: #1a2536;
}

.drink-option-danger .drink-option-name {
  color: #e57373;
}

/* === Category chips (mixed-drink modal) === */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.category-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 60px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.category-chip:active {
  background: #232323;
}

.category-chip[aria-pressed="true"] {
  background: #f4f4f4;
  border-color: #f4f4f4;
}

.category-chip[aria-pressed="true"] .category-name,
.category-chip[aria-pressed="true"] .category-hint {
  color: #0a0a0a;
}

.category-chip-custom {
  grid-column: 1 / -1;
}

.category-name {
  font-size: 14px;
  font-weight: 600;
  color: #f4f4f4;
}

.category-hint {
  font-size: 12px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
}

/* === Shot picker chips (size + strength) === */
.shot-size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.shot-strength-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shot-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 60px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.shot-chip:active {
  background: #232323;
}

.shot-chip-default {
  border-color: #4a90e2;
  background: #1a2536;
}

.shot-chip[aria-pressed="true"] {
  background: #f4f4f4;
  border-color: #f4f4f4;
}

.shot-chip[aria-pressed="true"] .shot-chip-name,
.shot-chip[aria-pressed="true"] .shot-chip-hint {
  color: #0a0a0a;
}

.shot-chip-custom {
  grid-column: 1 / -1;
}

.shot-chip-name {
  font-size: 14px;
  font-weight: 600;
  color: #f4f4f4;
}

.shot-chip-hint {
  font-size: 12px;
  color: #9a9a9a;
  line-height: 1.3;
}

/* === Time picker === */
.time-picker-subtitle {
  font-size: 14px;
  color: #9a9a9a;
  margin-top: -8px;
  font-variant-numeric: tabular-nums;
}

.time-chips {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.time-chip {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  color: #f4f4f4;
  min-height: 48px;
  transition: background 0.15s, border-color 0.15s;
}

.time-chip:active {
  background: #232323;
}

.time-chip[aria-pressed="true"] {
  background: #f4f4f4;
  color: #0a0a0a;
  border-color: #f4f4f4;
  font-weight: 600;
}

.drink-action-detail {
  font-size: 14px;
  color: #c4c4c4;
  margin-top: -6px;
  font-variant-numeric: tabular-nums;
}

/* === Tracker screen footer disclaimer === */
.tracker-disclaimer {
  font-size: 11px;
  line-height: 1.4;
  color: #6a6a6a;
  text-align: center;
  padding: 4px 8px 0;
}

/* === Small screens === */
@media (max-height: 700px) {
  .bac-number {
    font-size: 52px;
  }
  .stage-card {
    min-height: 150px;
    padding: 20px 18px;
  }
  .stage-name {
    font-size: 24px;
  }
}
