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

:root {
  --bg: #111111;
  --surface: #1c1c1e;
  --surface2: #2a2a2c;
  --surface3: #313135;
  --border: rgba(255,255,255,0.08);
  --text: #f2f2f7;
  --text2: #8e8e93;
  --text3: #48484a;
  --accent: #e63946;
  --accent-bg: rgba(230,57,70,0.12);
  --danger: #ff453a;
  --success: #30d158;
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 54px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --sugg-bg: #252528;
}

/* ── Light theme ────────────────────────────────────── */
html.light-theme {
  --bg:      #f2f2f7;
  --surface: #ffffff;
  --surface2: #f2f2f7;
  --surface3: #e5e5ea;
  --border:  rgba(0,0,0,0.12);
  --text:    #1c1c1e;
  --text2:   #6c6c70;
  --text3:   #aeaeb2;
  --danger:  #ff3b30;
  --success: #34c759;
  --sugg-bg: #e5e5ea;
}
html.light-theme .sug-chip { border-color: rgba(0,0,0,0.1); }
html.light-theme .sug-chip.prev-chip { border-color: rgba(0,0,0,0.08); }
html.light-theme .sug-divider { background: rgba(0,0,0,0.1); }
html.light-theme .color-preview-swatch { border-color: rgba(0,0,0,0.15); }
html.light-theme .btn-circle { border-color: var(--accent); }
html.light-theme .btn-outlined { border-color: var(--accent); }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  overflow: hidden;
}

/* ── Page Layout ────────────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.page-header .header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-header .header-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
  display: block;
}

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

.page-content.no-pad {
  padding: 0;
}

/* ── Accent color for camera pages ─────────────────── */
.page[data-accent] .accent-text { color: var(--accent); }
.page[data-accent] .accent-bg { background: var(--accent); }
.page[data-accent] .accent-border { border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { opacity: 0.7; transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-sm);
}

/* Outlined variant — adds a visible border (white in dark, accent in light) */
.btn-outlined {
  border: 1.5px solid rgba(255,255,255,0.25);
  padding: 8px 10px;
}
.btn-icon {
  background: transparent;
  color: var(--text2);
  padding: 8px;
  border-radius: 50%;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:active { background: var(--surface2); }


.btn-back {
  background: transparent;
  color: var(--accent);
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  -webkit-user-select: none;
}
.btn-back:active { opacity: 0.6; }
.btn-back svg { width: 18px; height: 18px; }

/* Circle icon button (theme toggle, production menu dots) */
.btn-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.btn-circle:active { opacity: 0.6; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s, opacity 0.15s;
  z-index: 10;
  -webkit-user-select: none;
}
.fab:active { transform: scale(0.93); opacity: 0.85; }

/* ── Forms ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}

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

.field-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field-input:focus {
  border-color: var(--accent);
  background: var(--surface3);
}
.field-input::placeholder {
  color: var(--text3);
}

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

/* Section headers in forms */
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 20px 0 8px;
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.card:active { opacity: 0.8; }

/* Project card */
.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-user-select: none;
}
.project-card:active { opacity: 0.75; }

.project-card-info { flex: 1; min-width: 0; }
.project-card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-card-meta {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.project-card-dot { color: var(--text3); }

.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mode-badge.digital { background: rgba(0,122,255,0.15); color: #0a84ff; }
.mode-badge.film    { background: rgba(255,149,0,0.15); color: #ff9500; }
.mode-badge.hybrid  { background: rgba(175,82,222,0.15); color: #af52de; }

.pro-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,214,10,0.18);
  color: #b8860b;
}
.light-theme .pro-badge { color: #8a6500; }

.member-role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: capitalize;
  letter-spacing: 0.03em;
  background: var(--surface2);
  color: var(--text2);
}

/* Pro upgrade row in settings modal */
.pro-upgrade-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.pro-upgrade-info { flex: 1; }
.pro-upgrade-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.pro-upgrade-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}
.pro-upgrade-btn { white-space: nowrap; flex-shrink: 0; }

/* Pro active indicator in settings modal */
.pro-active-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #b8860b;
  margin-bottom: 16px;
}
.light-theme .pro-active-row { color: #8a6500; }

.card-chevron {
  color: var(--text3);
  font-size: 18px;
}

/* Camera card */
.camera-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
}
.camera-card:active { opacity: 0.75; }

.camera-color-strip {
  width: 6px;
  flex-shrink: 0;
}
.camera-card-body {
  flex: 1;
  padding: 14px 16px;
}
.camera-card-letter {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.camera-card-model {
  font-size: 14px;
  color: var(--text2);
}
.camera-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0 4px 0 0;
  gap: 2px;
  flex-shrink: 0;
  text-align: right;
}
.cam-stat-roll {
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 150ms ease;
}
.cam-stat-count {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 150ms ease;
}
.cam-stat-roll.loaded,
.cam-stat-count.loaded {
  opacity: 1;
}
.camera-menu-btn {
  margin: 0 10px;
  flex-shrink: 0;
  align-self: center;
}
.cam-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
}
.cam-type-badge--film    { background: rgba(255,149,0,0.15);  color: #ff9500; }
.cam-type-badge--digital { background: rgba(0,122,255,0.15);  color: #0a84ff; }

/* Camera card overflow dropdown */
.camera-menu-dropdown {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 1000;
  overflow: hidden;
  min-width: 150px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
}
.camera-menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.camera-menu-dropdown button:active { opacity: 0.6; }
.camera-menu-dropdown button.danger { color: var(--danger); }
.camera-menu-dropdown button + button { border-top: 1px solid var(--border); }

/* ── Roll Dividers (Scene List) ─────────────────────── */
.roll-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 6px;
  margin-top: 16px;
  border-bottom: 1px solid var(--border);
}
.roll-divider:first-child { margin-top: 0; }

.roll-divider-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.roll-divider-date {
  font-size: 12px;
  color: var(--text2);
}

/* ── Scene List Cards ───────────────────────────────── */
.scene-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-left: 4px solid var(--accent);
  transition: opacity 0.15s;
}
.scene-card:active { opacity: 0.75; }
.scene-card.press-active { opacity: 0.6; }
.scene-card.dragging {
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  transform: scale(1.02);
  opacity: 0.96;
  transition: none;
}
.scene-card-placeholder {
  border-radius: var(--radius);
  background: var(--surface2);
  border: 2px dashed var(--border);
  flex-shrink: 0;
}
.scene-drag-handle {
  touch-action: none;
  color: var(--text3);
  padding: 4px 0 4px 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.scene-drag-handle:active { cursor: grabbing; }

.scene-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 6px;
}
.scene-card-number {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.scene-card-number span {
  color: var(--accent);
}
.scene-card-date {
  font-size: 12px;
  color: var(--text2);
}

.scene-card-fields {
  padding: 0 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.scene-field-row {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.scene-field-row .sf-val {
  color: var(--text);
}
.scene-field-row .sf-labeled {
  color: var(--text2);
}
.scene-field-row .sf-labeled strong {
  color: var(--text);
  font-weight: 500;
}
.scene-field-sep {
  color: var(--text3);
}

.scene-card-takes {
  padding: 4px 14px 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scene-take-row {
  font-size: 13px;
  color: var(--text2);
  padding: 1px 0;
}
.scene-take-row strong {
  color: var(--text);
  font-weight: 500;
}
.scene-take-row.is-circled strong {
  border: 1.5px solid var(--accent);
  border-radius: 9px;
  padding: 1px 6px;
  margin-left: -6px;
  display: inline-block;
}

.scene-card-body {
  display: flex;
  align-items: flex-start;
}

.scene-card-main {
  flex: 1;
  min-width: 0;
}

.scene-card-desc {
  width: 38%;
  flex-shrink: 0;
  padding: 4px 14px 10px 4px;
  font-size: 12px;
  color: var(--text2);
  font-style: italic;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ── Takes Widget (Log Note) ────────────────────────── */
.takes-widget {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.take-row-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.take-row-wrap:last-child { border-bottom: none; }

.take-delete-hint {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 90px;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.take-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  background: var(--bg);
  position: relative;
  touch-action: pan-y;
}

.take-swipe-hint {
  color: var(--text3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.5;
  -webkit-user-select: none;
  user-select: none;
}

.take-num {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  min-width: 32px;
  flex-shrink: 0;
}

.take-label-edit {
  flex: 1;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  min-width: 0;
}
.take-label-edit:empty::before {
  content: attr(data-placeholder);
  color: var(--text3);
}

.take-undo-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--surface);
  border-radius: 100px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  transition: transform 0.25s ease;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.take-undo-toast.visible {
  transform: translateX(-50%) translateY(0);
}
.take-undo-toast .toast-undo-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.add-take-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  -webkit-user-select: none;
}
.add-take-btn:active { opacity: 0.7; }

/* ── Takes Mode Toggle ──────────────────────────────── */
.takes-mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.takes-mode-bar .add-take-btn {
  flex: 1;
  margin-top: 0;
  width: auto;
}

.takes-mode-toggle {
  display: flex;
  background: var(--surface3);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.take-mode-btn {
  background: transparent;
  border: none;
  border-radius: 17px;
  padding: 8px 14px;
  color: var(--text2);
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-user-select: none;
}

.take-mode-btn.active {
  background: rgba(255,255,255,0.14);
  color: var(--text);
}

/* ── Circle Mode Takes Grid ─────────────────────────── */
.takes-circle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
}

.take-circle-btn {
  min-width: 48px;
  height: 48px;
  padding: 0 14px;
  border-radius: 24px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  -webkit-user-select: none;
  transition: border-color 0.15s, color 0.15s;
}

.take-circle-btn.circled {
  border-color: var(--accent);
  color: var(--accent);
}

.take-circle-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}

/* Circled indicator in edit mode — oval around the take number */
.take-num.is-circled {
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 2px 7px;
  margin-left: -7px;
}

/* ── Roll field with reload ─────────────────────────── */
.roll-reload-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 20px;
  padding: 0 14px;
  cursor: pointer;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-user-select: none;
}
.roll-reload-btn:active { opacity: 0.7; }

/* ── Color Picker ───────────────────────────────────── */
.color-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.color-spectrum {
  width: 100%;
  height: 36px;
  border-radius: 18px;
  background: linear-gradient(to right,
    hsl(0,70%,55%), hsl(30,70%,55%), hsl(60,70%,55%),
    hsl(90,70%,55%), hsl(120,70%,55%), hsl(150,70%,55%),
    hsl(180,70%,55%), hsl(210,70%,55%), hsl(240,70%,55%),
    hsl(270,70%,55%), hsl(300,70%,55%), hsl(330,70%,55%),
    hsl(360,70%,55%)
  );
  cursor: pointer;
  position: relative;
  touch-action: none;
}
.color-spectrum-thumb {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.05s;
}
.color-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-preview-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.color-preview-hex {
  font-size: 14px;
  color: var(--text2);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ── Modals ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--text3);
  border-radius: 2px;
  margin: 0 auto 20px;
  touch-action: none;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; padding: 14px; font-size: 16px; }

/* Mode selector */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.mode-option {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s;
  -webkit-user-select: none;
}
.mode-option.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.mode-option-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.mode-option-desc {
  font-size: 12px;
  color: var(--text2);
}

/* Field checklist */
.field-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-user-select: none;
}
.field-check-item.locked {
  opacity: 0.5;
  cursor: default;
}
.field-check-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.field-check-item label {
  font-size: 15px;
  color: var(--text);
  flex: 1;
  cursor: pointer;
}
.field-check-item.locked label { cursor: default; }

/* ── Suggestion / Preset Bar ────────────────────────── */
.suggestion-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;       /* default — JS overrides with top: once keyboard height is known */
  top: auto;
  background: var(--sugg-bg);
  border-top: 1px solid var(--border);
  z-index: 200;
  height: 52px;
  display: flex;
  align-items: stretch;
  touch-action: none;
  /* Prevent iOS from shifting this element during keyboard animation */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: top;
}
.suggestion-bar.hidden { display: none; }
.suggestion-bar.two-row { height: 96px; }

.sug-inner {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  scrollbar-width: none;
}
.sug-inner::-webkit-scrollbar { display: none; }

.sug-chip {
  height: 36px;
  padding: 0 15px;
  background: var(--surface3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  -webkit-user-select: none;
  user-select: none;
}
.sug-chip.type-chip {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-bg);
}
.sug-chip.prev-chip {
  background: transparent;
  color: var(--text2);
  border-color: rgba(255,255,255,0.08);
}
.sug-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
  align-self: center;
}
.sug-two-row {
  flex-direction: column;
  align-items: stretch;
  overflow-x: hidden;
  gap: 0;
  padding: 0;
}
.sug-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
}
.sug-row::-webkit-scrollbar { display: none; }
.sug-row + .sug-row { border-top: 1px solid var(--border); }

/* ── Log Note Page ──────────────────────────────────── */
.log-note-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Log Note Tile Layout ────────────────────────────── */
.ln-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ln-row {
  display: flex;
  gap: 8px;
}

.ln-tile {
  flex: 1;
  min-height: 66px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.1s;
}
.ln-tile:active { background: var(--surface2); }

.ln-tile-always {
  cursor: default;
  min-height: 68px;
}
.ln-tile-always:active { background: var(--surface); }

.ln-tile-full {
  min-height: 76px;
}

.ln-tile-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1.2;
}

/* Value display (inactive state) */
.ln-tile-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
  min-height: 24px;
}
.ln-tile-full .ln-tile-val {
  font-size: 17px;
  font-weight: 400;
  min-height: 22px;
}
/* Ghost placeholder from prev scene value when tile is empty */
.ln-tile-val:empty::after {
  content: attr(data-ghost);
  color: var(--text3);
  font-weight: 400;
}
/* Tilt ghost is too wide for a 4-col tile — shrink it to fit on one line */
[data-field-id="tilt"] .ln-tile-val:empty::after {
  font-size: 11px;
}

/* Input (hidden by default, shown when active) */
.ln-tile-input {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  width: 100%;
  padding: 0;
  margin: 0;
  display: none;
  -webkit-appearance: none;
  appearance: none;
  min-height: 24px;
}
.ln-tile-full .ln-tile-input {
  font-size: 17px;
  font-weight: 400;
  resize: none;
  overflow: hidden;
  min-height: 22px;
}
.ln-tile-input::placeholder { color: var(--text3); font-weight: 400; }

/* Active state: show input, hide val */
.ln-tile.active .ln-tile-val   { display: none; }
.ln-tile.active .ln-tile-input { display: block; }

/* Always-on tiles: input always visible */
.ln-tile-always .ln-tile-val   { display: none !important; }
.ln-tile-always .ln-tile-input { display: block; }

/* Always-on body: input + action button side by side */
.ln-tile-always-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.ln-tile-always-body .ln-tile-input {
  flex: 1;
  font-size: 19px;
  min-height: 0;
}

/* Small action buttons inside tiles (↑ ↻ Cal ⊕) */
.ln-tile-action-btn {
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  color: var(--accent);
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  font-weight: 500;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.ln-tile-action-btn:active { opacity: 0.65; }

/* Filters tile: reduce font when 3+ items (2+ commas) to limit vertical expansion */
.ln-tile-filters-long .ln-tile-val,
.ln-tile-filters-long .ln-tile-input { font-size: 15px; }

/* Long values (zoom lenses, format names, etc.) — shrink to reduce wrapping */
.ln-tile-val-compact .ln-tile-val,
.ln-tile-val-compact .ln-tile-input { font-size: 15px; }

.ln-tile-val-long .ln-tile-val,
.ln-tile-val-long .ln-tile-input    { font-size: 13px; }

/* 4-col rows: smaller value font so values like 1280EI don't wrap */
.ln-row-4col .ln-tile-val,
.ln-row-4col .ln-tile-input { font-size: 17px; min-height: 20px; }
.ln-row-4col .ln-tile { min-height: 60px; }

/* 4-col tiles are ~63px wide — compact/long must shrink further than in wider rows */
.ln-row-4col .ln-tile-val-compact .ln-tile-val,
.ln-row-4col .ln-tile-val-compact .ln-tile-input { font-size: 13px; }

.ln-row-4col .ln-tile-val-long .ln-tile-val,
.ln-row-4col .ln-tile-val-long .ln-tile-input    { font-size: 11px; }

/* Tilt Cal/⊕ buttons — only visible when tile is active */
.ln-tile-tilt-btns {
  display: none;
  gap: 6px;
}
.ln-tile.active .ln-tile-tilt-btns { display: flex; }
.ln-tile-tilt-btns .ln-tile-action-btn {
  font-size: 14px;
  width: auto;
  padding: 0 14px;
  height: 32px;
}

/* ── Tilt Floating Panel ─────────────────────────────── */
.tilt-panel {
  position: fixed;
  z-index: 400;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
}

.tilt-panel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.tilt-panel-input {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  width: 100%;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
.tilt-panel-input::placeholder { color: var(--text3); font-weight: 400; font-size: 17px; }

.tilt-panel-btns {
  display: flex;
  gap: 8px;
}

.tilt-panel-btn {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface3);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.tilt-panel-btn:active { opacity: 0.7; }

.tilt-panel-capture-btn {
  background: var(--accent);
  color: #fff;
}

/* ── Log Note Takes Section ──────────────────────────── */
.ln-takes-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ln-takes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ln-takes-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

.log-note-camera-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.log-note-camera-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.log-note-camera-name {
  font-size: 14px;
  color: var(--text2);
}

/* ── Productions header ─────────────────────────────── */
.app-wordmark {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.app-wordmark span { color: var(--accent); }

/* ── Camera header bar ──────────────────────────────── */
.camera-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.camera-header-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.camera-header-letter {
  font-size: 18px;
  font-weight: 700;
}
.camera-header-model {
  font-size: 13px;
  color: var(--text2);
}

/* ── Empty state ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  text-align: center;
}
.empty-state-icon {
  font-size: 48px;
  opacity: 0.3;
}
.empty-state-icon svg { display: block; }
.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text2);
}
.empty-state-desc {
  font-size: 14px;
  color: var(--text3);
  max-width: 240px;
}

/* ── Delete confirm overlay ─────────────────────────── */
.delete-confirm {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.delete-confirm-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.delete-confirm-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}
.delete-confirm-msg {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 20px;
}
.delete-confirm-actions {
  display: flex;
  gap: 10px;
}
.delete-confirm-actions .btn { flex: 1; }

/* ── Export modal options ───────────────────────────── */
.export-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 10px;
  -webkit-user-select: none;
}
.export-option:active { opacity: 0.75; }
.export-option-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text2);
}
.export-option-info { flex: 1; }
.export-option-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.export-option-desc {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

/* ── Custom Export Selection UI ─────────────────────── */
.ce-content {
  padding-top: 8px;
  padding-bottom: 16px;
}

.ce-day-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-user-select: none;
}
.ce-day-row:active { opacity: 0.7; }

.ce-day-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.ce-cam-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0 13px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-user-select: none;
}
.ce-cam-row:active { opacity: 0.7; }

.ce-cam-label {
  font-size: 15px;
  font-weight: 600;
}

.ce-roll-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0 12px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-user-select: none;
}
.ce-roll-row:active { opacity: 0.7; }

.ce-roll-label {
  font-size: 15px;
  font-weight: 500;
}

.ce-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ce-dash {
  width: 10px;
  height: 2px;
  border-radius: 1px;
}

.ce-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.ce-export-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.ce-export-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Scrollbar (desktop) ─────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 2px; }

/* ── Utilities ──────────────────────────────────────── */
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text2); }

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

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-container {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-logo {
  text-align: center;
  margin-bottom: 20px;
}
.login-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  margin-bottom: 4px;
}
.login-tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.login-tab.selected {
  background: var(--surface3);
  color: var(--text);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

/* ── Offline / sync badge ───────────────────────────── */
.offline-badge {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 16px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--surface3);
  color: var(--text2);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
.offline-badge.hidden { display: none; }
body.no-badge .offline-badge { display: none !important; }

/* ── App Toast ───────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  background: #e63946;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.app-toast--hidden { opacity: 0; }

/* ── Scene Search ────────────────────────────────────── */

/* Mobile: Back and title hidden so search input fills the header */
.search-mode-header .search-back  { display: none; }
.search-mode-header .search-title { display: none; }
.search-mode-header .scene-search-input-wrap { flex: 1; }

/* Desktop: Back and title stay visible; search input is ~20% of window width */
@media (min-width: 600px) {
  .search-mode-header .search-back  { display: flex; }
  .search-mode-header .search-title { display: block; flex: 1; }
  .search-mode-header .scene-search-input-wrap {
    flex: none;
    width: 20vw;
    min-width: 160px;
  }
}

.scene-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 36px;
}
.scene-search-input-wrap svg { color: var(--text2); flex-shrink: 0; }
.scene-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.scene-search-input::placeholder { color: var(--text3); }
.scene-search-input::-webkit-search-cancel-button { display: none; }
.scene-search-clear {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.scene-search-clear:active { opacity: 0.6; }
.scene-search-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.scene-search-tab {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  -webkit-user-select: none;
  transition: color 0.15s, border-color 0.15s;
}
.scene-search-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.search-mode-header .btn-ghost { font-size: 14px; font-weight: 500; }

/* ── Log Note Header Actions ─────────────────────────── */
.log-hdr-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 60px;
  justify-content: flex-end;
}

.log-hdr-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 6px;
  border: none;
}

.log-hdr-btn.active {
  color: var(--accent);
}

/* × remove button for custom preset list items in field settings */
.take-delete-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  -webkit-user-select: none;
}
.take-delete-btn:active { opacity: 0.6; }

/* ── Clip / dial number on scene card takes ──────────── */
.take-clip {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text3);
  margin: 0 6px;
}
.take-row-label { color: var(--text2); }

/* ── Camera type toggle (Digital / Film) ─────────────── */
.cam-type-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cam-type-btn {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cam-type-btn + .cam-type-btn {
  border-left: 1px solid var(--border);
}
.cam-type-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Dial input + diff in take rows ──────────────────── */
.take-item-film .take-label-edit {
  flex: 1;
}
.take-dial-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.take-dial-input {
  width: 60px;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
  text-align: center;
  outline: none;
}
.take-dial-input:focus {
  border-color: var(--accent);
}
.take-dial-diff {
  min-width: 32px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text3);
  text-align: right;
}
