/* ==========================================================================
   STREAM METRIC - Premium Mobile Web Utility Application
   Theme: Cinematic Dark & Crimson Glow Aesthetic
   ========================================================================== */

:root {
  --bg-dark: #08080c;
  --bg-overlay: rgba(8, 8, 12, 0.52);
  --surface-glass: rgba(18, 18, 24, 0.80);
  --surface-glass-card: rgba(24, 24, 34, 0.74);
  --surface-glass-elevated: rgba(32, 32, 44, 0.88);
  --surface-input: rgba(12, 12, 18, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-crimson: rgba(229, 9, 20, 0.35);
  --border-crimson-bright: rgba(229, 9, 20, 0.7);
  
  --accent-crimson: #e50914;
  --accent-crimson-hover: #f40612;
  --accent-vermilion: #ff3344;
  --accent-glow: rgba(229, 9, 20, 0.45);
  --accent-glow-subtle: rgba(229, 9, 20, 0.2);
  
  --gradient-crimson: linear-gradient(135deg, #e50914 0%, #b80610 100%);
  --gradient-glow: linear-gradient(135deg, #ff3344 0%, #e50914 50%, #90030a 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
  --gradient-card-active: linear-gradient(135deg, rgba(229, 9, 20, 0.18) 0%, rgba(18, 18, 24, 0.85) 100%);
  
  --text-primary: #ffffff;
  --text-secondary: #c5c5cb;
  --text-muted: #7c7c88;
  --text-crimson: #ff4757;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.6);
  --shadow-crimson: 0 8px 25px rgba(229, 9, 20, 0.35);
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  
  --nav-height: 64px;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Accent Themes */
body[data-theme="amber"] {
  --accent-crimson: #f59e0b;
  --accent-crimson-hover: #d97706;
  --accent-vermilion: #fbbf24;
  --accent-glow: rgba(245, 158, 11, 0.45);
  --border-crimson: rgba(245, 158, 11, 0.35);
  --border-crimson-bright: rgba(245, 158, 11, 0.7);
  --gradient-crimson: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  --gradient-glow: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #92400e 100%);
  --text-crimson: #fbbf24;
  --shadow-crimson: 0 8px 25px rgba(245, 158, 11, 0.35);
}

body[data-theme="neon"] {
  --accent-crimson: #00f2fe;
  --accent-crimson-hover: #4facfe;
  --accent-vermilion: #38ef7d;
  --accent-glow: rgba(0, 242, 254, 0.45);
  --border-crimson: rgba(0, 242, 254, 0.35);
  --border-crimson-bright: rgba(0, 242, 254, 0.7);
  --gradient-crimson: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --gradient-glow: linear-gradient(135deg, #38ef7d 0%, #00f2fe 50%, #11998e 100%);
  --text-crimson: #00f2fe;
  --shadow-crimson: 0 8px 25px rgba(0, 242, 254, 0.35);
}

/* ==========================================================================
   RESET & MOBILE BASE STYLES
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-image: url("bg.jpg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
  background-color: var(--bg-dark);
}

/* Clean background overlay: crisp & visible, never muddy */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  pointer-events: none;
  z-index: 0;
}

/* Inputs, Selects, Buttons */
input, select, textarea, button {
  font-family: inherit;
  font-size: 16px; /* Strictly 16px to prevent iOS auto-zoom */
  color: var(--text-primary);
  border: none;
  outline: none;
  background: transparent;
}

button {
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform var(--transition-fast), background var(--transition-fast), border var(--transition-fast), box-shadow var(--transition-fast);
}

button:active {
  transform: scale(0.97);
}

a {
  color: var(--accent-crimson);
  text-decoration: none;
}

/* ==========================================================================
   CONTAINER & SCREEN SHELL
   ========================================================================== */

.app-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px 16px;
  background: rgba(10, 10, 14, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 0 14px var(--accent-glow);
  border: 1px solid var(--border-crimson);
}

.app-title-group h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 40%, #ff7782 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-title-group .app-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

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

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.header-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-crimson);
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid var(--border-crimson);
  color: var(--text-crimson);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-crimson);
  box-shadow: 0 0 8px var(--accent-crimson);
}

/* ==========================================================================
   SCREENS VIEWPORT & TRANSITIONS
   ========================================================================== */

.screens-viewport {
  flex: 1;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 84px) 16px;
  position: relative;
}

.screen {
  display: none;
  animation: fadeInScreen var(--transition-smooth) forwards;
}

.screen.active {
  display: block;
}

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

/* ==========================================================================
   CARDS & GLASSMORPHIC COMPONENTS
   ========================================================================== */

.glass-card {
  background: var(--surface-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.glass-card-elevated {
  background: var(--surface-glass-elevated);
  border-color: var(--border-crimson);
  box-shadow: var(--shadow-md), 0 0 20px rgba(229, 9, 20, 0.1);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   SCREEN 1: WELCOME / ONBOARDING MODAL
   ========================================================================== */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 4, 8, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.welcome-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.welcome-dialog {
  width: 100%;
  max-width: 400px;
  background: rgba(18, 18, 26, 0.95);
  border: 1px solid var(--border-crimson-bright);
  border-radius: var(--radius-lg);
  padding: 28px 20px 24px 20px;
  box-shadow: var(--shadow-lg), 0 0 35px var(--accent-glow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-badge-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
  margin-bottom: 16px;
  border: 2px solid var(--border-crimson-bright);
  box-shadow: 0 0 24px var(--accent-glow);
}

.welcome-dialog h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.welcome-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.welcome-features {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}

.welcome-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.feature-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid var(--border-crimson);
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feature-text h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.feature-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

.btn-primary-large {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--gradient-crimson);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-crimson);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

/* ==========================================================================
   SCREEN 2: DASHBOARD / HOME
   ========================================================================== */

.hero-banner {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.18) 0%, rgba(20, 20, 28, 0.88) 100%);
  border: 1px solid var(--border-crimson);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hero-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-crimson);
}

.hero-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.hero-banner h2 {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 6px;
}

.hero-banner p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.stat-card .stat-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

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

/* Quick Tool Grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.tool-tile {
  background: var(--surface-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 112px;
  text-align: left;
  backdrop-filter: blur(14px);
  position: relative;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.tool-tile:hover, .tool-tile:active {
  border-color: var(--border-crimson);
  transform: translateY(-2px);
  background: var(--gradient-card-active);
}

.tool-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tool-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(229, 9, 20, 0.12);
  border: 1px solid var(--border-crimson);
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-arrow {
  color: var(--text-muted);
  opacity: 0.6;
}

.tool-tile h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.tool-tile p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Mini Quick Converter on Home */
.quick-convert-box {
  background: var(--surface-glass-elevated);
  border: 1px solid var(--border-crimson);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

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

.quick-convert-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.quick-input-field {
  flex: 1;
  height: 44px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.quick-input-field:focus {
  border-color: var(--accent-crimson);
}

.quick-swap-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid var(--border-crimson);
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quick-result-display {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(10, 10, 14, 0.7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quick-result-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-crimson);
}

.quick-copy-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ==========================================================================
   SCREEN 3: MAIN TOOL SCREEN (CONVERTER & CALCULATORS)
   ========================================================================== */

/* Category Tabs Pill Bar */
.category-pills-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.category-pills-bar::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex-shrink: 0;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-pill.active {
  background: var(--gradient-crimson);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-crimson);
}

/* Tool Container Panes */
.tool-pane {
  display: none;
}

.tool-pane.active {
  display: block;
}

/* Unit Converter UI */
.converter-card {
  background: var(--surface-glass-card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.unit-row {
  margin-bottom: 14px;
}

.unit-row-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.unit-input-group {
  display: flex;
  gap: 8px;
}

.unit-number-input {
  flex: 1.2;
  height: 48px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.unit-number-input:focus {
  border-color: var(--accent-crimson);
  box-shadow: 0 0 12px var(--accent-glow-subtle);
}

.unit-select {
  flex: 1;
  height: 48px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.unit-select option {
  background: #14141c;
  color: #ffffff;
}

.unit-swap-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: -4px 0 10px 0;
}

.unit-swap-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-crimson);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-crimson);
  border: 2px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.3s ease;
}

.unit-swap-btn:hover {
  transform: rotate(180deg);
}

/* Quick Input Helper Buttons */
.keypad-helper-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.helper-btn {
  flex: 1;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.helper-btn:hover {
  background: rgba(229, 9, 20, 0.15);
  border-color: var(--border-crimson);
  color: var(--text-primary);
}

/* Primary Result Card */
.result-card {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.16) 0%, rgba(20, 20, 28, 0.95) 100%);
  border: 1px solid var(--border-crimson-bright);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md), 0 0 25px rgba(229, 9, 20, 0.15);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.result-header span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.result-main-value {
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
  word-break: break-word;
  line-height: 1.2;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.result-subtext {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn-copy {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.action-btn-save {
  background: var(--gradient-crimson);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* All Units Reference Table */
.reference-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

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

.reference-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.reference-unit {
  color: var(--text-secondary);
  font-weight: 600;
}

.reference-val {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Percentage Calculator Specifics */
.mode-segmented-control {
  display: flex;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 14px;
}

.segment-btn {
  flex: 1;
  height: 36px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.segment-btn.active {
  background: var(--gradient-crimson);
  color: #ffffff;
  font-weight: 700;
}

.percent-formula-box {
  background: rgba(10, 10, 14, 0.65);
  border-left: 3px solid var(--accent-crimson);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Tip Calculator Specifics */
.tip-chips-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tip-chip {
  flex: 1;
  min-width: 52px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
}

.tip-chip.active {
  background: var(--gradient-crimson);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: var(--shadow-crimson);
}

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  height: 48px;
  padding: 0 6px;
  margin-bottom: 14px;
}

.stepper-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.tip-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.tip-breakdown-cell {
  background: rgba(10, 10, 14, 0.6);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tip-breakdown-cell .cell-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tip-breakdown-cell .cell-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}

.tip-breakdown-cell.primary-cell .cell-val {
  color: var(--text-crimson);
}

/* ==========================================================================
   SCREEN 4: HISTORY & STATISTICS SCREEN
   ========================================================================== */

.chart-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#statsChart {
  width: 100% !important;
  height: 180px !important;
  display: block;
}

.history-filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 12px;
}

.history-filter-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.history-filter-chip.active {
  background: var(--gradient-crimson);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(14px);
  position: relative;
}

.history-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.history-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid var(--border-crimson);
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-content {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.history-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-action-btn:hover {
  background: rgba(229, 9, 20, 0.18);
  color: var(--text-primary);
  border-color: var(--border-crimson);
}

.empty-history-box {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 12px;
  opacity: 0.5;
  color: var(--text-muted);
}

/* ==========================================================================
   SCREEN 5: SETTINGS & LEGAL
   ========================================================================== */

.settings-group {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.settings-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.settings-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(229, 9, 20, 0.12);
  border: 1px solid var(--border-crimson);
  color: var(--accent-crimson);
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-text h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-text p {
  font-size: 11px;
  color: var(--text-muted);
}

.settings-right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

/* Custom Switch Toggle */
.toggle-switch {
  position: relative;
  width: 46px;
  height: 26px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-smooth);
}

.toggle-switch.active {
  background: var(--accent-crimson);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  transition: transform var(--transition-smooth);
}

.toggle-switch.active .toggle-knob {
  transform: translateX(20px);
}

/* ==========================================================================
   BOTTOM NAVIGATION BAR
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: rgba(10, 10, 14, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 60;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  height: 100%;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

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

.nav-item.active svg {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* ==========================================================================
   BOTTOM SHEETS & MODALS (IN-APP DIALOGS)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: #101016;
  border-top: 1px solid var(--border-crimson-bright);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 20px) 20px;
  transform: translateY(100%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(229, 9, 20, 0.2);
}

.modal-backdrop.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 44px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 16px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.sheet-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding-right: 4px;
}

.sheet-body h4 {
  font-size: 14px;
  color: var(--text-primary);
  margin: 14px 0 6px 0;
}

.sheet-body p {
  margin-bottom: 10px;
}

.sheet-footer {
  margin-top: 16px;
  padding-top: 12px;
}

/* Star Rating Controls */
.stars-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
}

.star-btn {
  width: 42px;
  height: 42px;
  color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.star-btn.selected {
  color: #ffb800;
  filter: drop-shadow(0 0 10px rgba(255, 184, 0, 0.6));
}

.rating-textarea {
  width: 100%;
  height: 80px;
  background: var(--surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-primary);
  resize: none;
  font-size: 14px;
  margin-bottom: 14px;
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(20, 20, 28, 0.94);
  border: 1px solid var(--border-crimson);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
