/* ============================================================
   SPLASH SCREEN
   ============================================================ */

#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a1628;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashFadeOut 0.5s ease 1.8s forwards;
  pointer-events: all;
}

#splash-screen.dismissed {
  display: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: splashPulseIn 0.6s ease-out;
}

.splash-logo {
  filter: drop-shadow(0 0 30px rgba(0, 229, 255, 0.5));
}

.splash-bolt {
  animation: boltFlash 0.8s ease-in-out;
  transform-origin: center;
}

.splash-drop {
  animation: dropPulse 1.2s ease-in-out;
  transform-origin: center;
}

.splash-title {
  font-family: var(--font-display, 'SF Pro Display', -apple-system, sans-serif);
  font-size: 32px;
  font-weight: 800;
  color: #f0f8ff;
  letter-spacing: -0.5px;
  animation: splashTextIn 0.5s ease 0.3s both;
}

.splash-subtitle {
  font-family: var(--font-mono, 'SF Mono', monospace);
  font-size: 14px;
  color: rgba(200, 236, 248, 0.5);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: splashTextIn 0.5s ease 0.5s both;
}

@keyframes splashPulseIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes boltFlash {
  0% { opacity: 0; transform: translateY(-20px); }
  30% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.3; }
  70% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes dropPulse {
  0% { stroke-dasharray: 300; stroke-dashoffset: 300; opacity: 0; }
  50% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes splashTextIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes splashFadeOut {
  0% { opacity: 1; pointer-events: all; }
  100% { opacity: 0; pointer-events: none; }
}

/* Brand bolt icon */
.brand-bolt,
.brand-logo {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  margin-top: -4px;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.6));
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  --bg: #0a1628;
  --surface: rgba(13, 32, 64, 0.85);
  --border: rgba(79, 179, 232, 0.18);
  --ripple: #4fb3e8;
  --accent: #00e5ff;
  --foam: #c8ecf8;
  --white: #f0f8ff;
  --muted: rgba(200, 236, 248, 0.5);
  --gold: #ffd54f;
  --green: #4ade80;
  --danger: #f87171;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 44px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: 'SF Pro Display', -apple-system, 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: 'SF Mono', ui-monospace, Menlo, 'Courier New', monospace;
  --font-ui: -apple-system, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --surface: rgba(255, 255, 255, 0.95);
  --text: #1a2a3a;
  --muted: #6b7d8e;
  --accent: #0099cc;
  --accent-glow: rgba(0, 153, 204, 0.3);
  --border: rgba(0, 0, 0, 0.1);
  --card-bg: rgba(255, 255, 255, 0.9);
  --input-bg: rgba(240, 244, 248, 0.9);
  --success: #00cc66;
  --error: #ff4444;
  --white: #1a2a3a;
  --muted: #6b7d8e;
  --foam: #1a2a3a;
  --ripple: #0099cc;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  width: 100%;
  height: 100%;
  background-color: var(--bg);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.5;
  -webkit-app-region: drag;
  -webkit-user-select: none;
  overflow: hidden;
  position: fixed;
}

::selection {
  background-color: var(--accent);
  color: var(--bg);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--ripple);
}

button {
  -webkit-user-select: none;
  user-select: none;
  -webkit-app-region: no-drag;
}

input {
  -webkit-user-select: text;
  user-select: text;
  -webkit-app-region: no-drag;
}

a {
  color: var(--accent);
  text-decoration: none;
  -webkit-app-region: no-drag;
}

a:active {
  opacity: 0.8;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.5px;
}

h1 {
  font-size: 32px;
  line-height: 1.2;
}

h2 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 16px 0;
}

h3 {
  font-size: 20px;
  line-height: 1.3;
}

p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  -webkit-user-select: text;
  user-select: text;
}

.primary-btn {
  background-color: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
}

.primary-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

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

.secondary-btn {
  background-color: var(--surface);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 24px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
}

.secondary-btn:active {
  background-color: rgba(79, 179, 232, 0.1);
  border-color: var(--ripple);
}

.tertiary-btn {
  background: none;
  color: var(--accent);
  border: none;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
}

.tertiary-btn:active {
  opacity: 0.7;
}

.form-input {
  background-color: var(--surface);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--font-ui);
  font-size: 15px;
  width: 100%;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
}

.form-input::placeholder {
  color: var(--muted);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: rgba(13, 32, 64, 0.95);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

.content-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(80px + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.content-wrapper::-webkit-scrollbar {
  width: 4px;
}

#toast-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  pointer-events: none;
  padding-top: var(--safe-top);
}

.toast {
  background-color: rgba(0, 0, 0, 0.9);
  color: var(--white);
  padding: 14px 20px;
  border-radius: 12px;
  margin: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  animation: slideInDown 0.3s ease;
  pointer-events: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

@keyframes slideInDown {
  from {
    transform: translateY(-100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100px);
    opacity: 0;
  }
}

.toast.out {
  animation: slideOutUp 0.3s ease forwards;
}

#auth-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(79, 179, 232, 0.08) 0%, rgba(10, 22, 40, 0) 50%), var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 24px;
  max-width: 400px;
  width: 100%;
  backdrop-filter: blur(10px);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--white) 0%, var(--foam) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-card > p {
  text-align: center;
  margin-bottom: 32px;
  font-size: 14px;
}

.auth-card h2 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 24px;
  color: var(--white);
}

.oauth-btn {
  width: 100%;
  background-color: var(--white);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.oauth-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.oauth-btn svg {
  width: 20px;
  height: 20px;
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

.form-group input {
  width: 100%;
}

.form-group input + input {
  margin-top: 12px;
}

.primary-btn.full-width {
  width: 100%;
  margin-top: 24px;
}

.auth-card .tertiary-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 16px;
  padding: 12px 0;
}

#username-screen,
#group-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(79, 179, 232, 0.08) 0%, rgba(10, 22, 40, 0) 50%), var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  flex-direction: column;
}

.onboarding-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 24px;
  max-width: 400px;
  width: 100%;
  backdrop-filter: blur(10px);
}

.onboarding-card h2 {
  color: var(--white);
  margin-bottom: 12px;
}

.onboarding-card > p {
  margin-bottom: 32px;
  font-size: 14px;
}

.onboarding-card input {
  width: 100%;
  margin-bottom: 12px;
}

.onboarding-card .primary-btn {
  width: 100%;
}

.onboarding-card .tertiary-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 16px;
}

/* ============================================================
   ONBOARDING WALKTHROUGH SCREEN
   ============================================================ */

#onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: linear-gradient(135deg, #0a1628 0%, #0d2040 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  padding-top: calc(var(--safe-top) + 40px);
  padding-bottom: calc(var(--safe-bottom) + 40px);
}

#onboarding-screen.hidden {
  display: none;
}

.onboarding-slides {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 420px;
  perspective: 1000px;
}

.onboarding-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.onboarding-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.onboarding-slide.prev {
  opacity: 0;
  transform: translateX(-100px);
}

.onboarding-icon {
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-icon svg {
  filter: drop-shadow(0 0 25px rgba(0, 229, 255, 0.4));
  animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-15px);
  }
}

.onboarding-slide h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.onboarding-slide p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 320px;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 40px 0;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(79, 179, 232, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.onboarding-dots .dot.active {
  width: 24px;
  background-color: var(--accent);
  border-radius: 4px;
}

.onboarding-controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.onboarding-next-btn {
  flex: 1;
  padding: 14px 24px;
  font-weight: 600;
  font-size: 15px;
}

.onboarding-skip-btn {
  flex: 0;
  padding: 14px 32px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
}

.onboarding-skip-btn:active {
  opacity: 0.7;
}

/* Responsive adjustments */
@media (max-width: 400px) {
  #onboarding-screen {
    padding: 32px 16px;
    padding-top: calc(var(--safe-top) + 32px);
    padding-bottom: calc(var(--safe-bottom) + 32px);
  }

  .onboarding-slide h2 {
    font-size: 24px;
  }

  .onboarding-slide p {
    font-size: 14px;
  }

  .onboarding-icon svg {
    width: 90px;
    height: 110px;
  }
}

.group-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.group-divider::before,
.group-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

#main-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 500;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 28px;
  color: var(--white);
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 22px;
  padding: 8px;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
  border-radius: 8px;
}

.icon-btn:active {
  background-color: rgba(0, 229, 255, 0.1);
  transform: scale(0.9);
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(80px + 16px + var(--safe-bottom));
}

.tab-content.hidden {
  display: none;
}

#tab-today {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-ring-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 32px 0 24px;
}

.progress-ring-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(20px);
  pointer-events: none;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.3));
}

.progress-ring__bg {
  transition: stroke 0.3s ease;
}

.progress-ring__fill {
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.5));
}

.progress-ring__text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 100%;
  z-index: 10;
  -webkit-user-select: none;
  user-select: none;
}

.progress-ring__amount {
  display: block;
  font-size: 48px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1;
}

.progress-ring__unit {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.progress-ring__unit span {
  color: var(--white);
  font-weight: 600;
}

.progress-ring__remaining {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.streak-badge {
  background: linear-gradient(135deg, rgba(255, 213, 79, 0.2) 0%, rgba(255, 213, 79, 0.1) 100%);
  border: 1px solid rgba(255, 213, 79, 0.3);
  border-radius: 12px;
  padding: 12px 20px;
  text-align: center;
  margin-bottom: 32px;
  display: inline-block;
}

.streak-badge-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.quick-add-section {
  width: 100%;
  margin-bottom: 32px;
}

.section-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 16px;
  display: block;
}

.quick-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.quick-add-btn {
  background-color: var(--surface);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 100px;
}

.quick-add-btn:active {
  background-color: rgba(0, 229, 255, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.2);
  transform: scale(0.98);
}

.quick-add-btn-amount {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.quick-add-btn-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.custom-add-container {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
}

.custom-add-container input {
  flex: 1;
}

.custom-add-container button {
  padding: 14px 24px;
}

.log-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.log-card h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--white);
}

.log-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry-time {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.log-entry-oz {
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-mono);
  flex: 1;
  text-align: right;
  margin-right: 12px;
}

.log-entry-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 0.2s, color 0.2s;
}
.log-entry-delete:hover,
.log-entry-delete:active {
  opacity: 1;
  color: #ff4444;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}

.undo-btn {
  width: 100%;
  margin-top: 16px;
}

#tab-board {
  padding: 16px 0;
}

.board-section-heading {
  padding: 0 16px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  padding: 0 16px;
}

.leaderboard-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-rank {
  width: 40px;
  font-weight: 700;
  color: var(--white);
  font-family: var(--font-mono);
  text-align: center;
}

.leaderboard-rank.rank-1 {
  color: var(--gold);
  font-size: 18px;
}

.leaderboard-rank.rank-2 {
  color: #c0c0c0;
  font-size: 16px;
}

.leaderboard-rank.rank-3 {
  color: #cd7f32;
  font-size: 16px;
}

.leaderboard-username {
  flex: 1;
  color: var(--white);
  font-weight: 500;
}

.leaderboard-oz {
  text-align: right;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-mono);
  min-width: 80px;
}

.leaderboard-badge {
  text-align: right;
  color: var(--green);
  font-weight: 600;
  min-width: 30px;
}

.goal-met {
  color: var(--green);
}

.goal-unmet {
  color: var(--danger);
}

#tab-history {
  padding: 16px 0;
}

.history-list {
  padding: 0 16px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
}

.history-item-date {
  flex: 1;
  color: var(--white);
  font-weight: 500;
  font-size: 15px;
}

.history-item-oz {
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-mono);
  margin-right: 16px;
  min-width: 60px;
  text-align: right;
}

.history-item-status {
  font-size: 16px;
}

.goal-met {
  color: var(--accent);
}

.goal-unmet {
  color: var(--muted);
}

/* ============================================================
   INSIGHTS CHART & STATS
   ============================================================ */

.insights-section {
  padding: 20px 16px 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 0 16px 20px;
}

.insights-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.insights-chart {
  position: relative;
  height: 200px;
  margin-bottom: 24px;
  padding: 16px 0;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 140px;
  padding: 0 8px;
  position: relative;
  z-index: 2;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  width: 12%;
  min-width: 32px;
  position: relative;
}

.chart-bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.chart-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: all 0.3s ease;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.chart-bar-met .chart-bar-fill {
  background-color: var(--accent) !important;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.4);
}

.chart-bar-exceeded .chart-bar-fill {
  background-color: var(--gold) !important;
  box-shadow: 0 0 20px rgba(255, 213, 79, 0.6);
}

.chart-bar-unmet .chart-bar-fill {
  background-color: var(--ripple);
  opacity: 0.4;
}

.chart-bar-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}

.chart-goal-line-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 140px;
  pointer-events: none;
  z-index: 1;
}

.chart-goal-line {
  position: absolute;
  width: 100%;
  height: 2px;
  border-top: 2px dashed var(--accent);
  opacity: 0.5;
  left: 0;
}

.monthly-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.stat-card {
  padding: 14px 12px;
  background-color: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
}

.stat-card:hover {
  background-color: rgba(0, 229, 255, 0.12);
  border-color: var(--accent);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

.insights-divider {
  height: 1px;
  background-color: var(--border);
  margin: 20px 0;
}

#tab-settings {
  padding: 16px 0;
}

.settings-section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 0 16px 20px;
  overflow: hidden;
}

.settings-section-title {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  background-color: rgba(0, 0, 0, 0.2);
  letter-spacing: 0.5px;
}

.settings-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item-label {
  flex: 1;
  color: var(--white);
  font-weight: 500;
  font-size: 15px;
}

.settings-item-value {
  color: var(--muted);
  font-size: 13px;
}

.ios-toggle {
  width: 51px;
  height: 31px;
  background-color: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s ease;
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  padding: 2px;
}

.ios-toggle.active {
  background-color: var(--accent);
}

.ios-toggle-thumb {
  width: 27px;
  height: 27px;
  background-color: var(--white);
  border-radius: 50%;
  position: absolute;
  transition: left 0.3s ease;
  left: 2px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.ios-toggle.active .ios-toggle-thumb {
  left: 22px;
}

.settings-select {
  background-color: var(--bg);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  -webkit-app-region: no-drag;
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent);
}

.time-input-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px 0;
}

.time-input-group input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
}

.time-input-group span {
  color: var(--muted);
  font-size: 13px;
  min-width: 20px;
}

.settings-button {
  width: 100%;
  background-color: var(--accent);
  color: var(--bg);
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
}

.settings-button:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.settings-button.secondary {
  background-color: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.faq-category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  padding: 16px 16px 4px;
  opacity: 0.7;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: 12px;
  -webkit-app-region: no-drag;
  user-select: none;
}

.faq-question-text {
  flex: 1;
  color: var(--white);
  font-weight: 500;
  font-size: 15px;
}

.faq-chevron {
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.faq-item.open .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 12px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-item.open .faq-answer {
  max-height: 500px;
  margin-top: 12px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #0d2040;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 0;
  padding-top: 8px;
  padding-bottom: calc(var(--safe-bottom) + 8px);
  z-index: 999;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  flex: 1;
  transition: all 0.2s ease;
  -webkit-app-region: no-drag;
  border: none;
  background: none;
  border-top: 3px solid transparent;
  position: relative;
}

.nav-tab.active {
  color: var(--accent);
}

.nav-tab.active::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  background-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.nav-tab-icon {
  font-size: 22px;
}

.nav-tab-label {
  letter-spacing: 0.3px;
}

#pwa-banner {
  position: fixed;
  bottom: 100px;
  left: 16px;
  right: 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 900;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(120px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#pwa-banner.hidden {
  display: none;
}

.pwa-text {
  flex: 1;
  font-size: 14px;
  color: var(--white);
  font-weight: 500;
}

.pwa-button {
  padding: 8px 16px;
  background-color: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-app-region: no-drag;
}

.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.share-modal.hidden {
  display: none;
}

.share-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.share-card h3 {
  color: var(--white);
  margin-bottom: 16px;
}

.share-card-content {
  background: linear-gradient(135deg, rgba(79, 179, 232, 0.1) 0%, rgba(0, 229, 255, 0.05) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.share-card-stat {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.share-card-stat strong {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 16px;
}

.share-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.share-buttons button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  -webkit-app-region: no-drag;
}

.share-buttons button:first-child {
  background-color: var(--accent);
  color: var(--bg);
}

.share-buttons button:last-child {
  background-color: var(--border);
  color: var(--white);
}

.close-modal-btn {
  width: 100%;
  background-color: var(--border);
  color: var(--white);
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  -webkit-app-region: no-drag;
}

/* Goal Celebration Effects */

.goal-crushed {
  color: #ffd700 !important;
  font-weight: 700;
  font-size: 1.1em;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: goalPulse 1.5s ease-in-out infinite;
}

@keyframes goalPulse {
  0%, 100% {
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
  }
  50% {
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.3);
  }
}

.progress-ring.goal-met .progress-ring__fill {
  stroke: #ffd700 !important;
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.6));
}

.progress-ring.goal-met .progress-ring__bg {
  stroke: rgba(255, 215, 0, 0.15) !important;
}

.goal-celebration {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 215, 0, 0.15), transparent 70%);
  animation: celebrationFlash 1.5s ease-out forwards;
}

@keyframes celebrationFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.goal-bolt-zap {
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
  animation: boltZap 0.6s ease-in-out infinite alternate;
}

@keyframes boltZap {
  0% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8)); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 12px rgba(255, 215, 0, 1)); }
}

@media (max-width: 600px) {
  .auth-card {
    padding: 32px 20px;
  }

  .onboarding-card {
    padding: 32px 20px;
  }

  h1 {
    font-size: 28px;
  }

  .tab-content {
    padding: 12px;
    padding-bottom: calc(80px + 12px + var(--safe-bottom));
  }

  .quick-add-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .quick-add-btn {
    min-height: 90px;
    padding: 12px;
  }
}

.settings-item-sublabel {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  padding: 0 4px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

/* ============================================================
   GOAL CELEBRATION ANIMATIONS
   ============================================================ */

.goal-celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
  overflow: hidden;
}

.bolt-particle {
  position: absolute;
  width: 24px;
  height: 24px;
  animation: boltExplode 1.5s ease-out forwards;
}

.bolt-particle svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(255, 213, 79, 0.8));
}

@keyframes boltExplode {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.3);
  }
}

.confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: confettiFall 3s ease-in forwards;
  top: -10px;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(calc(100vh + 20px)) translateX(var(--tx)) rotate(360deg);
  }
}

.goal-crushed-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  font-weight: 900;
  color: #ffd54f;
  text-shadow: 0 0 30px rgba(255, 213, 79, 0.8),
               0 0 60px rgba(255, 213, 79, 0.6),
               0 0 90px rgba(255, 100, 100, 0.4);
  font-family: var(--font-display, 'SF Pro Display', -apple-system, sans-serif);
  z-index: 1001;
  letter-spacing: -1px;
  animation: goalCrushedPop 2.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: none;
  white-space: nowrap;
  font-style: italic;
  line-height: 1;
}

@keyframes goalCrushedPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-10deg);
  }
  10% {
    opacity: 1;
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15) rotate(2deg);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-1deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9) rotate(0deg);
  }
}

.progress-ring-glow.celebrating {
  animation: glowPulse 1.5s ease-out forwards;
}

@keyframes glowPulse {
  0% {
    background: radial-gradient(circle, rgba(255, 213, 79, 0.6) 0%, rgba(255, 100, 100, 0.2) 40%, transparent 70%);
    filter: blur(10px);
  }
  50% {
    background: radial-gradient(circle, rgba(255, 213, 79, 0.8) 0%, rgba(255, 100, 100, 0.3) 40%, transparent 70%);
    filter: blur(15px);
  }
  100% {
    background: radial-gradient(circle, rgba(0, 229, 255, 0.2) 0%, transparent 70%);
    filter: blur(20px);
  }
}

/* Yesterday button */
.yesterday-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
  opacity: 0.7;
  font-size: 13px;
}
.yesterday-btn:active {
  opacity: 1;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 229, 255, 0.1);
}
.modal-card h3 {
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 20px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
