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

:root {
  --bg:        #0e0e14;
  --surface:   #16161f;
  --surface2:  #1e1e2a;
  --border:    rgba(255,255,255,0.07);
  --text:      #e8e8f0;
  --muted:     rgba(255,255,255,0.38);
  --accent:    #00e054;
  --accent2:   #40bcf4;
  --danger:    #ff5580;
  --radius:    10px;
  --sidebar-w: 320px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}

/* ── Layout ───────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100dvh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* The sidebar logo bar and the preview header share one height so their
   bottom borders line up across the window. */
:root { --topbar-h: 58px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-icon {
  font-size: 18px;
  color: var(--accent);
}
.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ── Intro ───────────────────────────────────────────────── */
.intro {
  padding: 16px 20px 4px;
}
.intro-lede {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 900;
  font-size: 20px;
  line-height: 1.25;
  color: var(--text);
}

/* ── Panels ───────────────────────────────────────────────── */
.panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
/* The movie list keeps its own min/max height (see .movie-list), so the
   panel no longer needs to stretch; the sidebar simply scrolls. */
.panel-movies { flex-shrink: 0; }
.panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
/* Each step is a <details>; its title and subheader form the clickable
   <summary>, so a folded step still says what it's for. */
.panel-summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding-right: 24px;
}
.panel-summary::-webkit-details-marker { display: none; }
.panel-summary::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.panel:not([open]) > .panel-summary::after { transform: rotate(-45deg); top: 5px; }
.panel-summary:hover::after { border-color: var(--text); }
.panel:not([open]) > .panel-summary .pane-intro { margin-bottom: 0; }

.panel-title .step-num {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  letter-spacing: 0;
  vertical-align: 1px;
}
.pane-intro {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255,255,255,0.6);
  margin: -4px 0 10px;
}
.pane-intro a { color: var(--accent); }
.pane-intro code {
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface2);
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.movie-count {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  margin-left: 4px;
}
.panel-movies .panel-title-row { margin-bottom: 4px; }
.panel-movies .panel-title-row .field-label { margin-bottom: 0; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: rgba(255,255,255,0.7);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.sort-btn:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }
.sort-arrow { font-size: 12px; color: var(--accent); }

.list-legend {
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 8px;
}
.legend-dot { color: var(--text); }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-row {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.tab-btn {
  flex: 1;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Drop zone ───────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0,224,84,0.05);
}
.drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-zone p { font-size: 12px; margin: 4px 0; }
.drop-hint { font-size: 11px; color: var(--muted); margin-top: 6px !important; }

/* ── Form fields ─────────────────────────────────────────── */
.field-group { margin-bottom: 12px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}
.field-hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.muted { color: var(--muted); }

.text-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: rgba(255,255,255,0.2); }
.text-input::placeholder { color: var(--muted); }

select.text-input { cursor: pointer; }

.input-row {
  display: flex;
  gap: 6px;
}
.input-row .text-input { flex: 1; }

.input-with-prefix {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.input-prefix {
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}
.input-with-prefix:focus-within { border-color: rgba(255,255,255,0.2); }
.input-with-prefix .text-input {
  border: none;
  background: transparent;
  padding-left: 2px;
}
.input-row .input-with-prefix { flex: 1; min-width: 0; }

/* ── Date range picker ───────────────────────────────────── */
.date-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.date-trigger:hover { border-color: rgba(255,255,255,0.2); }
.date-trigger .date-icon { color: var(--accent); flex-shrink: 0; }
.date-trigger #date-label { flex: 1; }
.date-trigger .date-caret { color: var(--muted); flex-shrink: 0; }

.date-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.date-popover:popover-open { display: flex; flex-direction: column; }
.date-popover::backdrop { background: transparent; }
.date-pop-body { display: flex; min-height: 0; }
.date-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.date-pop-foot .field-hint { margin: 0; }

.date-presets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  min-width: 150px;
  max-height: 340px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.date-presets .preset-group {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 8px 4px;
}
.date-presets .preset-group:first-child { padding-top: 2px; }
.preset-btn {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(255,255,255,0.8);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}
.preset-btn:hover { background: var(--surface2); color: var(--text); }
.preset-btn.active { background: rgba(0,224,84,0.12); color: var(--accent); }
.preset-btn .preset-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.date-cal-wrap { padding: 12px 14px 10px; }
.input-row .date-trigger { flex: 1; min-width: 0; }

/* Narrow windows: quick picks above the calendar, both full width */
@media (max-width: 600px) {
  .date-popover:popover-open {
    width: calc(100vw - 16px);
    max-width: none;
  }
  .date-pop-body { flex-direction: column; }
  .date-presets {
    flex-direction: row;
    flex-wrap: wrap;
    /* Tall enough for the quick picks and several months without
       scrolling; only a long CSV history scrolls here. */
    max-height: 45dvh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .date-presets .preset-group { width: 100%; }
  .date-cal-wrap { padding: 10px 8px 6px; }
  calendar-range { display: block; width: 100%; }
  calendar-range::part(header) { width: 100%; justify-content: space-between; }
  /* "calendar-range calendar-month" outranks the base 32px day rule below */
  calendar-range calendar-month { display: block; width: 100%; }
  calendar-range calendar-month::part(table) { width: 100%; table-layout: fixed; }
  calendar-range calendar-month::part(button) { width: 100%; }
}

/* ── Header font dropdown (customizable select) ──────────── */
.font-select,
.font-select::picker(select) { appearance: base-select; }
.font-select { display: flex; align-items: center; }
.font-select::picker-icon { color: var(--muted); }
.font-select::picker(select) {
  margin-top: 4px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.font-select option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
}
.font-select option::checkmark { display: none; }
.font-select option:hover,
.font-select option:focus-visible { background: var(--surface2); outline: none; }
.font-select option:checked { background: rgba(0,224,84,0.12); }
.font-select .font-sample { font-size: 17px; line-height: 1.2; }
.font-select .font-note { font-size: 10px; color: var(--muted); }
.font-select selectedcontent .font-note { display: none; }

calendar-range {
  --color-accent: var(--accent);
  --color-text-on-accent: #000;
}
calendar-range svg { color: var(--text); }
calendar-range::part(button) {
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 8px;
}
calendar-range::part(button):hover { background: var(--surface2); }
calendar-range::part(heading) { font-weight: 600; font-size: 13px; }
calendar-month::part(th) { color: var(--muted); font-size: 10px; font-weight: 500; }
calendar-month::part(button) {
  width: 32px;
  height: 30px;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}
calendar-month::part(button):hover { background: var(--surface2); }
calendar-month::part(today) { outline: 1px solid rgba(255,255,255,0.3); outline-offset: -1px; }
calendar-month::part(outside) { color: rgba(255,255,255,0.2); }
calendar-month::part(range-inner) {
  border-radius: 0;
  background: rgba(0,224,84,0.16);
  color: var(--text);
}
calendar-month::part(range-start),
calendar-month::part(range-end) {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}
calendar-month::part(range-start) { border-start-end-radius: 0; border-end-end-radius: 0; }
calendar-month::part(range-end)   { border-start-start-radius: 0; border-end-start-radius: 0; }
calendar-month::part(range-start range-end) { border-radius: 6px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Radio & Checkbox ────────────────────────────────────── */
.radio-row {
  display: flex;
  gap: 16px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  cursor: pointer;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 6px;
  color: rgba(255,255,255,0.7);
}
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }

.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Background swatches ─────────────────────────────────── */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.bg-swatch {
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
  aspect-ratio: 9/16;
}
.bg-swatch:hover { transform: scale(1.05); }
.bg-swatch.active { border-color: var(--accent); }

.bg-preview {
  width: 100%;
  height: 100%;
}
.bg-preview.dark-gradient { background: linear-gradient(160deg,#0d0d1f,#1a1030); }
.bg-preview.midnight { background: linear-gradient(160deg,#0a0f2e,#162060); }
.bg-preview.velvet { background: linear-gradient(160deg,#1a0028,#2d0044); }
.bg-preview.warm-dark { background: linear-gradient(160deg,#1a0a00,#2a1200); }
.bg-preview.noir { background: #0a0a0a; }
.bg-preview.bokeh {
  background: #0d0d1f;
  box-shadow: inset 0 0 20px rgba(80,80,255,0.25), inset 10px 10px 30px rgba(200,0,150,0.15);
}
.bg-preview.geometric {
  background: #0d1117;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 12px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 12px);
}
.bg-preview.forest { background: linear-gradient(160deg,#061a0c,#0e2a14); }

/* ── Movie list ───────────────────────────────────────────── */
.movie-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
  min-height: 200px;
  max-height: 240px;
}
.empty-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 20px 0;
  line-height: 1.5;
}

.movie-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  user-select: none;
}
.movie-item:last-child { border-bottom: none; }
.movie-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }

.movie-item .heart-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 2px;
  line-height: 1;
  width: 20px;          /* ♥ and ♡ differ in width; keep titles aligned */
  text-align: center;
  transition: color 0.15s, transform 0.1s;
}
.movie-item .heart-btn.liked {
  color: var(--danger);
}
.movie-item .heart-btn:hover { transform: scale(1.2); }

.venue-btn {
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 2px;
  line-height: 1;
  width: 20px;
  text-align: center;
  transition: transform 0.1s, opacity 0.15s;
}
.venue-btn.unset { color: var(--text); opacity: 0.75; font-size: 16px; }
.venue-btn:hover { transform: scale(1.2); opacity: 1; }

.movie-info { flex: 1; min-width: 0; }
.movie-title-text {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,0.85);
}
.movie-meta-text {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}
.movie-star { color: #ffd700; }
.rewatch-badge {
  font-size: 9px;
  background: rgba(64,188,244,0.15);
  color: var(--accent2);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.08); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: #00f05e; }
.btn-secondary {
  background: transparent;
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
}
.btn-secondary:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }

.sidebar-actions {
  padding: 14px 20px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-actions .btn { text-align: center; }
.sidebar-actions #export-all-btn { flex: 1; }

/* Page nav */
.page-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-nav.hidden { display: none; }
.page-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.6;
  transition: background 0.15s;
}
.page-btn:hover { background: rgba(255,255,255,0.1); }
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-indicator {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
  text-align: center;
}

/* ── Preview area ────────────────────────────────────────── */
.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #09090f;
  min-width: 0;
  overflow: hidden;
}
.preview-header {
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.preview-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}
.status-text {
  font-size: 11px;
  color: var(--accent2);
}

.canvas-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* Canvas scaled to preview height */
.canvas-outer {
  position: relative;
  /* Canvas is 1080×1920. Scale it so the preview fits nicely. */
}
#story-canvas {
  display: block;
  border-radius: 16px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.7);
  /* Width controlled by JS scaling */
}

/* ── Mode tabs (Grid / Stats) ────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}
.mode-tab {
  padding: 5px 18px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.mode-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.mode-tab:not(.active):hover { color: var(--text); }

/* Scrollbar styles */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ── Phone bar (hidden on desktop) ───────────────────────── */
.mobile-bar { display: none; }

/* ════════════════════════════════════════════════════════════
   PHONES (≤ 768px)
   One screen at a time: Edit (the steps) or Preview (the image),
   switched from a bar pinned to the bottom. Desktop is untouched.
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body { font-size: 14px; }

  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
  }
  .preview-area { flex: 1; min-height: 0; }
  body:not([data-view="preview"]) .preview-area { display: none; }
  body[data-view="preview"] .sidebar { display: none; }

  /* Desktop's export row; the phone bar replaces it */
  .sidebar-actions { display: none; }

  .preview-header {
    padding: 0 12px;
    gap: 8px;
  }
  .status-text { display: none; } /* shown in the phone bar instead */
  .canvas-scroll { padding: 12px; }

  /* iOS zooms the whole page into any field with text under 16px */
  .text-input,
  .input-with-prefix .text-input { font-size: 16px; }

  /* Thumb-sized targets (~40px+) */
  .tab-btn, .btn { padding: 10px 14px; font-size: 14px; }
  .mode-tab { padding: 8px 20px; font-size: 14px; }
  .page-btn { padding: 8px 14px; font-size: 14px; }
  .date-trigger { padding: 11px 12px; font-size: 15px; }
  .check-label { font-size: 15px; padding: 6px 0; margin-bottom: 2px; }
  .radio-label { font-size: 15px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .sort-btn { padding: 7px 12px; font-size: 13px; }
  .preset-btn { padding: 10px; font-size: 14px; }
  .movie-item { padding: 6px 2px; gap: 4px; }
  .movie-item .heart-btn,
  .venue-btn { width: 36px; height: 36px; font-size: 18px; }
  .venue-btn.unset { font-size: 20px; }
  .movie-title-text { font-size: 14px; }
  .movie-meta-text { font-size: 12px; }
  .movie-list { max-height: 360px; }
  .panel-summary::after { width: 9px; height: 9px; }
  calendar-month::part(button) { height: 40px; font-size: 14px; }

  .date-popover:popover-open { max-height: calc(100dvh - 16px); overflow-y: auto; }

  .mobile-bar {
    display: block;
    flex-shrink: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .mobile-status {
    font-size: 12px;
    color: var(--accent2);
    min-height: 0;
    margin-bottom: 6px;
  }
  .mobile-status:empty { display: none; }
  .mobile-bar-row { display: flex; gap: 8px; }
  .mobile-views {
    display: flex;
    flex: 1;
    gap: 4px;
    padding: 3px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .mobile-view {
    flex: 1;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
  }
  .mobile-view.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
  #mobile-save { flex-shrink: 0; }
}

/* ── Diary load result (step 1) ──────────────────────────── */
.load-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.load-status[hidden] { display: none; }
.load-status::before { flex-shrink: 0; font-weight: 700; }
.load-status-text { flex: 1; }
.load-status.loading { background: var(--surface2); color: var(--muted); }
.load-status.loading::before { content: '…'; }
.load-status.ok { background: rgba(0,224,84,0.1); color: var(--accent); }
.load-status.ok::before { content: '✓'; }
.load-status.error { background: rgba(255,85,128,0.1); color: var(--danger); }
.load-status.error::before { content: '!'; }
.load-status-close {
  flex-shrink: 0;
  margin: -4px -4px -4px 0;
  padding: 2px 6px;
  border: none;
  background: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.load-status-close[hidden] { display: none; }

/* ── Page dots (phone preview) ───────────────────────────── */
.page-dots { display: none; }
@media (max-width: 768px) {
  .load-status { font-size: 14px; }
  .load-status-close { font-size: 22px; padding: 4px 10px; }

  .page-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 2px 0 8px;
  }
  .page-dots[hidden] { display: none; }
  .page-dot {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
  }
  .page-dot::after {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    margin: auto;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: background 0.2s;
  }
  .page-dot.active::after { background: #fff; }
  .page-dots .dots-gap { width: 10px; }
}

/* ── Credits (bottom of the sidebar) ─────────────────────── */
.credits {
  padding: 14px 20px 16px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}
.credits p + p { margin-top: 6px; }
.credits a { color: rgba(255,255,255,0.6); }
@media (max-width: 768px) {
  .credits { font-size: 12px; padding-bottom: 24px; }
}
