@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0c0e16;
  --surface:   #161923;
  --surface2:  #1e2230;
  --border:    #272c3f;
  --accent:    #5b9cf6;
  --accent2:   #7c72ff;
  --danger:    #e05252;
  --success:   #3ec97a;
  --warning:   #f0a500;
  --text:      #e8eaf0;
  --muted:     #6b7194;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.5);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.6);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.7);
  --transition: 0.15s ease;
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Layout ───────────────────────────────────────────── */
header {
  background: rgba(12,14,22,0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(39,44,63,0.7);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-brand .brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.nav-brand .brand-name {
  background: linear-gradient(135deg, #e8eaf0 0%, #5b9cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-email {
  color: var(--muted);
  font-size: 0.875rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  opacity: 0.6;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  background: var(--surface2);
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  {
  background: linear-gradient(135deg, #5b9cf6, #7c72ff);
  color: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(91,156,246,0.35);
}
.btn-primary:hover {
  opacity: 1;
  box-shadow: 0 4px 18px rgba(91,156,246,0.5);
  transform: translateY(-1px);
}
.btn-secondary { background: var(--accent2); color: #fff; border: none; }
.btn-ghost    { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); opacity: 1; }
.btn-sm       { padding: 0.3rem 0.8rem; font-size: 0.78rem; border-radius: 6px; }
.btn-full     { width: 100%; margin-top: 0.5rem; }

/* ── Flash messages ───────────────────────────────────── */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.flash-error { background: rgba(224, 82, 82, 0.15); border: 1px solid var(--danger); color: #f08080; }
.flash-info { background: rgba(79,142,247,0.12); border: 1px solid var(--accent); color: var(--accent); }

/* ── Auth cards ───────────────────────────────────────── */
.auth-card {
  max-width: 400px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.auth-card h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-switch  { margin-top: 1.25rem; text-align: center; color: var(--muted); font-size: 0.875rem; }

/* ── Form fields ──────────────────────────────────────── */
.field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-currency {
  display: flex;
  align-items: center;
  gap: 0;
}
.input-currency-sym {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 0.5rem 0.55rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1;
}
.input-currency input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.hint { color: var(--muted); font-size: 0.8rem; margin-left: 0.25rem; }

/* ── Analyze page ─────────────────────────────────────── */
.analyze-wrap { max-width: 600px; margin: 0 auto; }
.analyze-wrap h1 { margin-bottom: 1.5rem; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.form-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.photo-tips {
  margin-bottom: 1rem;
}
.photo-tips-toggle {
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.photo-tips-toggle:hover { text-decoration: underline; }
.photo-tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(79, 142, 247, 0.07);
  border: 1px solid rgba(79, 142, 247, 0.25);
  border-radius: var(--radius);
}
.photo-tips-list li {
  font-size: 0.82rem;
  color: var(--muted);
  padding-left: 1.1rem;
  position: relative;
}
.photo-tips-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}
.photo-tips-list strong { color: var(--text); }

.image-preview {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius);
  margin-top: 0.75rem;
  border: 1px solid var(--border);
}

.spinner-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard ────────────────────────────────────────── */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.analysis-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.analysis-card:hover .card-thumb {
  transform: scale(1.03);
}

.card-thumb-wrap {
  position: relative;
  overflow: hidden;
  height: 185px;
  background: var(--surface2);
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.card-badge-overlay {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.card-stats {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
  padding-top: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 0.65rem 0.5rem;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.15rem; }
.stat-value { font-size: 1rem; font-weight: 700; color: var(--text); }

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-date { font-size: 0.78rem; color: var(--muted); }
.card-engine { font-size: 0.72rem; color: var(--muted); }

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ── Pattern badge ────────────────────────────────────── */
.pattern-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  background: rgba(12,14,22,0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
}
.pattern-center      { border-color: var(--success); color: var(--success); }
.pattern-scattered   { border-color: var(--danger);  color: var(--danger); }
.pattern-low_left    { border-color: var(--warning);  color: var(--warning); }
.pattern-low_right   { border-color: var(--warning);  color: var(--warning); }
.pattern-high_right  { border-color: var(--warning);  color: var(--warning); }
.pattern-high_left   { border-color: var(--warning);  color: var(--warning); }
.pattern-low         { border-color: var(--accent2);  color: var(--accent2); }
.pattern-high        { border-color: var(--accent2);  color: var(--accent2); }
.pattern-left        { border-color: var(--accent);   color: var(--accent); }
.pattern-right       { border-color: var(--accent);   color: var(--accent); }

/* ── Result page ──────────────────────────────────────── */
.result-wrap { max-width: 1000px; margin: 0 auto; }

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.result-header h1 {
  flex: 1;
  font-size: 1.35rem;
  font-weight: 700;
  min-width: 0;
}
.result-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.result-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.result-title-text {
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-title-text:hover { opacity: 0.7; }
.result-title-edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  flex-shrink: 0;
}
.result-title-edit-btn:hover { color: var(--fg); }
.result-title-form {
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
.result-title-input {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  padding: 0.25rem 0.5rem;
  min-width: 0;
}

.annotated-wrap {
  margin-bottom: 1.5rem;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.annotated-container {
  position: relative;
}
.annotated-img {
  width: 100%;
  display: block;
  max-height: 520px;
  object-fit: contain;
}
.diam-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.diam-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.diam-toggle input { margin: 0; }
.annotated-legend {
  padding: 0.55rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 1.25rem;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  flex-shrink: 0;
}
.legend-blue { background: #4a7de8; }
.legend-red  { background: #e84a4a; }

/* Big stat tiles — key numbers at a glance */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 0.75rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-tile-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}
.stat-tile-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}
.stat-tile-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.result-bottom-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}
@media (max-width: 700px) {
  .result-bottom-row { flex-direction: column; }
}
.result-heatmap-wrap {
  display: flex;
  flex-shrink: 0;
}
.result-drills-card {
  flex: 1;
  min-width: 0;
}
.result-drills-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 280px;
  overflow-y: auto;
}
.result-drill-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.result-drill-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
}
.result-drill-desc {
  font-size: 0.78rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-heatmap-canvas {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity .15s;
}
.result-heatmap-canvas:hover { opacity: .85; }

/* Heat map enlarge modal */
.result-heatmap-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.75);
  justify-content: center;
  align-items: center;
}
.result-heatmap-modal.active { display: flex; }
.result-heatmap-modal-inner {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.result-heatmap-modal-canvas {
  border-radius: var(--radius);
  display: block;
}
.result-heatmap-modal-close {
  position: absolute;
  top: .25rem;
  right: .5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.result-heatmap-modal-close:hover { color: var(--text); }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .result-grid { grid-template-columns: 1fr; }
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.result-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
}
.result-card h2 { font-size: 1rem; margin-bottom: 1rem; font-weight: 600; }

.stats-dl {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.stats-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(39,44,63,0.5);
}
.stats-row:last-child { border-bottom: none; }
.stats-dt { color: var(--muted); font-size: 0.82rem; flex-shrink: 0; }
.stats-dd { font-weight: 500; font-size: 0.875rem; text-align: right; }

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.1rem;
  font-size: 0.8rem;
}
.confidence-label { color: var(--muted); white-space: nowrap; }
.bar-track {
  flex: 1;
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--warning) 50%, var(--success));
  border-radius: 99px;
  transition: width 0.5s ease;
}
.confidence-pct { color: var(--muted); min-width: 2.5rem; text-align: right; }

.engine-tag { font-size: 0.78rem; color: var(--muted); margin-top: 0.75rem; }

.inline-gun-form { display: inline; }
.inline-gun-select {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
}

/* Pattern card */
.result-card-pattern {
  border-top: 3px solid var(--accent);
}
.pattern-label-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.pattern-label-row .pattern-badge { font-size: 0.8rem; }

.causes-list {
  list-style: none;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.causes-list li {
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.causes-list li:has(.cause-illustration) {
  padding-left: 0;
}
.causes-list li:has(.cause-illustration)::before {
  display: none;
}
.cause-illustration {
  width: 56px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--surface2);
  padding: 2px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.cause-illustration:hover {
  transform: scale(1.15);
}

/* Tip illustration lightbox */
.tip-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
}
.tip-modal.active {
  display: flex;
}
.tip-modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 90vh;
}
.tip-modal-content img {
  display: block;
  width: 320px;
  max-width: 80vw;
  height: auto;
}
.tip-modal-close {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.tip-modal-close:hover {
  color: var(--text);
}
.causes-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.notes { font-size: 0.85rem; color: var(--muted); margin-top: 0.9rem; line-height: 1.5; }

.claude-retry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.claude-retry p { font-size: 0.875rem; color: var(--muted); }

.text-muted { color: var(--muted); }
.safety-disclaimer {
  font-size: 0.75rem;
  color: #e05252;
  border-left: 3px solid #e05252;
  padding: 0.4rem 0.6rem;
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* ── Editor page ──────────────────────────────────────── */
.edit-wrap { max-width: 1000px; margin: 0 auto; }

.edit-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.edit-header h1 { flex: 1; }

.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.6rem 0.9rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
}

.toolbar-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 0.15rem;
}

.toolbar-separator {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
  margin: 0 0.25rem;
}

.toolbar-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.3rem 0.9rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.toolbar-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.toolbar-toggle input { margin: 0; }

.canvas-container {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
  display: block;
  height: 70vh;
  min-height: 400px;
}

#editor {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
  touch-action: none;
}

/* ── Gun management page ──────────────────────────────── */
.guns-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.guns-header h1 { flex: 1; }

.guns-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 700px) {
  .guns-layout { grid-template-columns: 1fr; }
}

.gun-add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.gun-add-card h2 { margin-bottom: 1rem; }

.gun-list { display: flex; flex-direction: column; gap: 0.75rem; }

.gun-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.gun-info {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.gun-name { font-weight: 600; }
.target-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: var(--radius);
  vertical-align: middle;
  margin-right: 0.4rem;
}
.gun-caliber {
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(79,142,247,0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}
.gun-notes { font-size: 0.85rem; }

.gun-actions { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.btn-danger { color: var(--danger) !important; }
.btn-danger:hover { background: rgba(224,82,82,0.12) !important; }

.gun-edit-form { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* Inline gun add / edit row inside profile */
.gun-add-inline { margin-bottom: 0; }

.gun-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.gun-add-input {
  flex: 1 1 140px;
  min-width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.gun-add-input:focus { outline: none; border-color: var(--accent); }
.gun-add-btn { flex-shrink: 0; }

/* ── Dashboard grouping ───────────────────────────────── */
.dashboard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.group-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
}

.tab {
  padding: 0.35rem 0.9rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--accent); color: #fff; }

.analysis-group { margin-bottom: 2rem; }
.group-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.gun-tag {
  font-size: 0.7rem;
  color: rgba(232,234,240,0.85);
  background: rgba(12,14,22,0.7);
  backdrop-filter: blur(8px);
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}

/* ── Flash success ────────────────────────────────────── */
.flash-success { background: rgba(62, 201, 122, 0.12); border: 1px solid var(--success); color: var(--success); }

/* ── Training labeling tool ───────────────────────────── */
.train-wrap { max-width: 1100px; margin: 0 auto; }
.train-wrap h1 { margin-bottom: 0.25rem; }

.train-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .train-layout { grid-template-columns: 1fr; }
}

.train-canvas-col { min-width: 0; }

.train-upload-prompt {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface);
}
.train-upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.train-upload-prompt p { margin-bottom: 1rem; }

.train-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.train-hole-count { font-size: 0.875rem; color: var(--muted); margin-right: auto; }

.train-canvas {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: crosshair;
}

.train-form-col { display: flex; flex-direction: column; gap: 0; }
.train-form-col textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  resize: vertical;
  font-family: inherit;
}
.train-form-col textarea:focus { outline: none; border-color: var(--accent); }

/* ── Nav avatar ───────────────────────────────────────── */
.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent2);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.nav-avatar:hover { opacity: 0.85; text-decoration: none; }

/* ── Nav dropdown ────────────────────────────────────── */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger { cursor: pointer; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  padding-top: 0.35rem;
  z-index: 200;
}
.nav-dropdown-menu-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 150px;
  padding: 0.35rem 0;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }
.nav-dropdown-item {
  display: block;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
}
.nav-dropdown-item:hover { background: var(--surface2); text-decoration: none; }

/* ── Dashboard enhancements ───────────────────────────── */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-select,
.filter-date {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  height: 2rem;
}
.filter-select:focus,
.filter-date:focus {
  outline: none;
  border-color: var(--accent);
}

.gun-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.gun-filter-chip {
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.gun-filter-chip:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.gun-filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.filter-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.page-btn:hover { border-color: var(--accent); background: var(--surface2); text-decoration: none; }
.page-btn-disabled { color: var(--muted); cursor: default; }
.page-btn-disabled:hover { border-color: var(--border); background: var(--surface); }
.page-info { font-size: 0.875rem; color: var(--muted); }

.card-thumb-empty {
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  height: 100%;
  width: 100%;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.empty-state h2 { font-size: 1.25rem; color: var(--text); }
.empty-state p  { color: var(--muted); }

/* ── Profile page ─────────────────────────────────────── */
.profile-wrap { max-width: 900px; margin: 0 auto; }

.profile-page-header {
  margin-bottom: 2rem;
}
.profile-page-header h1 { margin-bottom: 0.5rem; }

.profile-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 680px) {
  .profile-layout { grid-template-columns: 1fr; }
}

/* Account card */
.profile-account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.profile-identity { width: 100%; }
.profile-email {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
  margin-bottom: 0.2rem;
}
.profile-since {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Plan badge */
.plan-badge {
  display: inline-block;
  padding: 0.25rem 0.9rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.plan-badge-free {
  background: rgba(122,127,153,0.15);
  border: 1px solid var(--border);
  color: var(--muted);
}
.plan-badge-pro {
  background: linear-gradient(135deg, rgba(79,142,247,0.2), rgba(108,99,255,0.2));
  border: 1px solid var(--accent2);
  color: var(--accent2);
}
.plan-badge-hobby {
  background: linear-gradient(135deg, rgba(240,165,0,0.2), rgba(240,165,0,0.1));
  border: 1px solid var(--warning);
  color: var(--warning);
}

/* Stats row */
.profile-stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.profile-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.profile-stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.profile-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

/* Upgrade card */
.plan-upgrade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}
.plan-upgrade-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--warning);
}
.plan-upgrade-card h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.plan-features {
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}
.plan-features li::before {
  content: '✓ ';
  color: var(--success);
  font-weight: 700;
}

/* Settings cards */
.profile-right { display: flex; flex-direction: column; gap: 1rem; }

.profile-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.profile-link-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 500px) {
  .profile-link-row { grid-template-columns: 1fr; }
}
.profile-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 0.75rem;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--fg);
  transition: border-color .15s, box-shadow .15s;
}
.profile-link-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.profile-link-title {
  font-size: 0.85rem;
  font-weight: 600;
}
.profile-link-count {
  font-size: 0.75rem;
  color: var(--muted);
}
.profile-link-arrow {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.profile-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.profile-section-hint {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 1rem;
  margin-top: -0.5rem;
}

/* Unit toggle */
.unit-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.unit-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
  text-align: center;
}
.unit-option input { display: none; }
.unit-option:hover { border-color: var(--accent); }
.unit-option.active {
  border-color: var(--accent);
  background: rgba(79,142,247,0.08);
}
.unit-option-icon { font-size: 1.5rem; }
.unit-option-label { font-weight: 600; font-size: 0.9rem; }
.unit-option-sub   { font-size: 0.75rem; color: var(--muted); }

/* ── Editor page ──────────────────────────────────────── */
.edit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Admin page ───────────────────────────────────────── */
.admin-wrap { max-width: 1100px; margin: 0 auto; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}
.admin-header h1 { margin: 0; }
.admin-user-count {
  font-size: .85rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: .25rem .75rem;
  border-radius: 99px;
}

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-table thead tr {
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
}
.admin-table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.admin-table th.num { text-align: right; }
.admin-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table td.num { text-align: right; color: var(--muted); }
.admin-table td.num-hi { text-align: right; }
.admin-table td.num-ai { text-align: right; color: var(--accent2); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255,255,255,.02); }

.admin-badge {
  display: inline-block;
  font-size: .7rem;
  background: rgba(240,165,0,.15);
  color: var(--warning);
  border: 1px solid rgba(240,165,0,.35);
  padding: .1rem .4rem;
  border-radius: .25rem;
  margin-left: .35rem;
  vertical-align: middle;
}

.admin-plan-form {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.admin-plan-select {
  font-size: .8rem;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.admin-plan-select:focus { outline: none; border-color: var(--accent); }
.admin-plan-save {
  font-size: .75rem;
  padding: .25rem .65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition);
}
.admin-plan-save:hover { opacity: .85; }

.admin-section-title {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.admin-plans-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-plans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-plans-table thead tr {
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
}
.admin-plans-table th {
  padding: .65rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.admin-plans-table th.num { text-align: right; }
.admin-plans-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-plans-table td.num { text-align: right; }
.admin-plans-table tbody tr:last-child td { border-bottom: none; }

/* ── Profile usage card ───────────────────────────────── */
.usage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.usage-card-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.usage-row {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.usage-row-header {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
}
.usage-row-label { color: var(--text); }
.usage-row-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-bar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}
.usage-bar-fill-blue   { background: linear-gradient(90deg, var(--accent), #60a5fa); }
.usage-bar-fill-purple { background: linear-gradient(90deg, var(--accent2), #a78bfa); }
.usage-no-ai {
  font-size: .8rem;
  color: var(--muted);
}

/* ── Diary ───────────────────────────────────────────── */
.diary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.diary-header h1 { flex: 1; }

/* Goals bar */
.diary-goals-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.diary-goals-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.diary-goals-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.diary-goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: rgba(91,156,246,0.1);
  border: 1px solid rgba(91,156,246,0.3);
  border-radius: 99px;
  font-size: 0.82rem;
}
.diary-goal-desc { color: var(--text); font-weight: 500; }
.diary-goal-metric { color: var(--accent); font-size: 0.78rem; }
.diary-goal-deadline { color: var(--muted); font-size: 0.78rem; }
.diary-goal-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}
.diary-goal-dismiss:hover { color: var(--danger); }

/* Add goal */
.diary-add-goal {
  margin-bottom: 1.25rem;
}
.diary-add-goal summary { cursor: pointer; list-style: none; }
.diary-add-goal summary::-webkit-details-marker { display: none; }
.diary-goal-form {
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.diary-goal-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.diary-goal-input {
  flex: 1 1 180px;
  min-width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}
.diary-goal-input:focus { outline: none; border-color: var(--accent); }
.diary-goal-input-sm { flex: 0 1 120px; min-width: 80px; }
.diary-goal-select {
  flex: 0 1 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}

/* Timeline cards */
.diary-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.diary-card {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.diary-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  box-shadow: var(--shadow-md);
}

.diary-card-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}
.diary-card-day {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.diary-card-month {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.diary-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.diary-card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.diary-card-location { font-weight: 500; }
.diary-weather-tag,
.diary-mood-tag {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--muted);
}

.diary-card-drills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.diary-drill-tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(124,114,255,0.12);
  color: var(--accent2);
  border: 1px solid rgba(124,114,255,0.3);
}

.diary-card-notes {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.diary-card-ai-summary {
  font-size: 0.82rem;
  color: var(--accent);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diary-card-stats {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  min-width: 120px;
  text-align: right;
}
.diary-mini-stat {
  font-size: 0.78rem;
  color: var(--muted);
}

.diary-shared-badge {
  font-size: 0.7rem;
  background: rgba(62,201,122,0.15);
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.pagination-info {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Diary View ──────────────────────────────────────── */
.diary-view-wrap { max-width: 900px; margin: 0 auto; }

.diary-view-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.diary-view-header h1 { flex: 1; }

.diary-share-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(62,201,122,0.08);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.diary-share-url {
  background: var(--bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diary-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.diary-meta-item {
  font-size: 0.875rem;
  color: var(--text);
}

.diary-drills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.diary-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.diary-section h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.diary-gun-breakdown { display: flex; flex-direction: column; gap: 0.5rem; }
.diary-gun-row { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.diary-gun-name { font-weight: 500; }

.diary-pattern-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.diary-notes-text {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.diary-ai-summary {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--accent);
  font-style: italic;
  padding: 0.75rem 1rem;
  background: rgba(91,156,246,0.06);
  border-radius: var(--radius);
}

/* ── Diary Form ──────────────────────────────────────── */
.diary-form-wrap { max-width: 900px; margin: 0 auto; }
.diary-form-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.diary-form-header h1 { flex: 1; }

.diary-form-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 700px) {
  .diary-form-grid { grid-template-columns: 1fr; }
}

.diary-form-main { min-width: 0; }
.diary-form-sidebar { min-width: 0; }

.diary-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.diary-toggle-option {
  cursor: pointer;
}
.diary-toggle-option input { display: none; }
.diary-toggle-label {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.82rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all 0.15s;
}
.diary-toggle-option input:checked + .diary-toggle-label {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.diary-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
}
.diary-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.25rem 0;
}
.diary-checkbox-item input { margin: 0; }

.diary-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Drills layout (reuses gun patterns) ── */
.drills-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 700px) {
  .drills-layout { grid-template-columns: 1fr; }
}
.drill-add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.drill-add-card h2 { margin-bottom: 1rem; }
.drill-list { display: flex; flex-direction: column; gap: 0.75rem; }
.drill-default-badge {
  font-size: 0.65rem;
  background: rgba(62,201,122,0.15);
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 20px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
}
.drill-tag-row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.drill-pattern-chip {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  background: rgba(91,140,255,0.12);
  color: var(--accent);
  border: 1px solid rgba(91,140,255,0.3);
}
.drill-general-chip {
  background: rgba(255,204,0,0.12);
  color: #ffcc00;
  border-color: rgba(255,204,0,0.3);
}
.drill-pattern-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.diary-toggle-sm .diary-toggle-label { font-size: 0.72rem; padding: 0.2rem 0.5rem; }
.analyze-drill-list { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }

/* ── Changelog ───────────────────────────────────────── */
.changelog { display: flex; flex-direction: column; gap: 1.5rem; }
.changelog-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.changelog-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.changelog-entry h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.changelog-entry ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.changelog-entry li {
  font-size: 0.875rem;
  color: var(--muted);
  padding-left: 1rem;
  position: relative;
  line-height: 1.5;
}
.changelog-entry li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}
.changelog-entry li strong { color: var(--text); }

/* ── Diary filter bar ────────────────────────────────── */
.diary-filter-bar { margin-bottom: 1rem; }
.diary-filter-bar > summary { list-style: none; cursor: pointer; }
.diary-filter-bar > summary::-webkit-details-marker { display: none; }
.diary-filter-form { margin-top: 0.75rem; }
.diary-filter-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end;
}
.diary-filter-field { display: flex; flex-direction: column; gap: 0.25rem; }
.diary-filter-field label { font-size: 0.75rem; color: var(--muted); }
.diary-filter-field input,
.diary-filter-field select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 0.35rem 0.5rem; font-size: 0.85rem;
}
.diary-filter-actions { display: flex; gap: 0.5rem; align-items: flex-end; }
.diary-filter-summary { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.75rem; }

/* ── Diary card title & session tracking ─────────────── */
.diary-card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.diary-card-rounds,
.diary-card-duration { font-size: 0.8rem; color: var(--muted); }
.diary-inline-title { cursor: pointer; }
.diary-inline-title:hover { color: var(--accent); }
.diary-ammo-tag {
  background: var(--surface2); border-radius: 4px; padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
}

/* ── Diary form 3-col row ────────────────────────────── */
.diary-form-row-3 {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem;
}
@media (max-width: 600px) {
  .diary-form-row-3 { grid-template-columns: 1fr; }
}

/* ── Drill filter chips ──────────────────────────────── */
.drill-filter-row {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem;
}
.drill-filter-chip {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 14px; padding: 0.25rem 0.65rem; font-size: 0.78rem;
  cursor: pointer; transition: var(--transition);
}
.drill-filter-chip:hover { border-color: var(--accent); color: var(--text); }
.drill-filter-chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.drill-filter-count { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.75rem; }

/* ── Calendar ────────────────────────────────────────── */
.calendar-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.calendar-month-label { font-size: 1.1rem; font-weight: 600; }
.calendar-grid { margin-bottom: 1rem; }
.calendar-header-row {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  text-align: center; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.25rem;
}
.calendar-week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.calendar-day {
  aspect-ratio: 1; background: var(--surface); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; min-height: 48px;
}
.calendar-day-outside { opacity: 0.3; }
.calendar-day-today { border: 2px solid var(--accent); }
.calendar-day-has { background: var(--surface2); }
.calendar-day-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; text-decoration: none; color: var(--text);
}
.calendar-day-link:hover { text-decoration: none; }
.calendar-day-empty .calendar-day-num { color: var(--muted); }
.calendar-day-num { font-size: 0.85rem; font-weight: 500; }
.calendar-day-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-top: 2px;
}
.calendar-day-dots { display: flex; gap: 2px; }
.calendar-day-multi {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; cursor: pointer; position: relative;
}
.calendar-day-popover {
  display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.4rem; z-index: 10; min-width: 140px; box-shadow: var(--shadow-md);
}
.calendar-day-multi:hover .calendar-day-popover { display: block; }
.calendar-popover-item {
  display: block; padding: 0.25rem 0.5rem; font-size: 0.8rem; color: var(--text);
  border-radius: 4px; text-decoration: none; white-space: nowrap;
}
.calendar-popover-item:hover { background: var(--surface2); text-decoration: none; }
.calendar-summary {
  display: flex; gap: 1.5rem; justify-content: center; font-size: 0.9rem;
  color: var(--muted); padding: 0.75rem 0; border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
  .calendar-day { min-height: 36px; }
  .calendar-day-dot { width: 4px; height: 4px; }
  .calendar-summary { flex-direction: column; align-items: center; gap: 0.25rem; }
}

/* ── Ammo specs row ──────────────────────────────────── */
.ammo-specs-row {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

/* ── Cost breakdown table ────────────────────────────── */
.cost-table {
  width: 100%;
  max-width: 400px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.cost-table td { padding: 0.35rem 0; }
.cost-table .cost-amount { text-align: right; font-variant-numeric: tabular-nums; }
.cost-table tfoot { border-top: 1px solid var(--border); }
.cost-total-row td { font-weight: 600; padding-top: 0.5rem; }
.cost-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
@media (max-width: 600px) { .cost-form-grid { grid-template-columns: 1fr; } }

/* ── Diary heatmaps ──────────────────────────────────── */
.diary-heatmap-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.diary-heatmap-card { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.diary-heatmap-canvas { border-radius: var(--radius); cursor: default; }
.diary-heatmap-label { font-size: 0.78rem; color: var(--muted); text-align: center; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Ammo detail page ────────────────────────────────── */
.ammo-detail-wrap { max-width: 900px; margin: 0 auto; }
.ammo-detail-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 1.5rem; align-items: flex-start; }
.ammo-detail-section { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.ammo-detail-section h2 { font-size: 1rem; margin-bottom: 0.25rem; }
.ammo-trend-canvas { width: 100%; height: 200px; border-radius: var(--radius); background: #0a0c14; }

/* ── Ammo session table ──────────────────────────────── */
.ammo-session-table-wrap { overflow-x: auto; }
.ammo-session-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ammo-session-table th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.ammo-session-table td { padding: 0.45rem 0.75rem; border-bottom: 1px solid rgba(39,44,63,0.3); }
.ammo-session-table tr:hover td { background: rgba(39,44,63,0.2); }

/* ── Ammo compare page ───────────────────────────────── */
.ammo-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.ammo-compare-name { font-size: 1.1rem; font-weight: 600; }
.ammo-compare-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 1rem; }
.ammo-compare-table th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.ammo-compare-table td { padding: 0.45rem 0.75rem; border-bottom: 1px solid rgba(39,44,63,0.3); font-variant-numeric: tabular-nums; }
.ammo-compare-table td:first-child { color: var(--muted); }
.ammo-trend-legend { display: flex; gap: 1.5rem; margin-bottom: 0.5rem; font-size: 0.82rem; color: var(--muted); }
.ammo-trend-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.ammo-trend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

@media (max-width: 600px) {
  .ammo-compare-grid { grid-template-columns: 1fr; }
  .ammo-detail-row { flex-direction: column; }
}

/* ── Crop interface ──────────────────────────────────────── */
#crop-container { max-height: 500px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
#crop-container img { display: block; max-width: 100%; }
.crop-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
/* Cropper.js dark theme overrides */
.cropper-modal { background: rgba(0,0,0,0.65) !important; }
.cropper-view-box { outline: 2px solid var(--accent) !important; outline-color: var(--accent) !important; }
.cropper-line { background-color: var(--accent) !important; }
.cropper-point { background-color: var(--accent) !important; width: 8px !important; height: 8px !important; }
.cropper-dashed { border-color: rgba(255,255,255,0.3) !important; }
@media (max-width: 600px) {
  #crop-container { max-height: 60vh; }
  .crop-actions { flex-direction: column; }
  .crop-actions .btn { width: 100%; }
}

/* ── Social login / OAuth ────────────────────────────── */
.social-login { display: flex; flex-direction: column; gap: 0.5rem; }
.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; padding: 0.6rem 1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  font-size: 0.9rem; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-social:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-social svg { flex-shrink: 0; }

.auth-divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1rem 0; color: var(--text-muted); font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Profile linked accounts */
.linked-accounts-list { display: flex; flex-direction: column; gap: 0.5rem; }
.linked-account-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
}
.linked-account-row:last-child { border-bottom: none; }
.linked-account-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
