/* Design system variables — light (default) */
:root,
[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #888888;
  --accent: #1d6f42;
  --accent-light: #e8f5ee;
  --t1: #c0392b;  --t1-bg: #fdf0ef;
  --t2: #e67e22;  --t2-bg: #fef9ec;
  --t3: #2980b9;  --t3-bg: #eaf4fd;
  --t4: #888888;  --t4-bg: #f0f0f0;
  --danger: #e74c3c;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #111111;
  --surface: #1e1e1e;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --text-muted: #888888;
  --accent: #2ecc71;
  --accent-light: #0d2b1a;
  --t1: #e74c3c;  --t1-bg: #2b1010;
  --t2: #e67e22;  --t2-bg: #2b1d0a;
  --t3: #3498db;  --t3-bg: #0a1e2b;
  --t4: #888888;  --t4-bg: #1a1a1a;
  --danger: #e74c3c;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --top-bar-h: 52px;
  --bottom-nav-h: 64px;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Top Bar */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-bar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  z-index: 100;
}

.app-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 0.3s;
}
.sync-dot.yellow { background: #f39c12; }
.sync-dot.grey   { background: #bbb; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

/* Floating Status Bar */
.status-bar {
  position: fixed;
  top: calc(var(--top-bar-h) + env(safe-area-inset-top) + 8px);
  left: 16px; right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px 8px;
  z-index: 99;
}

.status-bar-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

.status-bar-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Screens */
.screens {
  position: fixed;
  top: calc(var(--top-bar-h) + env(safe-area-inset-top));
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  left: 0; right: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  background: var(--bg);
}

.screen.active { display: block; }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 0 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
  transition: color 0.15s;
  min-width: 0;
}

.nav-btn.active { color: var(--accent); }
.nav-btn:active { opacity: 0.7; }

.nav-btn-capture {
  position: relative;
  color: var(--accent);
  padding-top: 0;
  /* Elevate the circle above the nav bar so it reads as the primary action */
  margin-top: -22px;
  font-weight: 600;
}

.capture-btn-circle {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(29, 111, 66, 0.45), 0 0 0 4px var(--surface);
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: transform 0.15s;
}

.nav-btn-capture:active .capture-btn-circle {
  transform: scale(0.94);
}

/* Utility classes */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; color: var(--accent); font-weight: 500; }
.btn-full     { width: 100%; }

.tier-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}
.tier-chip.t1 { color: var(--t1); background: var(--t1-bg); }
.tier-chip.t2 { color: var(--t2); background: var(--t2-bg); }
.tier-chip.t3 { color: var(--t3); background: var(--t3-bg); }
.tier-chip.t4 { color: var(--t4); background: var(--t4-bg); }

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

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

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 20px 16px 8px;
}

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

.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* Avatar initial circle */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  display: flex;
  align-items: flex-end;
}

.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}
