:root {
  --bg: #FCFAF7;
  --bg-soft: #F7F2EB;
  --card: #FFFFFF;
  --primary: #F97316;
  --primary-dark: #EA580C;
  --primary-soft: #FFF1E5;
  --primary-tint: #FFEDD5;
  --secondary: #111827;
  --secondary-2: #374151;
  --secondary-dim: #6B7280;
  --secondary-soft: #F3F4F6;
  --success: #16A34A;
  --success-soft: #DCFCE7;
  --slip: #DC2626;
  --slip-soft: #FEE2E2;
  --warn-soft: #FEF3C7;
  --warn-text: #92400E;
  --border: rgba(17, 24, 39, 0.08);
  --border-soft: rgba(17, 24, 39, 0.04);
  --shadow-1: 0 1px 2px rgba(17, 24, 39, 0.04), 0 0 0 1px var(--border);
  --shadow-2: 0 4px 16px rgba(17, 24, 39, 0.06), 0 0 0 1px var(--border);
  --shadow-3: 0 16px 40px rgba(17, 24, 39, 0.10), 0 0 0 1px var(--border);
  --shadow-press: 0 1px 1px rgba(17, 24, 39, 0.06);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--secondary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: 'cv11' 1, 'ss01' 1;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea {
  outline: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--secondary);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-user-select: text;
  user-select: text;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.screen {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ========== PIN SCREEN ========== */
.pin-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #FFF7ED 0%, var(--bg) 60%);
}

.pin-inner {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.brand {
  font-family: 'Manrope', sans-serif;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--primary);
}

.pin-prompt {
  margin: 0 0 28px;
  color: var(--secondary-dim);
  font-weight: 500;
  font-size: 14px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}
.pin-dots .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--secondary-soft);
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pin-dots .dot.filled {
  background: var(--primary);
  transform: scale(1.15);
  box-shadow: 0 0 0 4px var(--primary-tint);
}

#pin-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.pin-error {
  min-height: 22px;
  color: var(--slip);
  font-weight: 600;
  font-size: 13px;
  margin: 6px 0 16px;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.key {
  background: var(--card);
  border-radius: var(--radius-md);
  font-size: 22px;
  font-weight: 700;
  color: var(--secondary);
  padding: 18px 0;
  box-shadow: var(--shadow-1);
  transition: transform 0.1s, background 0.1s, box-shadow 0.1s;
}
.key:not(.invisible):active {
  transform: scale(0.95);
  background: var(--primary-soft);
  box-shadow: var(--shadow-press);
}
.key-back { color: var(--secondary-dim); font-size: 18px; }
.key.invisible { background: transparent; box-shadow: none; }

/* ========== APP SCREEN ========== */
.app-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg);
}

.view {
  flex: 1;
  padding: 14px 18px 88px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 6px 0 14px;
  color: var(--secondary);
}
.view-title-inline { margin: 0; }
.view-sub {
  color: var(--secondary-dim);
  font-size: 13px;
  margin: 0 0 14px;
}

/* ========== HOME VIEW ========== */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 2px 16px;
}

.hstat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hstat-center { align-items: center; }
.hstat-right { align-items: flex-end; }

.hstat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--secondary-dim);
  text-transform: uppercase;
}

.hstat-value {
  font-weight: 800;
  font-size: 17px;
  color: var(--secondary);
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.01em;
}

/* DIAL */
.dial-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 4px auto 18px;
  aspect-ratio: 1;
}

.dial {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 2px 8px rgba(249, 115, 22, 0.10));
}

.dial-bg {
  fill: none;
  stroke: var(--secondary-soft);
  stroke-width: 12;
}

.dial-fill {
  fill: none;
  stroke: url(#dialGrad);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 659.7;
  stroke-dashoffset: 659.7;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dial-pr-ring {
  fill: none;
  stroke: var(--success);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 3 7;
  stroke-dashoffset: 659.7;
  opacity: 0.5;
  transition: stroke-dashoffset 0.6s ease;
}

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  pointer-events: none;
}

.dial-hours {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: clamp(58px, 17vw, 88px);
  line-height: 1;
  color: var(--secondary);
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.05em;
}

.dial-unit {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--primary);
  margin-top: 6px;
  text-transform: uppercase;
}

.dial-mins {
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary-dim);
  margin-top: 4px;
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0.02em;
}

.dial-burst { position: absolute; inset: 0; pointer-events: none; }
.dial-burst.burst { animation: dialBurst 0.6s ease-out; }
@keyframes dialBurst {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.dial-wrap.pr-mode .dial-fill { stroke: url(#dialGradPr); }

/* NEXT MILESTONE */
.next-milestone {
  margin: 0 2px 14px;
}
.mile-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.mile-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--secondary-dim);
  text-transform: uppercase;
}
.mile-target {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  font-feature-settings: 'tnum' 1;
}
.mile-bar {
  height: 5px;
  background: var(--secondary-soft);
  border-radius: 3px;
  overflow: hidden;
}
.mile-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #FB923C);
  width: 0%;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 3px;
}
.mile-remaining {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary-dim);
  margin-top: 4px;
  font-feature-settings: 'tnum' 1;
}

/* REWARD DISPLAY — fixed height, never shifts layout */
.reward-display {
  height: 76px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 12px;
  margin: 8px 0 4px;
  font-weight: 800;
  color: var(--primary);
  transition: opacity 0.35s;
  opacity: 0;
  overflow: hidden;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.reward-display.show { opacity: 1; }
.reward-display.tier-mikro     { font-size: 22px; color: var(--primary); }
.reward-display.tier-srednje   { font-size: 16px; color: var(--secondary); font-weight: 700; }
.reward-display.tier-veliko    { font-size: 22px; color: var(--primary); animation: pulseUp 0.6s ease-out; }
.reward-display.tier-easter    { font-size: 14px; color: var(--secondary-dim); font-style: italic; font-weight: 600; }
.reward-display.tier-jackpot   { font-size: 22px; color: var(--success); animation: pulseUp 0.8s ease-out; }
.reward-display.tier-milestone { font-size: 20px; color: var(--success); animation: pulseUp 0.8s ease-out; }
.reward-display.tier-comeback  { font-size: 16px; color: var(--success); }
.reward-display.tier-pr_break  { font-size: 20px; color: var(--success); animation: pulseUp 0.6s ease-out; }

@keyframes pulseUp {
  0%   { transform: scale(0.92); opacity: 0; }
  50%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ACTION BUTTONS */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 16px;
}

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  padding: 18px 16px;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: white;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.08), 0 0 0 1px rgba(255,255,255,0.06);
  transition: transform 0.12s ease-out, box-shadow 0.12s, filter 0.15s;
  font-family: 'Inter', sans-serif;
  min-height: 72px;
}

.btn:active {
  transform: scale(0.97);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
}

.btn-tap {
  background: linear-gradient(160deg, #16A34A, #15803D);
}
.btn-tap .btn-main { font-size: 20px; letter-spacing: 0.04em; }
.btn-tap .btn-sub  { font-size: 11px; opacity: 0.85; margin-top: 3px; letter-spacing: 0.18em; font-weight: 800; }
.btn-tap.celebrating { animation: celebrate 0.5s ease-out; }
@keyframes celebrate {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  70%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.btn-slip {
  background: linear-gradient(160deg, #DC2626, #B91C1C);
  font-size: 15px;
  min-height: 56px;
  padding: 14px;
  letter-spacing: 0.06em;
  font-weight: 800;
}

/* WEIGHT STRIP */
.weight-strip {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-1);
}
.weight-strip.empty {
  text-align: center;
  font-size: 13px;
  color: var(--secondary-dim);
  font-weight: 500;
  padding: 14px;
}
.ws-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ws-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-cell:nth-child(2) { align-items: center; }
.ws-cell:last-child { align-items: flex-end; }
.ws-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--secondary-dim);
  text-transform: uppercase;
}
.ws-cell strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--secondary);
  font-feature-settings: 'tnum' 1;
}
.ws-cell-current strong { color: var(--primary); }
.ws-delta-down strong { color: var(--success); }
.ws-delta-up strong { color: var(--slip); }

.ws-progress {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.ws-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary-dim);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.ws-progress-pct { color: var(--success); }
.ws-progress-bar {
  height: 5px;
  background: var(--secondary-soft);
  border-radius: 3px;
  overflow: hidden;
}
.ws-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #22C55E);
  border-radius: 3px;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========== WEIGHT VIEW ========== */
.weight-summary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 22px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.22);
}
.weight-summary .ws-big {
  font-size: 38px;
  font-weight: 900;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 4px 0 6px;
}
.weight-summary .ws-small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.92;
  text-transform: uppercase;
}

.ws-target-row {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}
.ws-target-text {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.ws-target-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  overflow: hidden;
}
.ws-target-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 16px 16px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
}
.card-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--secondary-dim);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.card-desc {
  font-size: 13px;
  color: var(--secondary-dim);
  margin: 0 0 12px;
  line-height: 1.5;
}

.weight-input-row {
  display: flex;
  gap: 8px;
}
.weight-input-row input { flex: 1; }

.btn-primary, .btn-secondary, .btn-slip-confirm {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: transform 0.1s, filter 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(249,115,22,0.25); }
.btn-secondary { background: var(--secondary); color: white; box-shadow: 0 2px 8px rgba(17,24,39,0.18); }
.btn-slip-confirm { background: var(--slip); color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.25); }
.btn-primary:active, .btn-secondary:active, .btn-slip-confirm:active { transform: scale(0.97); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: default; }
.btn-block { width: 100%; padding: 15px; font-size: 14px; }

.weight-message {
  margin-top: 12px;
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
  min-height: 18px;
  line-height: 1.4;
}

#weight-chart {
  width: 100%;
  height: 160px;
  display: block;
  margin-bottom: 8px;
}

.weight-history {
  max-height: 240px;
  overflow-y: auto;
}
.weight-history-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--secondary-2);
  font-weight: 500;
}
.weight-history-row:last-child { border-bottom: none; }
.weight-history-row strong { color: var(--secondary); font-weight: 700; }

/* ========== PROGRESS VIEW ========== */
.windows-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.window-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-1);
}
.window-label {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--secondary-dim);
  text-transform: uppercase;
}
.window-pct {
  font-size: 24px;
  font-weight: 900;
  color: var(--primary);
  margin: 6px 0 2px;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.02em;
}
.window-meta {
  font-size: 9px;
  color: var(--secondary-dim);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.milestone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.milestone-pill {
  background: var(--secondary-soft);
  color: var(--secondary-dim);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.milestone-pill.hit {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.milestone-pill.hit-now {
  background: var(--success);
  color: white;
}

.slip-log .slip-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.slip-log .slip-row:last-child { border-bottom: none; }
.slip-row .slip-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  color: var(--secondary-dim);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.slip-row .slip-verdict {
  font-size: 13px;
  color: var(--secondary-2);
  line-height: 1.5;
}

.info-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--secondary-dim);
  line-height: 1.7;
}

.push-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--secondary-dim);
}

/* ========== BUDDY (CHAT) VIEW ========== */
.view-buddy {
  display: flex;
  flex-direction: column;
}
.buddy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.chat-clear {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary-soft);
  color: var(--secondary-dim);
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.chat-clear:active { background: var(--primary-soft); color: var(--primary); }

.chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: calc(100dvh - 320px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-empty {
  text-align: center;
  color: var(--secondary-dim);
  font-size: 13px;
  margin: auto;
  padding: 24px 16px;
  font-weight: 500;
}

.chat-bubble {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
}

.chat-user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  font-weight: 500;
}

.chat-assistant {
  background: var(--card);
  color: var(--secondary);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-1);
  font-weight: 500;
}

.chat-loading {
  opacity: 0.6;
  animation: chatPulse 1.2s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

.chat-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 8px;
}
.suggestion {
  background: var(--card);
  color: var(--secondary-2);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: background 0.15s, transform 0.1s;
}
.suggestion:active {
  transform: scale(0.97);
  background: var(--primary-soft);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 4px;
}
#chat-input {
  resize: none;
  max-height: 140px;
  line-height: 1.4;
  font-size: 14px;
}
.chat-send {
  background: var(--primary);
  color: white;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249,115,22,0.25);
  transition: transform 0.1s;
}
.chat-send:active { transform: scale(0.95); }
.chat-send:disabled { opacity: 0.5; }

/* ========== TABS ========== */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  color: var(--secondary-dim);
  font-weight: 700;
  transition: color 0.15s, background 0.15s;
}
.tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.tab-icon { font-size: 18px; line-height: 1; }
.tab-label { font-size: 9px; letter-spacing: 0.08em; font-weight: 800; }

/* ========== MODAL ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-inner {
  position: relative;
  background: var(--card);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.modal-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0;
}
.modal-close {
  font-size: 22px;
  color: var(--secondary-dim);
  padding: 4px 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.modal-close:active { background: var(--secondary-soft); }
.modal-sub {
  color: var(--secondary-dim);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.5;
}

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 12px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.chip-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--secondary-dim);
  letter-spacing: 0;
  text-transform: none;
}
.chip:active { transform: scale(0.98); }
.chip.selected {
  border-color: var(--slip);
  background: var(--slip-soft);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

#slip-text {
  min-height: 100px;
  resize: vertical;
  margin-bottom: 12px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.modal-buttons button { flex: 1; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--secondary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

#slip-loading { text-align: center; padding: 16px 0; }

.severity-badge {
  display: inline-block;
  background: var(--slip-soft);
  color: var(--slip);
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.verdict {
  font-size: 16px;
  font-weight: 700;
  color: var(--secondary);
  margin: 8px 0;
  line-height: 1.5;
}

.next-step {
  background: var(--secondary-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--secondary-2);
  margin: 10px 0;
  line-height: 1.5;
}
.next-step:empty { display: none; }

.damage-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  background: var(--slip-soft);
  border-radius: var(--radius-sm);
  margin: 12px 0;
}
.damage-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--slip);
  text-transform: uppercase;
}
.damage-value {
  font-size: 20px;
  font-weight: 900;
  color: var(--slip);
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.02em;
}

.ai-override-hint {
  background: var(--warn-soft);
  color: var(--warn-text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  margin: 8px 0;
  font-weight: 600;
  line-height: 1.4;
}

/* ========== MILESTONE OVERLAY ========== */
.milestone-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
}
.milestone-card {
  background: linear-gradient(160deg, #FFF7ED, #FFFFFF);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.20), 0 0 0 1px rgba(249, 115, 22, 0.4);
  animation: jackpotIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes jackpotIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.milestone-emoji { font-size: 48px; margin-bottom: 12px; }
.milestone-hours {
  font-family: 'Manrope', sans-serif;
  font-weight: 900;
  font-size: 56px;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 12px;
  letter-spacing: -0.04em;
  font-feature-settings: 'tnum' 1;
}
.milestone-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 22px;
  line-height: 1.4;
}

/* ========== CONFETTI ========== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 600px) {
  .view { max-width: 560px; margin: 0 auto; }
  .tabs { max-width: 560px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; border-radius: var(--radius-md) var(--radius-md) 0 0; }
}
