/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding: 0 var(--sp-5);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  border-radius: var(--radius-md);
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: .82; }
.btn-primary:disabled { opacity: .4; }
.btn-primary.btn-full { width: 100%; }

.btn-primary.btn-sleep-start { background: var(--c-sleep); }
.btn-primary.btn-nursing-start { background: var(--c-nursing); }

.btn-secondary {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  color: var(--text-1);
  transition: background .15s;
}
.btn-secondary:active { background: var(--bg-3); }

.btn-danger {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--touch); width: 100%;
  background: #7f1d1d; color: #fca5a5;
  font-weight: 700; font-size: 15px;
  border-radius: var(--radius-md);
  transition: background .15s;
}
.btn-danger:active { background: #991b1b; }

.btn-danger-outline {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--touch); width: 100%;
  border: 1px solid rgba(248,113,113,.4);
  color: var(--danger); font-weight: 600; font-size: 15px;
  border-radius: var(--radius-md);
  transition: background .15s;
}
.btn-danger-outline:active { background: rgba(248,113,113,.1); }

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--bg-2); color: var(--text-1); }

.link-btn {
  background: none;
  color: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* Chip group */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip {
  min-height: 36px;
  padding: 0 var(--sp-4);
  border: 1.5px solid var(--border-hi);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-2);
  transition: all .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { background: var(--bg-3); }
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(251,113,133,.1);
}

/* Form fields */
.input-field {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-size: 15px;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.input-field:focus { border-color: var(--accent); }
.input-field::placeholder { color: var(--text-3); }

input[type="time"].input-field {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  color: var(--text-1);
}

textarea.input-field { min-height: 80px; padding-top: var(--sp-3); }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
.optional { font-weight: 400; text-transform: none; opacity: .6; }

/* Bottom sheet modal */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.bottom-sheet {
  width: 100%;
  max-height: 92dvh;
  background: var(--bg-1);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,1,.5,1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.bottom-sheet.is-open { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border-hi);
  border-radius: 2px;
  margin: var(--sp-3) auto var(--sp-1);
  flex-shrink: 0;
}

.sheet-header {
  padding: var(--sp-2) var(--sp-5) var(--sp-4);
  flex-shrink: 0;
}
.sheet-header h2 { font-size: 20px; font-weight: 700; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  -webkit-overflow-scrolling: touch;
}

.sheet-footer {
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* Timeline */
.timeline-list { padding: var(--sp-3) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }

.timeline-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--bg-1);
  box-shadow: var(--shadow-sm);
}

.timeline-swipe-content {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  min-height: 48px;
  background: var(--bg-1);
  transition: transform .2s ease;
  will-change: transform;
  position: relative;
  z-index: 1;
}

.tl-color {
  width: 3px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tl-icon { color: var(--text-2); flex-shrink: 0; display: flex; }

.tl-body { flex: 1; min-width: 0; }
.tl-main { font-size: 15px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-notes { font-size: 12px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tl-time {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.tl-delete-btn {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 80px;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger);
  color: #fff;
  z-index: 0;
  opacity: 0;
  transition: opacity .2s;
}

.timeline-item.swiped .tl-delete-btn { opacity: 1; }
.timeline-item.deleting { opacity: .3; pointer-events: none; }

/* Summary strip */
.summary-strip {
  display: flex;
  gap: 0;
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.summary-item {
  flex: 1;
  text-align: center;
  padding: var(--sp-2);
  border-right: 1px solid var(--border);
}
.summary-item:last-child { border-right: none; }

.summary-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin-bottom: 3px;
}

.summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

.summary-item.summary-active .summary-value { color: var(--c-sleep); }

/* Lock screen */
.lock-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-5);
  padding-top: calc(var(--sp-6) + env(safe-area-inset-top));
  padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
  gap: var(--sp-8);
}

.lock-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
}

.lock-icon {
  width: 80px; height: 80px;
  background: var(--bg-2);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  color: var(--text-2);
}

.lock-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.lock-subtitle { font-size: 15px; color: var(--text-2); }

.lock-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.lock-input {
  display: block;
  width: 100%;
  height: 56px;
  padding: 0 var(--sp-4);
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color .15s;
  -webkit-appearance: none;
  color-scheme: dark;
}
.lock-input:focus { border-color: var(--accent); }

/* ── Time-range row (nursing manual log) ──── */
.time-range-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
}
.time-range-row .field-group { flex: 1; }
.time-range-sep {
  font-size: 18px;
  color: var(--text-3);
  padding-bottom: 10px;
  flex-shrink: 0;
}
.flex-1 { flex: 1; }

/* ── Nursing timer card ──────────────────── */
.nt-card {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}

.nt-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.nt-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
}

.nt-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2.5px solid var(--border-hi);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .2s, background .2s, transform .1s;
  overflow: visible;
}
.nt-btn:active:not(.locked) { transform: scale(.95); }

.nt-btn.active {
  border-color: var(--c-nursing);
  background: rgba(244,63,94,.08);
}
[data-theme="dark"] .nt-btn.active {
  background: rgba(251,113,133,.1);
}

.nt-btn.locked { opacity: .5; cursor: default; }

.nt-btn.nt-last {
  border-color: var(--c-nursing);
  border-style: dashed;
  background: rgba(244,63,94,.06);
}
.nt-btn.nt-last .nt-letter {
  color: var(--c-nursing);
  opacity: .6;
}
.nt-btn.nt-last .nt-hint {
  color: var(--c-nursing);
  font-weight: 700;
  letter-spacing: .5px;
}
[data-theme="dark"] .nt-btn.nt-last {
  background: rgba(251,113,133,.08);
}

.nt-btn-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 1;
}

.nt-letter {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  color: var(--text-2);
  transition: color .2s;
  letter-spacing: -2px;
}
.nt-btn.active .nt-letter { color: var(--c-nursing); }

.nt-time {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--c-nursing);
  min-height: 18px;
  font-variant-numeric: tabular-nums;
}

.nt-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* Pulse ring */
.nt-pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--c-nursing);
  animation: nt-pulse 2s ease-out infinite;
  pointer-events: none;
}

@keyframes nt-pulse {
  0%   { opacity: .6; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.12); }
  100% { opacity: 0;  transform: scale(1.12); }
}

.nt-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

.nt-pause-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1.5px solid var(--border-hi);
  border-radius: 100px;
  cursor: pointer;
  padding: 0 var(--sp-4);
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.nt-pause-btn:active { background: var(--bg-3); }

.nt-btn.nt-paused {
  border-style: dashed;
  opacity: .75;
}
.nt-btn.nt-paused .nt-time {
  color: var(--text-3);
}

.nt-locked-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
}

.lock-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  padding: var(--sp-2) var(--sp-3);
  background: rgba(248,113,113,.1);
  border-radius: var(--radius-sm);
}

.lock-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--text-2);
  background: var(--bg-2);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  line-height: 1.5;
}

/* Shake animation */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.shake { animation: shake .4s ease; }

/* Toast notifications */
#toast-container {
  position: fixed;
  top: calc(var(--sp-4) + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  padding: var(--sp-3) var(--sp-5);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  max-width: 320px;
  text-align: center;
  opacity: 0;
  transform: translateY(-8px) scale(.95);
  transition: opacity .2s, transform .2s;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-hi);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.toast.visible { opacity: 1; transform: translateY(0) scale(1); }
.toast-success { background: rgba(52,211,153,.15); border-color: rgba(52,211,153,.4); color: var(--success); }
.toast-error { background: rgba(248,113,113,.15); border-color: rgba(248,113,113,.4); color: var(--danger); }
.toast-warning { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.3); color: #fbbf24; }

/* Settings */
.settings-view { padding-bottom: var(--sp-8); }
.settings-section { padding: var(--sp-5) var(--sp-4) 0; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin-bottom: var(--sp-3); }
.danger-title { color: rgba(248,113,113,.6); }

.settings-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  min-height: 60px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row.col { flex-direction: column; align-items: stretch; gap: var(--sp-3); }

.settings-row-text { flex: 1; }
.settings-row-label { font-size: 15px; font-weight: 500; }
.settings-row-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.danger-card { border-color: rgba(248,113,113,.2); }
.danger-warning {
  display: flex; align-items: center; gap: var(--sp-2);
  color: var(--danger); font-size: 14px; font-weight: 500;
}

.timeout-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.timeout-chip.active { border-color: var(--accent); color: var(--accent); background: rgba(251,113,133,.1); }

/* ML input row */
.ml-input-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.ml-display { display: flex; align-items: baseline; gap: 4px; flex: 1; justify-content: center; }
.ml-number {
  font-size: 40px;
  font-weight: 800;
  text-align: center;
  width: 90px;
  font-variant-numeric: tabular-nums;
}
.ml-unit { font-size: 18px; font-weight: 600; color: var(--text-2); }
.ml-step {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-3);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.ml-step:active { background: var(--bg-2); }

.ml-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  cursor: pointer;
}
.ml-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.ml-presets { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Quick panel */
.qp {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  min-height: calc(100dvh - var(--header-h) - var(--fab-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.qp-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1 1 0;
  min-height: 0;
}

.qp-section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .7px;
  flex-shrink: 0;
}

.qp-chips {
  display: flex;
  flex-wrap: wrap;
  align-content: stretch;
  gap: var(--sp-2);
  flex: 1 1 auto;
  min-height: 56px;
}

.qp-chip {
  flex: 1 1 auto;
  min-width: 56px;
  min-height: 56px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-hi);
  background: var(--bg-1);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .1s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.qp-chip:active { background: var(--bg-2); transform: scale(.94); }

.qp-chip-sleep {
  border-color: var(--c-sleep);
  color: var(--c-sleep);
  font-size: 15px;
}
.qp-chip-sleep.active {
  background: rgba(99,102,241,.1);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .qp-chip-sleep.active { background: rgba(129,140,248,.12); }

.qp-chip-bottle { border-color: var(--c-bottle); color: var(--c-bottle); }
.qp-unit { font-size: 10px; font-weight: 500; opacity: .7; }

.qp-chip-diaper { border-color: var(--c-diaper); color: var(--c-diaper); }
.qp-chip-meds   { border-color: var(--c-meds);   color: var(--c-meds); }
.qp-chip-meds.qp-chip-ready { border-color: var(--success); color: var(--success); background: rgba(5,150,105,.1); }
[data-theme="dark"] .qp-chip-meds.qp-chip-ready { background: rgba(52,211,153,.1); }
.mom-elapsed { font-size: 11px; font-weight: 500; opacity: .75; }

/* Home view */
.home-view {}

/* Quick-log strip */
.quick-log-strip {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.ql-btn {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-2);
  border: 1.5px solid var(--border-hi);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  transition: background .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.ql-btn:active { background: var(--bg-3); transform: scale(.97); }
.ql-btn:disabled { opacity: .35; }
.ql-wet, .ql-dirty { border-color: var(--c-diaper); color: var(--c-diaper); }
.ql-bottle { border-color: var(--c-bottle); color: var(--c-bottle); }

/* Large chips for compact modal sheets */
.chip-group-lg { gap: var(--sp-2); }
.chip.chip-lg {
  flex: 1;
  min-height: 52px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* Time quick-chips */
.time-chips-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Toast undo button */
.toast-undo-btn {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 100px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 10px;
  margin-left: 6px;
  flex-shrink: 0;
  cursor: pointer;
}
