/* ===================================================================
   Jamez Timeline — global styles
   Palette: champagne gold, deep purple, ivory
   =================================================================== */
:root {
  --bg: #ffffff;
  --bg-soft: #faf8f3;
  --bg-panel: #f7f5ef;
  --ink: #1d142e;
  --text: #212529;
  --muted: #6b6471;
  --border: #e8e3d6;
  --border-strong: #cfc6b0;
  --gold: #e5cc9f;
  --gold-strong: #c9a961;
  --gold-deep: #a8862f;
  --black: #111111;
  --danger: #b03a3a;
  --success: #2f7d3c;
  --warn: #c98a18;
  --shadow-sm: 0 1px 2px rgba(29, 20, 46, 0.06);
  --shadow-md: 0 6px 24px rgba(29, 20, 46, 0.08);
  --shadow-lg: 0 16px 50px rgba(29, 20, 46, 0.15);
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand, .brand-text {
  font-family: 'Manrope', 'Inter', -apple-system, sans-serif;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }

/* ============ Header / brand ============ */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  font-size: 22px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.brand-mark {
  display: inline-block;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-strong));
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 6px;
  border-radius: 50%;
  background: var(--ink);
}
.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ----- Status indicators ----- */
.save-status {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.save-status.is-saved { opacity: 1; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.save-status.is-saving .save-dot { background: var(--gold-strong); animation: pulse 1s infinite; }
.save-status.is-error .save-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.4; } }

.collaborators {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  background: var(--bg-soft);
  border-radius: 999px;
}
.collab-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold-strong);
  box-shadow: 0 0 0 2px #fff;
  margin-left: -3px;
}
.collab-count { margin-left: 8px; }

.drag-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--ink);
  padding: 4px 10px;
  background: rgba(229, 204, 159, 0.35);
  border: 1px solid var(--gold-strong);
  border-radius: 999px;
}
.drag-pill-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold-strong);
  animation: pulse 1s infinite;
}
.timeline.remote-drag-active {
  background: rgba(229, 204, 159, 0.06);
  border-radius: 8px;
  padding: 2px;
  transition: background 0.2s;
}

/* ----- Floating ghost of another user's dragged item ----- */
.remote-ghost {
  /* keep grid layout from the cloned block, but make it visually distinct */
  background: #fff !important;
  border: 2px solid var(--gold-strong) !important;
  border-left: 4px solid var(--gold-strong) !important;
  box-shadow: 0 12px 32px rgba(29, 20, 46, 0.25);
  opacity: 0.92;
  transition: top 0.05s linear, left 0.05s linear;
  transform: rotate(-0.5deg);
}
.remote-ghost-label {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  padding: 3px 10px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

.last-edit {
  font-size: 12px;
  color: var(--text);
  padding: 4px 10px;
  background: var(--bg-soft);
  border-radius: 999px;
}
.role-tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-panel); border-color: var(--gold-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn-primary:hover { background: var(--gold-strong); border-color: var(--gold-strong); }
.btn-dark { background: var(--black); border-color: var(--black); color: #fff; }
.btn-dark:hover { background: #2a2236; border-color: #2a2236; color: #fff; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  width: 100%;
  justify-content: center;
  padding: 14px;
}
.btn-ghost:hover { border-color: var(--gold-strong); color: var(--ink); background: var(--bg-panel); }

.btn-icon {
  background: transparent;
  border: none;
  padding: 4px;
  color: var(--muted);
  border-radius: 4px;
  font-size: 15px;
}
.btn-icon:hover { color: var(--ink); background: var(--bg-soft); }
.btn-icon.active { color: var(--ink); background: var(--gold); }

.btn-icon-text {
  background: transparent;
  border: none;
  padding: 4px 8px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.btn-icon-text:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.btn-icon-text.muted { color: var(--muted); }

.btn-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

/* ============ Landing page ============ */
.landing {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.landing-card {
  max-width: 480px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.landing-card h1 { font-size: 28px; margin: 0 0 8px; }
.landing-card p { color: var(--muted); margin: 0 0 24px; }
.landing-form { display: flex; flex-direction: column; gap: 12px; }
.landing-fineprint { font-size: 12px; margin-top: 18px; }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--gold-strong);
  box-shadow: 0 0 0 3px rgba(229, 204, 159, 0.35);
}

/* ============ Dashboard ============ */
.dashboard {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}
.dashboard-head { margin-bottom: 24px; }
.dashboard-head h1 { font-size: 28px; margin: 0; }
.dashboard-head p { margin: 6px 0 0; }

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.event-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.event-card:hover {
  border-color: var(--gold-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.event-card-icon {
  font-size: 36px;
  width: 56px; height: 56px;
  background: var(--bg-soft);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.event-card-body { min-width: 0; }
.event-card-body h3 { font-size: 17px; margin: 0 0 4px; }
.event-card-body h3 a { color: var(--ink); }
.event-card-body h3 a:hover { text-decoration: none; color: var(--gold-deep); }
.event-card-type { font-size: 12px; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.event-card-meta { font-size: 13px; color: var(--muted); margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.event-card-actions {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
}
.empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.empty-state p { margin: 0 0 14px; font-size: 13px; }
.empty-state.large { padding: 80px 20px; }
.empty-state.large h3 { font-size: 22px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(29, 20, 46, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 20px; margin: 0; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 4px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.type-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  background: #fff;
  text-align: center;
  font-size: 12px;
  transition: all 0.12s;
}
.type-tile input { position: absolute; opacity: 0; }
.type-tile:has(input:checked) {
  border-color: var(--gold-strong);
  background: var(--bg-soft);
  box-shadow: 0 0 0 3px rgba(229, 204, 159, 0.25);
}
.type-icon { font-size: 22px; }
.type-name { font-weight: 600; color: var(--ink); }

/* ============ Editor toolbar ============ */
.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 0.9fr 0.9fr 1.4fr;
  gap: 12px;
  align-items: end;
}
.toolbar.readonly { display: flex; gap: 24px; font-size: 14px; padding: 14px 28px; color: var(--text); }
@media (max-width: 1200px) { .toolbar { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 720px)  { .toolbar { grid-template-columns: 1fr 1fr; } }
.field .input { padding: 8px 10px; font-size: 14px; }

/* ============ Workspace layout ============ */
.workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  padding: 20px 28px 60px;
  max-width: 1500px;
  margin: 0 auto;
}
/* When there's no library (vendor / read-only), the timeline takes the
   whole row instead of getting jammed into the 280px column. */
.workspace.workspace-full { grid-template-columns: 1fr; max-width: 1100px; }
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; padding: 16px; }
}

/* ============ Library (left panel) ============ */
.library {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.library-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 8px 4px 6px;
}
.library-sub {
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 4px 8px;
}
.category { margin-bottom: 2px; }
.preset-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 6px;
  cursor: grab;
  font-size: 13.5px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.preset-event:hover { background: #fff; border-color: var(--gold-strong); }
.preset-event:active { cursor: grabbing; }
.preset-event .duration { font-size: 14px; color: var(--gold-strong); font-weight: 700; }
.preset-event.sortable-ghost { opacity: 0.4; }
.preset-event.sortable-drag { background: var(--gold); border-color: var(--gold-strong); box-shadow: var(--shadow-md); }

.template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--bg-soft);
  font-size: 13px;
}
.template-name { color: var(--ink); font-weight: 500; }
.template-actions { display: flex; gap: 4px; }

/* ============ Timeline (right panel) ============ */
.timeline-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}
.timeline-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.summary-item { display: flex; flex-direction: column; }
.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.summary-value {
  font-family: 'Manrope', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.summary-value.warn { color: var(--warn); }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
}

.block {
  display: grid;
  grid-template-columns: 24px 86px 1fr auto 60px;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.block:hover { box-shadow: var(--shadow-sm); }
.block.sortable-ghost { opacity: 0.3; }
.block.sortable-chosen { box-shadow: var(--shadow-md); }
.block.locked { background: var(--bg-soft); }
.block.locked .drag-handle { cursor: not-allowed; opacity: 0.4; }
.block.completed { opacity: 0.7; }
.block.completed .block-name { text-decoration: line-through; }
.block.skipped { opacity: 0.5; background: repeating-linear-gradient(135deg, #fff, #fff 8px, var(--bg-soft) 8px, var(--bg-soft) 16px); }

.block-form { display: contents; }
.block-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.block-icon {
  font-size: 18px;
  line-height: 1;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  display: flex;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.block-time {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.block-time .ampm { font-size: 11px; color: var(--muted); margin-left: 2px; font-weight: 600; }
.block-name {
  border: none;
  background: transparent;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  padding: 4px 4px;
  border-radius: 4px;
  width: 100%;
  min-width: 0;
}
.block-name.readonly { padding: 0; }
.block-name:hover { background: var(--bg-soft); }
.block-name:focus {
  outline: none;
  background: var(--bg-soft);
  box-shadow: inset 0 -2px 0 var(--gold-strong);
}
.duration-input {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  justify-self: end;
}
.duration-input.readonly { background: transparent; }
.duration-input:focus-within { border-color: var(--gold-strong); background: #fff; }
.duration-input input {
  width: 36px;
  border: none;
  background: transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding: 0;
}
.duration-input input:focus { outline: none; }
.duration-input .unit {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.block-actions { display: flex; gap: 2px; justify-content: flex-end; }
.accordion-toggle .chevron {
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.accordion-toggle.open .chevron { transform: rotate(90deg); }
.block-locked-icon { font-size: 13px; color: var(--muted); }

/* ----- Item drawer ----- */
.item-drawer {
  grid-column: 1 / -1;
  margin-top: 10px;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drawer-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .drawer-row { grid-template-columns: 1fr; } }
.drawer-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.active {
  border-color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff inset;
}
.icon-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-swatch.active { border-color: var(--gold-strong); background: var(--gold); }

.event-notes {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.notes-label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.add-custom-wrap { margin-top: 12px; }

/* ============ Day-of Mode ============ */
.day-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #faf8f3 0%, #fff 240px);
  padding-bottom: 100px;
}
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.day-header .brand-mark { width: 28px; height: 28px; }
.day-header .btn-pill { background: rgba(255,255,255,0.12); border-color: transparent; color: #fff; }
.day-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.day-event-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}
.day-event-meta { font-size: 11px; color: rgba(255,255,255,0.7); }

.day-delay-banner {
  background: var(--warn);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
}

.day-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.day-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 4px 4px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.day-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.day-card-now {
  border-left-width: 6px;
  box-shadow: var(--shadow-md);
}
.day-card-time {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.day-card-time .ampm { font-size: 14px; color: var(--muted); margin-left: 4px; font-weight: 700; }
.day-card-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  margin: 10px 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-card-icon { font-size: 28px; }
.day-card-desc { color: var(--muted); margin: 4px 0 0; }

.day-announce {
  margin-top: 14px;
  padding: 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
}
.day-announce.subtle { background: var(--bg-soft); color: var(--ink); }
.day-announce-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 6px;
}
.day-announce-text { font-size: 17px; line-height: 1.5; margin: 0; }

.day-notes {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: 10px;
  font-size: 14px;
}
.day-notes-label {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 4px;
}
.day-notes p { margin: 0; }

.day-actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.day-btn {
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  min-height: 60px;
  transition: transform 0.06s, background 0.12s;
}
.day-btn:active { transform: scale(0.98); }
.day-btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.day-btn.primary:hover { background: #2a2236; }
.day-btn.delay { background: var(--gold); border-color: var(--gold-strong); }
.day-btn.delay.subtle { background: #fff; color: var(--muted); }

.day-delays { margin-top: 14px; }
.day-delays-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.day-delay-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.day-list {
  margin-top: 12px;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.day-list-head {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.day-list-row {
  display: grid;
  grid-template-columns: 80px 1fr 30px;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.day-list-row:last-child { border-bottom: none; }
.day-list-row.is-current { background: var(--bg-soft); font-weight: 600; }
.day-list-row.completed { opacity: 0.55; text-decoration: line-through; }
.day-list-row.skipped { opacity: 0.45; }
.day-list-time {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-size: 13px;
}
.day-list-time .ampm { font-size: 10px; color: var(--muted); margin-left: 2px; }
.day-list-icon { margin-right: 8px; }
.day-list-status { text-align: right; color: var(--gold-strong); font-weight: 700; }

/* ============ Print sheet ============ */
.print-body { background: #f7f5ef; padding: 40px 20px; }
.print-toolbar {
  max-width: 800px;
  margin: 0 auto 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  padding: 56px 64px 72px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 28px;
}
.brand-text {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.sheet-contact { text-align: right; font-size: 12px; color: var(--muted); }
.sheet-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 30px;
  color: var(--ink);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.sheet-meta {
  display: flex; gap: 22px;
  color: var(--muted); font-size: 13.5px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.sheet-meta strong { color: var(--ink); font-weight: 600; }
.sheet-section-title {
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin: 28px 0 12px;
}
.sheet-notes-block {
  background: var(--bg-soft);
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.sheet-notes-block p { margin: 0; font-size: 13.5px; }

.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table thead th {
  text-align: left;
  font-family: 'Manrope', sans-serif;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 8px 8px;
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
}
.sheet-table tbody td { padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sheet-table .col-time {
  font-family: 'Manrope', sans-serif; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  width: 90px; font-size: 15px;
}
.sheet-table .col-time .ampm { font-size: 10.5px; color: var(--muted); margin-left: 3px; font-weight: 600; }
.sheet-table .col-name { font-size: 14px; color: var(--text); }
.sheet-table .col-name strong { font-weight: 600; color: var(--ink); margin-left: 4px; }
.sheet-table .col-name .row-desc { font-size: 12px; color: var(--muted); margin-top: 3px; font-style: italic; }
.sheet-table .col-name .row-locked { font-size: 10px; margin-left: 6px; }
.sheet-table .col-category {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.sheet-table .col-duration {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  width: 70px;
}
.sheet-table .empty { padding: 24px; text-align: center; color: var(--muted); font-style: italic; }

.sheet-announcement {
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
  break-inside: avoid;
}
.ann-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ann-time { font-family: 'Manrope', sans-serif; }
.ann-title { color: var(--ink); }
.ann-text { font-size: 14px; margin: 0; line-height: 1.55; }

.sheet-notes { margin-bottom: 12px; font-size: 13px; }
.sheet-notes strong { display: block; margin-bottom: 4px; color: var(--ink); }
.sheet-notes p { margin: 0; color: var(--muted); }

.sheet-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}

.sheet-page-break { page-break-before: always; }

@media print {
  .print-body { background: #fff; padding: 0; }
  .print-toolbar { display: none; }
  .sheet { border: none; box-shadow: none; padding: 28px 32px; max-width: none; }
  .sheet-table tbody tr { page-break-inside: avoid; }
  .sheet-announcement { page-break-inside: avoid; }
}

/* ============ Auth forms + Settings ============ */
.form-error {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f4cfcf;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  text-align: left;
}
.landing-cta-row { display: flex; gap: 10px; margin-bottom: 6px; }

.settings-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  max-width: 720px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.settings-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 4px;
}
.settings-help { font-size: 13px; margin: 4px 0 0; }
.settings-help code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.settings-actions { display: flex; gap: 10px; }

/* Toggle switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 44px; height: 24px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle-thumb {
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-track { background: var(--gold-strong); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* ----- Flash ----- */
.phx-flash { position: fixed; top: 14px; right: 14px; z-index: 50; }
.phx-flash > * {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-md);
}

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.flash-info { background: var(--bg-soft); color: var(--ink); }
.flash-error { background: #fde7e7; color: #7a1d1d; border-color: #f3c2c2; }

/* ----- Impersonation banner ----- */
.impersonation-banner {
  background: #2a1d4a;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.impersonation-banner strong { color: #ffd66b; }
.impersonation-stop {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
}

/* ----- Share link group (Copy + Revoke) ----- */
.share-link-group {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}
.share-link-group .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.share-link-group .btn-icon {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: none;
  padding: 0 8px;
}

/* ----- Users table (admin panel) ----- */
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}
.users-table th, .users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.users-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.users-table tr:last-child td { border-bottom: none; }
.users-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
}
.badge.badge-on {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold-strong);
}

.btn-small {
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.btn-small.btn-primary { background: var(--gold-strong); border-color: var(--gold-strong); color: var(--ink); }
.btn-small.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.user-pwreset { display: inline-block; }
.user-pwreset > summary { list-style: none; }
.user-pwreset > summary::-webkit-details-marker { display: none; }
.user-pwreset[open] > summary { background: var(--bg-soft); }
.pw-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  padding: 8px;
  background: var(--bg-soft);
  border-radius: 6px;
}
.pw-form .input { padding: 6px 10px; font-size: 13px; }

@media (max-width: 720px) {
  .users-table thead { display: none; }
  .users-table tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .users-table td {
    display: block;
    padding: 4px 0;
    border: none;
  }
  .users-table td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    margin-right: 6px;
  }
}

/* Mobile-only UI elements — hidden by default on desktop. */
.meta-summary,
.library-fab,
.library-mobile-head { display: none; }

/* ============ Small tablets & landscape phones (sidebar → sheet) ============
   At ≤960px we hide the library sidebar so the timeline gets full width
   and surface it through the floating "+ Add item" FAB instead. This
   catches iPhone Pro Max in landscape (932) and iPad portrait sizes.
   Below 640px the existing mobile rules take over for header/meta/blocks. */
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; padding: 16px; gap: 14px; }

  .library { display: none; }
  .library.library-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    max-height: none;
    border-radius: 0;
    border: none;
    overflow-y: auto;
    padding: 14px 14px 80px;
    background: #fff;
  }
  .library-mobile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 15px;
  }
  .library.library-open > .library-title:first-of-type { display: none; }
  .library-fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gold);
    color: var(--ink);
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 30;
    cursor: pointer;
  }
}

/* ============ Short viewports — landscape phones ============
   Width-based rules can't reach landscape phones (≥640px wide) so we
   also key the header/meta collapse off viewport height. */
@media (max-height: 560px) {
  .site-header { padding: 6px 12px; gap: 8px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-mark::after { inset: 5px; }
  .brand-sub { display: none; }
  .header-actions { gap: 6px; }
  .header-actions .btn,
  .header-actions .btn-icon-text { padding: 5px 9px; font-size: 12.5px; }
  .save-status { padding: 3px 8px; font-size: 11px; }

  /* Collapse the meta toolbar into the sticky summary button. */
  .meta-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 14px;
    background: #fff;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--ink);
    position: sticky;
    top: 0;
    z-index: 9;
  }
  .meta-summary-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
  .meta-summary-main strong {
    font-size: 14px; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .meta-summary-sub {
    font-size: 11.5px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .meta-chevron { font-size: 18px; line-height: 1; color: var(--muted); flex-shrink: 0; }

  .toolbar.collapsible { display: none; }
  .toolbar.collapsible.open {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 14px;
    gap: 8px;
  }
  .toolbar.collapsible.readonly.open {
    display: flex; padding: 10px 14px; gap: 12px;
    flex-wrap: wrap; font-size: 13px;
  }

  /* Day-of mode — slim down so the current item stays above the fold. */
  .day-header { padding: 8px 12px; position: static; }
  .day-header .brand-mark { width: 22px; height: 22px; }
  .day-event-name { font-size: 13.5px; }
  .day-event-meta { font-size: 10.5px; }
  .day-main { padding: 12px; gap: 10px; }
  .day-card { padding: 12px 14px; }
  .day-card-time { font-size: 22px; }
  .day-actions { gap: 8px; margin-top: 10px; }
  .day-btn { padding: 12px; min-height: 48px; font-size: 14px; }
  .day-delays { margin-top: 10px; }
}

/* ============ Mobile ============ */
@media (max-width: 640px) {
  /* Header — trim padding, hide the subtitle (often a long email), shrink brand. */
  .site-header { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-mark::after { inset: 5px; }
  .brand-sub { display: none; }
  .header-actions { gap: 6px; }
  .header-actions .btn,
  .header-actions .btn-icon-text { padding: 6px 10px; font-size: 13px; }

  /* Dashboard */
  .dashboard { padding: 20px 14px 40px; }
  .dashboard-head h1 { font-size: 22px; }
  .event-grid { grid-template-columns: 1fr; gap: 12px; }
  .event-card { padding: 14px; gap: 10px 12px; }
  .event-card-icon { width: 44px; height: 44px; font-size: 26px; border-radius: 10px; }
  .event-card-body h3 { font-size: 16px; }
  .event-card-actions { padding-top: 10px; gap: 4px; }
  .event-card-actions .btn-icon-text { padding: 8px 10px; font-size: 12.5px; }

  /* Collapsible event-meta bar: a compact summary that expands to the full
     toolbar form. Sticky to keep critical context visible while scrolling. */
  .meta-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--ink);
    position: sticky;
    top: 0;
    z-index: 9;
  }
  .meta-summary-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
  .meta-summary-main strong { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .meta-summary-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .meta-chevron { font-size: 20px; line-height: 1; color: var(--muted); flex-shrink: 0; }

  /* Toolbar is collapsed by default; revealed when .open is added. */
  .toolbar.collapsible { display: none; }
  .toolbar.collapsible.open { display: grid; grid-template-columns: 1fr; padding: 12px 14px; gap: 8px; }
  .toolbar.collapsible.readonly.open { display: flex; padding: 10px 14px; gap: 12px; flex-wrap: wrap; font-size: 13px; }

  /* Editor workspace */
  .workspace { padding: 12px; gap: 12px; }
  .timeline-panel { padding: 14px; border-radius: var(--radius); }
  .timeline-summary { gap: 8px; padding-bottom: 10px; margin-bottom: 10px; }
  .summary-value { font-size: 15px; }

  /* Library hides off-screen by default on phones; the floating "+ Add item"
     button opens it as a fullscreen sheet (`.library-open`). */
  .library { display: none; }
  .library.library-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    max-height: none;
    border-radius: 0;
    border: none;
    overflow-y: auto;
    padding: 14px 14px 80px;
  }
  .library-mobile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 15px;
  }
  /* The original `.library-title` heading is redundant once the sheet header
     is showing — hide it inside the mobile sheet to avoid duplication. */
  .library.library-open > .library-title:first-of-type { display: none; }
  .library-fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--gold);
    color: var(--ink);
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 30;
    cursor: pointer;
  }

  /* Timeline blocks — re-flow into two rows:
       row 1:  handle | time | (spacer) | duration | actions
       row 2:  title (full width)                            */
  .block {
    grid-template-columns: 22px auto 1fr auto auto;
    column-gap: 6px;
    row-gap: 4px;
    padding: 10px 10px 10px 4px;
    min-width: 0;
  }
  .block > .drag-handle    { grid-column: 1; grid-row: 1; }
  .block > .block-time     { grid-column: 2; grid-row: 1; font-size: 14px; white-space: nowrap; }
  .block > .duration-input { grid-column: 4; grid-row: 1; justify-self: end; }
  .block > .block-actions  { grid-column: 5; grid-row: 1; }
  .block > .block-main     { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .block-name { font-size: 14px; }
  .block-actions .btn-icon { padding: 6px; font-size: 17px; }

  /* Drawer */
  .item-drawer { padding: 12px; margin-top: 8px; }
  .swatch-row { gap: 4px; }
  .drawer-actions { flex-wrap: wrap; }
  .drawer-actions .btn { padding: 8px 12px; font-size: 13px; }

  /* Modal */
  .modal-backdrop { padding: 12px; }
  .modal-head { padding: 14px 18px; }
  .modal-body { padding: 16px 18px; }

  /* Settings */
  .settings-card { padding: 18px; }
  .settings-row { flex-direction: column; gap: 10px; }
  .settings-actions { flex-wrap: wrap; }
}
