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

/* ===== Theme: Dark (default) ===== */
body.theme-dark {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --bg-card-hover: #1a4a7a;
  --accent: #84a98c;
  --accent-hover: #9ec5a6;
  --accent-dim: #52796f;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0b0;
  --text-dim: #6b6b80;
  --border: #2a2a4a;
  --danger: #e07070;
  --danger-hover: #f08080;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --glass-bg: rgba(15,52,96,0.6);
  --glass-border: rgba(132,169,140,0.15);
}

/* ===== Theme: Medium ===== */
body.theme-medium {
  --bg-primary: #2c2c3a;
  --bg-secondary: #38384a;
  --bg-card: #44445a;
  --bg-card-hover: #50506a;
  --accent: #84a98c;
  --accent-hover: #9ec5a6;
  --accent-dim: #52796f;
  --text-primary: #f0f0f0;
  --text-secondary: #b0b0c0;
  --text-dim: #808094;
  --border: #4a4a60;
  --danger: #e07070;
  --danger-hover: #f08080;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.25);
  --glass-bg: rgba(68,68,90,0.6);
  --glass-border: rgba(132,169,140,0.15);
}

/* ===== Theme: Light ===== */
body.theme-light {
  --bg-primary: #f5f5f0;
  --bg-secondary: #eaeae5;
  --bg-card: #ddddd8;
  --bg-card-hover: #d0d0cb;
  --accent: #52796f;
  --accent-hover: #3a5f55;
  --accent-dim: #84a98c;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a60;
  --text-dim: #7a7a90;
  --border: #c8c8c0;
  --danger: #c05050;
  --danger-hover: #a04040;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --glass-bg: rgba(221,221,216,0.7);
  --glass-border: rgba(82,121,111,0.15);
}

:root {
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar-width: 180px;
  --warm-accent: #d4a574;
  --success: #4caf50;
  --warning: #ff9800;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Titlebar ===== */
.titlebar {
  -webkit-app-region: drag;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.titlebar-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  height: calc(100vh - 38px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.nav-btn {
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  position: relative;
}

.nav-btn:hover {
  background: rgba(132, 169, 140, 0.06);
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(132, 169, 140, 0.1);
  border-left-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.nav-btn svg { flex-shrink: 0; }

.nav-label { pointer-events: none; }

.badge {
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: auto;
}

.sidebar-spacer { flex: 1; }

/* ===== Sidebar user info ===== */
.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-name {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== Mobile Nav ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: none;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
  z-index: 50;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  position: relative;
}

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

.mobile-nav-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.mobile-nav-btn svg { flex-shrink: 0; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  padding: 24px;
  scroll-behavior: smooth;
}

.view {
  max-width: 900px;
  margin: 0 auto;
  animation: viewFadeIn 0.25s ease;
}

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

/* ===== Buttons ===== */
.btn-primary, .btn-accent, .btn-ghost, .btn-danger, .btn-sm,
.nav-btn, .mobile-nav-btn, .slot-btn, .recipe-card {
  touch-action: manipulation;
}

.btn-primary {
  -webkit-app-region: no-drag;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.98); box-shadow: none; }

.btn-accent {
  -webkit-app-region: no-drag;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn-accent:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-accent:active { transform: scale(0.98); box-shadow: none; }
.btn-accent:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  -webkit-app-region: no-drag;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s, transform 0.1s;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.btn-ghost:active { transform: scale(0.98); }

.btn-danger {
  -webkit-app-region: no-drag;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s, transform 0.1s;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-danger:active { transform: scale(0.98); }

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(132, 169, 140, 0.05);
  box-shadow: inset 0 0 30px rgba(132, 169, 140, 0.05);
}

.drop-zone.drag-over {
  animation: dropPulse 1.5s ease infinite;
}

@keyframes dropPulse {
  0%, 100% { box-shadow: inset 0 0 20px rgba(132,169,140,0.05); }
  50% { box-shadow: inset 0 0 40px rgba(132,169,140,0.1); }
}

.drop-icon {
  width: 64px;
  height: 64px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.drop-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.drop-subtext {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ===== Results ===== */
.results { animation: fadeIn 0.3s ease; }

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

/* ===== Read View Hero ===== */
.read-hero {
  margin-bottom: 24px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.read-hero-img-wrap {
  position: relative;
  width: 100%;
  max-height: 320px;
  overflow: hidden;
  background: #111;
}

.read-hero-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
}

.read-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 20px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.read-hero-sim {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  padding: 5px 14px;
  border-radius: 6px;
  background: rgba(132,169,140,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.read-hero-file {
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', monospace;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.read-hero-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Film sim badge color variants */
.read-hero-sim[data-sim-family="warm"]    { background: rgba(212,165,116,0.85); }
.read-hero-sim[data-sim-family="vivid"]   { background: rgba(192,57,43,0.85); }
.read-hero-sim[data-sim-family="neutral"] { background: rgba(127,140,141,0.85); }
.read-hero-sim[data-sim-family="mono"]    { background: rgba(44,44,44,0.9); }
.read-hero-sim[data-sim-family="cinema"]  { background: rgba(44,62,80,0.85); }
.read-hero-sim[data-sim-family="green"]   { background: rgba(107,159,120,0.85); }

/* ===== Columns (Recipe) ===== */
.columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: 720px;
}

.column-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

/* Recipe Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
}

.card:hover {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Visual recipe parameter — highlighted card */
.card-visual {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s, box-shadow 0.2s;
}

.card-visual:hover {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-md);
}

.card-visual-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.card-visual-body {
  flex: 1;
  min-width: 0;
}

.card-visual-body .card-label {
  margin-bottom: 2px;
}

.card-visual-body .card-value {
  font-size: 15px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.card-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* Inline recipe row — multiple params in one line */
.recipe-params-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.recipe-param {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}

.recipe-param:hover {
  border-color: var(--accent-dim);
}

.recipe-param .card-label {
  font-size: 9px;
  margin-bottom: 4px;
  text-align: center;
}

.recipe-param .card-value {
  font-size: 14px;
  text-align: center;
}

.card-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.card-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
}

.sub-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sub-value {
  font-size: 15px;
  font-weight: 500;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--text-primary);
}

/* Camera Info — visual grid */
.camera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.camera-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}

.camera-stat:hover {
  border-color: var(--accent-dim);
}

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

.camera-stat-value {
  font-size: 13px;
  font-weight: 500;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Camera stat spanning full width */
.camera-stat-wide {
  grid-column: 1 / -1;
}

/* Legacy info-row for compatibility */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.5);
}

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

.info-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--text-primary);
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Photo Preview Bar ===== */
.photo-preview-bar {
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.photo-preview-wrapper {
  position: relative;
  max-height: 240px;
  overflow: hidden;
}

.preview-photo {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
  transition: filter 0.4s ease;
}

.photo-preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  padding: 20px 16px 8px;
  pointer-events: none;
}

.preview-recipe-label {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.photo-preview-controls {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  align-items: center;
  border-top: 1px solid var(--border);
}

/* ===== Detail Thumbnail Compare ===== */
.detail-preview-thumb {
  margin-bottom: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.thumb-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.thumb-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.thumb-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  transition: filter 0.4s ease;
}

.thumb-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ===== Saved Recipes View ===== */
.saved-header {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.saved-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

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

#btn-enter-select.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.recipe-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  animation: cardSlideIn 0.3s ease backwards;
}

.recipe-card:hover {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.recipe-card-public {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 4px rgba(74, 222, 128, 0.5);
  pointer-events: none;
}

.btn-icon-only {
  padding: 6px !important;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.recipe-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-card-sim {
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--accent);
  margin-bottom: 6px;
}

.recipe-card-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
}

.recipe-card-author {
  font-size: 12px;
  color: var(--accent-dim);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.recipe-card--imported { border-left: 3px solid rgba(100, 100, 140, 0.3); }
.recipe-card--manual { border-left: 3px solid rgba(132, 169, 140, 0.3); }

.saved-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-dim);
}

.saved-empty svg { margin-bottom: 16px; }
.saved-empty p { font-size: 16px; margin-bottom: 4px; }
.saved-empty-sub { font-size: 13px; color: var(--text-dim); }

/* Saved Detail Hero (mirrors .read-hero structure) */
.detail-hero {
  margin-bottom: 24px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.detail-hero-banner {
  position: relative;
  padding: 28px 24px 20px;
  background: linear-gradient(135deg, rgba(132,169,140,0.12) 0%, rgba(42,42,74,0.18) 100%);
  border-bottom: 1px solid var(--border);
}

/* Film sim family color variants for banner accent */
.detail-hero-banner[data-sim-family="warm"]    { background: linear-gradient(135deg, rgba(212,165,116,0.15) 0%, rgba(42,42,74,0.12) 100%); }
.detail-hero-banner[data-sim-family="vivid"]   { background: linear-gradient(135deg, rgba(192,57,43,0.12) 0%, rgba(42,42,74,0.12) 100%); }
.detail-hero-banner[data-sim-family="neutral"] { background: linear-gradient(135deg, rgba(127,140,141,0.12) 0%, rgba(42,42,74,0.12) 100%); }
.detail-hero-banner[data-sim-family="mono"]    { background: linear-gradient(135deg, rgba(44,44,44,0.18) 0%, rgba(42,42,74,0.10) 100%); }
.detail-hero-banner[data-sim-family="cinema"]  { background: linear-gradient(135deg, rgba(44,62,80,0.18) 0%, rgba(42,42,74,0.10) 100%); }
.detail-hero-banner[data-sim-family="green"]   { background: linear-gradient(135deg, rgba(107,159,120,0.15) 0%, rgba(42,42,74,0.12) 100%); }

.detail-hero-sim {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  padding: 4px 14px;
  border-radius: 6px;
  background: rgba(132,169,140,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

/* Same data-sim-family color variants as read-hero-sim */
.detail-hero-sim[data-sim-family="warm"]    { background: rgba(212,165,116,0.85); }
.detail-hero-sim[data-sim-family="vivid"]   { background: rgba(192,57,43,0.85); }
.detail-hero-sim[data-sim-family="neutral"] { background: rgba(127,140,141,0.85); }
.detail-hero-sim[data-sim-family="mono"]    { background: rgba(44,44,44,0.9); }
.detail-hero-sim[data-sim-family="cinema"]  { background: rgba(44,62,80,0.85); }
.detail-hero-sim[data-sim-family="green"]   { background: rgba(107,159,120,0.85); }

.detail-hero-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-hero-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.detail-hero-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
}

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

.detail-author {
  color: var(--accent);
  font-weight: 500;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 9px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 140px;
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.tag-chips-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(132, 169, 140, 0.1);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tag-chip:hover { border-color: var(--accent-dim); color: var(--text-primary); }
.tag-chip.active { background: rgba(132, 169, 140, 0.25); border-color: var(--accent); color: var(--accent); }

/* ===== Star Rating ===== */
.star-rating {
  display: inline-flex;
  gap: 2px;
}

.star-rating .star {
  font-size: 20px;
  cursor: pointer;
  color: var(--border);
  transition: color 0.1s;
  user-select: none;
  line-height: 1;
}

.star-rating .star.filled { color: #d4a854; }
.star-rating .star:hover { color: #d4a854; }

.star-rating-sm {
  display: inline-flex;
  gap: 1px;
  margin-left: 4px;
}

.star-rating-sm .star {
  font-size: 12px;
  color: var(--border);
  line-height: 1;
}

.star-rating-sm .star.filled { color: #d4a854; }

.detail-rating-inline {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.detail-rating-inline .star {
  font-size: 14px;
  color: var(--border);
  line-height: 1;
}

.detail-rating-inline .star.filled { color: #d4a854; }

/* ===== Tags ===== */
.recipe-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.recipe-card-tags .mini-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(132, 169, 140, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid rgba(42, 42, 74, 0.5);
}

/* ===== Organize Section (Detail) ===== */
.detail-organize {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.organize-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.organize-row:last-child { margin-bottom: 0; }

.organize-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.organize-group-full { flex: 1; min-width: 100%; }

.organize-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.organize-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}

.organize-select {
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.organize-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-list .tag-chip { padding-right: 6px; }

.tag-chip-remove {
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-dim);
  margin-left: 2px;
  font-weight: 600;
}

.tag-chip-remove:hover { color: var(--danger); }

.tag-input {
  padding: 4px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  width: 140px;
  transition: border-color 0.15s;
}

.tag-input:focus { border-color: var(--accent); }

/* ===== Multi-select & Bulk Actions ===== */
.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

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

.bulk-action-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-count {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.recipe-card-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--text-dim);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 2;
}

.recipe-card-checkbox:hover { border-color: var(--accent); }

.recipe-card-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.recipe-card-checkbox.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.recipe-card.selected {
  border-color: var(--accent);
  background: rgba(132, 169, 140, 0.08);
}

.recipe-card.has-checkbox { padding-left: 40px; }

/* ===== Error & Loading ===== */
.error-box {
  text-align: center;
  padding: 40px 24px;
  animation: fadeIn 0.3s ease;
}

.error-box p {
  color: var(--danger);
  font-size: 16px;
  margin-bottom: 20px;
}

.loading {
  text-align: center;
  padding: 60px 24px;
}

.loading p {
  color: var(--text-secondary);
  margin-top: 16px;
  font-size: 14px;
}

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

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

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-box {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

.modal-box-lg { width: 520px; }

.modal-box h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.modal-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-row { margin-bottom: 8px; }

.modal-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Slot selector */
.slot-grid { display: flex; gap: 8px; flex-wrap: wrap; }

.slot-btn {
  width: 52px;
  height: 44px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', monospace;
  cursor: pointer;
  transition: all 0.15s;
}

.slot-btn:hover { border-color: var(--accent-dim); color: var(--text-primary); }

.slot-btn.selected {
  border-color: var(--accent);
  background: rgba(132, 169, 140, 0.15);
  color: var(--accent);
}

/* Export success */
.export-success { text-align: center; margin-bottom: 20px; }
.check-icon { color: var(--accent); margin-bottom: 8px; }
.export-success-text { font-size: 15px; font-weight: 500; color: var(--text-primary); }

.export-instructions {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.export-instructions ol { padding-left: 20px; }
.export-instructions li { margin-bottom: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Create Recipe Form ===== */
.create-form { animation: fadeIn 0.3s ease; }

/* Editor layout: 2 columns on desktop */
.create-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}

.create-editor-sticky {
  position: sticky;
  top: 16px;
  align-self: start;
}

.create-editor-controls { min-width: 0; }

/* Category bar: hidden on desktop */
.create-category-bar { display: none; }

/* Beta badge */
.beta-badge {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: var(--radius);
  color: #eab308;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 12px;
}
.beta-badge svg { flex-shrink: 0; stroke: #eab308; margin-top: 1px; }

/* Create photo preview */
.create-photo-preview { margin-bottom: 0; }

.create-photo-empty {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  padding: 24px;
  transition: border-color 0.2s;
}
.create-photo-empty:hover { border-color: var(--accent); }

.create-photo-label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}
.create-photo-label svg { opacity: 0.5; }
.create-photo-hint { font-size: 11px; opacity: 0.6; }

.create-photo-loaded {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.create-photo-wrapper {
  position: relative;
  overflow: hidden;
}

.create-preview-img {
  width: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.3s ease;
}

.create-grain-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.create-photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  padding: 20px 16px 8px;
  pointer-events: none;
}

#create-preview-label {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.create-photo-controls {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

/* Category bar buttons */
.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.cat-btn:hover { color: var(--text-primary); }
.cat-btn.active {
  color: var(--accent);
  background: rgba(132,169,140,0.15);
}
.cat-btn svg { width: 20px; height: 20px; }

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.form-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.form-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-row {
  margin-bottom: 12px;
  flex: 1;
  min-width: 140px;
}

.form-row:last-child { margin-bottom: 0; }

.form-row-inline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row-inline .form-row { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.form-select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Login Screen ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  text-align: center;
  max-width: 360px;
  width: 90%;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-logo { color: var(--accent); margin-bottom: 20px; }

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: center;
  margin-bottom: 12px;
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(132,169,140,0.15);
}

.btn-login {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.btn-login:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-login:active { transform: scale(0.98); }

.login-error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
}

.login-divider {
  margin: 16px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.btn-guest {
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s, transform 0.1s;
}
.btn-guest:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.btn-guest:active { transform: scale(0.98); }

.login-toggle {
  margin-top: 16px;
  font-size: 13px;
}
.login-toggle a {
  color: var(--accent);
  text-decoration: none;
}
.login-toggle a:hover { text-decoration: underline; }

/* ===== Recipe Card Owner (admin) ===== */
.recipe-card-owner {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 4px;
}

/* ===== Settings ===== */
.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.settings-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-avatar-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.settings-avatar-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.settings-field {
  margin-bottom: 14px;
}

.settings-field:last-child { margin-bottom: 0; }

.settings-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.settings-input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.settings-input:focus { border-color: var(--accent); }

.settings-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-field-row .settings-input { flex: 1; }

/* Theme selector */
.theme-selector {
  display: flex;
  gap: 8px;
}

.theme-option {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.theme-option:hover { border-color: var(--accent-dim); color: var(--text-primary); }

.theme-option.active {
  border-color: var(--accent);
  background: rgba(132, 169, 140, 0.15);
  color: var(--accent);
  font-weight: 600;
}

/* Language selector */
.language-selector {
  display: flex;
  gap: 8px;
}

.lang-option {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.lang-option:hover { border-color: var(--accent-dim); color: var(--text-primary); }

.lang-option.active {
  border-color: var(--accent);
  background: rgba(132, 169, 140, 0.15);
  color: var(--accent);
  font-weight: 600;
}

/* ===== Downloads ===== */
.downloads-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.download-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s;
}

.download-card:hover { border-color: var(--accent-dim); }

.download-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.download-card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.download-card-header svg { color: var(--accent); flex-shrink: 0; }

.download-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

.download-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(132, 169, 140, 0.05);
}

.download-link svg { flex-shrink: 0; color: var(--accent); }

/* ===== Manual ===== */
.manual-search-box { flex: 1; max-width: 340px; }

.manual-search-input {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.manual-search-input:focus { border-color: var(--accent); }

.manual-camera-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(132, 169, 140, 0.12);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 4px 14px;
  margin-bottom: 20px;
}

.manual-toc { display: flex; flex-direction: column; gap: 2px; }

.manual-toc-item {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.manual-toc-item:hover {
  border-color: var(--accent-dim);
  background: var(--bg-card);
}

.manual-toc-item::after {
  content: '\203A';
  font-size: 18px;
  color: var(--text-dim);
}

.manual-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.manual-result {
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.manual-result:hover { border-color: var(--accent-dim); }

.manual-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.manual-result-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.search-highlight {
  background: rgba(132, 169, 140, 0.3);
  border-radius: 2px;
  padding: 0 2px;
}

.manual-content { animation: fadeIn 0.3s ease; }

.manual-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 12px;
}

.manual-content p, .manual-content li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.manual-content ul, .manual-content ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.manual-results-count {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.manual-no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 15px;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
}
.lightbox-content {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-close {
  position: absolute;
  top: -36px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 5;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-recipe-label {
  position: absolute;
  top: -36px;
  left: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.9;
}

.lightbox-compare {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox-side {
  position: absolute;
  inset: 0;
}
.lightbox-original {
  z-index: 1;
}
.lightbox-filtered {
  z-index: 2;
  clip-path: inset(0 0 0 50%);
}
.lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.lightbox-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.lightbox-slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: rgba(255,255,255,0.6);
  z-index: 10;
  cursor: ew-resize;
  transform: translateX(-50%);
}
.lightbox-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.lightbox-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 8px 4px 0;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 500;
}

/* ===== Settings Logout ===== */
.settings-logout-section {
  border-top: 1px solid var(--border);
  text-align: center;
}
.settings-logout-section .btn-danger {
  width: 100%;
  max-width: 300px;
  justify-content: center;
}

/* ===== Admin Panel ===== */
.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 12px;
  flex-wrap: wrap;
}
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-email {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-user-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.admin-user-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.admin-role-select {
  font-size: 12px;
  padding: 4px 8px;
}
.admin-role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}
.role-admin { background: var(--accent); color: #fff; }
.role-advanced { background: var(--accent-dim); color: #fff; }
.role-user { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.admin-btn-reset-pw { font-size: 11px !important; }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Non-Fuji Banner ===== */
.non-fuji-banner {
  background: var(--bg-card);
  border: 1px solid var(--accent-dim, var(--border));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
  max-width: 600px;
  box-shadow: var(--shadow-sm);
}
.non-fuji-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ===== Footer ===== */
.app-footer {
  padding: 8px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.footer-sep { margin: 0 6px; }
.footer-link { color: var(--accent); text-decoration: none; }
.footer-link:hover { text-decoration: underline; }

/* ===== Responsive: Tablet / iPad (601px-1024px) ===== */
@media (max-width: 1024px) {
  .app-layout { height: 100vh; height: 100dvh; }

  .sidebar {
    width: 60px;
    padding: 16px 6px;
  }

  .nav-btn span { display: none; }
  .nav-btn .badge { display: none; }
  .nav-btn { justify-content: center; padding: 10px; min-height: 40px; }
  .sidebar-user-info { display: none; }
  .sidebar-user { justify-content: center; }

  .view { max-width: 100%; }
  .columns { grid-template-columns: 1fr; max-width: 100%; }
  .saved-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .downloads-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

  .detail-actions { flex-wrap: wrap; }
  .detail-hero-name { font-size: 18px; }
  .detail-hero-banner { padding: 22px 18px 16px; }
  .read-hero-img-wrap { max-height: 260px; }
  .read-hero-img { max-height: 260px; }
  .read-hero-sim { font-size: 13px; padding: 4px 12px; }

  .drop-zone { padding: 40px 20px; }
  .drop-icon { width: 52px; height: 52px; }

  .btn-primary, .btn-accent, .btn-ghost, .btn-danger { min-height: 40px; }

  .manual-search-box { max-width: 200px; }
  .filter-select { min-width: 120px; }
}

/* Desktop fallback: grid containers transparent */
.cards-grid { display: contents; }
.info-grid { display: block; }

/* ===== Responsive: Mobile (<600px) ===== */
@media (max-width: 600px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }

  .main-content {
    padding: 8px;
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overflow-x: hidden;
    box-sizing: border-box;
    max-width: 100vw;
  }

  .app-footer {
    position: fixed;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    z-index: 49;
    padding: 6px 12px;
    font-size: 10px;
  }

  .titlebar { display: none; }

  .app-layout {
    height: 100vh;
    height: 100dvh;
  }

  .view { max-width: 100%; }

  .columns { grid-template-columns: 1fr; max-width: 100%; padding: 0; gap: 8px; }
  .downloads-grid { grid-template-columns: 1fr; }

  /* ---- Mobile Nav: 6 buttons ---- */
  .mobile-nav {
    padding: 4px 0 env(safe-area-inset-bottom, 4px);
  }
  .mobile-nav-btn {
    padding: 4px 2px;
    font-size: 8px;
    gap: 1px;
  }
  .mobile-nav-btn svg { width: 18px; height: 18px; }

  /* ---- Saved grid: 2 columns square cards ---- */
  .saved-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .recipe-card {
    padding: 10px;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    min-width: 0;
    box-sizing: border-box;
  }
  .recipe-card-name { font-size: 13px; margin-bottom: 4px; word-break: break-word; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .recipe-card-sim { font-size: 11px; margin-bottom: 4px; }
  .recipe-card-author { font-size: 10px; margin-bottom: 2px; }
  .recipe-card-meta { font-size: 9px; gap: 4px; justify-content: center; }
  .recipe-card-badges { display: none; }
  .recipe-card-tags { display: none; }
  .recipe-card-public { top: 6px; right: 6px; width: 8px; height: 8px; }
  /* ---- Create recipe VSCO mobile ---- */
  .create-editor-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 8px;
  }
  .create-editor-sticky {
    position: sticky;
    top: -1px;
    z-index: 10;
    background: var(--bg-primary);
    padding-bottom: 4px;
  }
  .beta-badge { font-size: 11px; padding: 8px 10px; margin-bottom: 8px; }
  .create-photo-empty { padding: 16px; }
  .create-photo-wrapper { max-height: 220px; }
  .create-preview-img { max-height: 220px; }

  /* Category bar visible on mobile */
  .create-category-bar {
    display: flex;
    overflow-x: auto;
    gap: 2px;
    padding: 6px 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .create-category-bar::-webkit-scrollbar { display: none; }
  .cat-btn { padding: 6px 10px; font-size: 9px; }
  .cat-btn svg { width: 18px; height: 18px; }

  /* Mobile: only show active category section */
  .create-editor-controls .form-section[data-category] { display: none; }
  .create-editor-controls .form-section[data-category].active-cat { display: block; }

  .create-editor-controls .form-grid { margin-top: 0; gap: 0; }
  .create-editor-controls .form-section { border-radius: var(--radius); }
  .create-editor-controls .form-actions { margin-top: 12px; }
  .recipe-card.has-checkbox { padding-left: 10px; }
  .recipe-card-checkbox { top: 6px; left: 6px; width: 16px; height: 16px; }

  .saved-header { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 10px; }
  .saved-header h2 { font-size: 17px; }
  .saved-header-actions { width: 100%; flex-wrap: wrap; gap: 4px; overflow: hidden; box-sizing: border-box; }
  .saved-header-actions .btn-accent,
  .saved-header-actions .btn-ghost { flex: 1; justify-content: center; min-width: 0; font-size: 10px; padding: 5px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .saved-detail { width: 100%; right: 0; }
  .organize-inline { flex-direction: column; }

  /* ---- Detail hero compact ---- */
  .detail-hero { margin-bottom: 10px; border-radius: 10px; }
  .detail-hero-banner { padding: 14px 12px 12px; }
  .detail-hero-sim { font-size: 10px; padding: 3px 8px; margin-bottom: 6px; }
  .detail-hero-name { font-size: 16px; margin-bottom: 4px; word-break: break-word; white-space: normal; }
  .detail-hero-meta { font-size: 10px; gap: 8px; }
  .detail-hero-actions { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .detail-hero-actions .btn-ghost { font-size: 11px; min-height: 36px; padding: 4px 10px; }
  .detail-actions { width: 100%; }
  .detail-actions button { flex: 1; justify-content: center; font-size: 11px; min-height: 36px; padding: 4px 8px; }

  /* ---- Read hero compact ---- */
  .read-hero { margin-bottom: 10px; border-radius: 10px; }
  .read-hero-img-wrap { max-height: 180px; }
  .read-hero-img { max-height: 180px; }
  .read-hero-overlay { padding: 20px 10px 8px; }
  .read-hero-sim { font-size: 11px; padding: 3px 8px; }
  .read-hero-file { font-size: 9px; max-width: 100px; }
  .read-hero-actions { padding: 8px 10px; gap: 6px; }
  .read-hero-actions button { min-height: 36px; font-size: 11px; padding: 4px 10px; flex: 1; }

  /* ---- Recipe params compact ---- */
  .recipe-params-row { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .recipe-param { padding: 5px 6px; }
  .recipe-param .card-label { font-size: 8px; margin-bottom: 2px; }
  .recipe-param .card-value { font-size: 11px; }

  .card-visual { padding: 6px 8px; gap: 8px; margin-bottom: 4px; }
  .card-visual-icon { width: 24px; height: 24px; font-size: 12px; border-radius: 5px; }
  .card-visual-body .card-label { font-size: 8px; }
  .card-visual-body .card-value { font-size: 12px; }

  /* ---- Card grids compact ---- */
  .cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
  .card { padding: 6px 8px; margin-bottom: 0; }
  .card-label { font-size: 8px; margin-bottom: 2px; }
  .card-value { font-size: 11px; word-break: break-word; }
  .card-row { gap: 8px; }
  .sub-label { font-size: 8px; }
  .sub-value { font-size: 11px; }
  .column-title { font-size: 11px; margin-bottom: 6px; padding-bottom: 4px; }

  /* ---- Camera grid compact ---- */
  .camera-grid { grid-template-columns: 1fr 1fr; gap: 3px; }
  .camera-stat { padding: 5px 6px; }
  .camera-stat-label { font-size: 8px; margin-bottom: 2px; }
  .camera-stat-value { font-size: 11px; word-break: break-word; }

  /* ---- Legacy info grid ---- */
  .info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
  .info-row { padding: 3px 0; font-size: 11px; }
  .info-label { font-size: 11px; }
  .info-value { font-size: 11px; }

  .non-fuji-banner { padding: 10px; margin-bottom: 8px; }

  /* ---- Drop zone compact ---- */
  .drop-zone { padding: 20px 12px; }
  .drop-icon { width: 40px; height: 40px; }
  .drop-text { font-size: 14px; }
  .drop-subtext { font-size: 11px; }

  /* ---- Filter bar stacked ---- */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 6px; }
  .filter-select { width: 100%; min-width: 0; }

  .bulk-action-bar { flex-direction: column; }
  .bulk-action-left, .bulk-action-right { width: 100%; }
  .bulk-action-right { flex-wrap: wrap; }
  .bulk-action-right button { flex: 1; }

  /* ---- Modal bottom-sheet ---- */
  .modal { align-items: flex-end; }
  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    min-height: auto;
    max-height: 85vh;
    max-height: 85dvh;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .theme-selector, .language-selector { flex-direction: column; }

  .settings-section { padding: 14px; }
  .settings-avatar-row { flex-direction: column; text-align: center; }
  .settings-field-row { flex-direction: column; }
  .settings-field-row .btn-accent { width: 100%; justify-content: center; }

  .manual-search-box { max-width: 100%; width: 100%; }
  .manual-search-input { width: 100%; }

  .form-row-inline { flex-direction: column; gap: 8px; }

  .organize-row { flex-direction: column; gap: 10px; }

  /* ---- Touch targets iOS ---- */
  .btn-accent, .btn-ghost, .btn-danger, .btn-primary {
    min-height: 44px;
  }

  /* ---- Overflow prevention ---- */
  * { max-width: 100%; }
  img, svg, video { max-width: 100%; height: auto; }

  .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

  .lightbox-content { width: 96vw; }
  .lightbox-close { top: -30px; font-size: 24px; }
  .lightbox-recipe-label { top: -30px; font-size: 12px; }
  .lightbox-slider-handle { width: 30px; height: 30px; }
}

/* ===== Responsive: Mobile Landscape ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .mobile-nav { padding: 2px 0; }
  .mobile-nav-btn span { display: none; }
  .mobile-nav-btn { padding: 4px 2px; }
  .mobile-nav-btn svg { width: 18px; height: 18px; }

  .read-hero-img-wrap { max-height: 120px; }
  .read-hero-img { max-height: 120px; }
  .detail-hero-banner { padding: 10px 12px 8px; }
  .detail-hero-name { font-size: 15px; }
  .drop-zone { padding: 16px 12px; }
  .drop-icon { width: 32px; height: 32px; }
  .drop-text { font-size: 13px; }

  .main-content { padding-bottom: 60px; }
  .app-footer { bottom: 36px; }
}
