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

/* ── Variables — Dark (default) ─────────────────────────────────────────────── */
:root {
  --bg-base:      #1E1E2E;
  --bg-surface:   #2A2A3E;
  --bg-elevated:  #32324A;
  --bg-hover:     #3A3A55;
  --border:       #3E3E5A;
  --border-light: #4E4E70;

  --text-primary:   #EEEEF5;
  --text-secondary: #9999BB;
  --text-muted:     #66669A;

  --accent:       #6C63FF;
  --accent-hover: #8B85FF;
  --accent-dim:   #25224A;

  --priority-high:   #FF5C5C;
  --priority-medium: #F5A623;
  --priority-low:    #43BF8E;

  --success: #43BF8E;
  --warning: #F5A623;
  --danger:  #FF5C5C;

  --radius:       12px;
  --radius-lg:    16px;
  --radius-pill:  999px;
  --radius-input: 10px;
  --shadow:    0 4px 16px rgba(108,99,255,0.18);
  --shadow-sm: 0 2px 8px rgba(108,99,255,0.10);

  --overlay-header: rgba(0,0,0,0.20);
  --select-arrow:   url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239999BB' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");

  --font: 'DM Sans', 'Nunito', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Variables — Light ──────────────────────────────────────────────────────── */
html[data-theme="light"] {
  --bg-base:      #F7F6FF;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #F2F0FF;
  --bg-hover:     #EAE8FF;
  --border:       #D8D4F5;
  --border-light: #C5BFEE;

  --text-primary:   #1A1A2E;
  --text-secondary: #4A4A72;
  --text-muted:     #8888AA;

  --accent:       #6C63FF;
  --accent-hover: #5A52E0;
  --accent-dim:   #EAE8FF;

  --priority-high:   #E03030;
  --priority-medium: #C07800;
  --priority-low:    #1E8A5A;

  --shadow:    0 4px 16px rgba(108,99,255,0.10);
  --shadow-sm: 0 2px 8px rgba(108,99,255,0.06);

  --overlay-header: rgba(108,99,255,0.05);
  --select-arrow:   url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234A4A72' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

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

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ── App Shell ──────────────────────────────────────────────────────────────── */
.app-shell {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 56px 44px 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: auto;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-powered {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
  letter-spacing: 0.02em;
}
.login-powered strong { color: var(--accent); font-weight: 600; }

.login-logo            { text-align: center; margin-bottom: 1rem; }
.login-logo-img        { height: 80px; width: auto; display: block; margin: 0 auto; }
.login-logo--light     { display: none; }
html[data-theme="light"] .login-logo--dark  { display: none; }
html[data-theme="light"] .login-logo--light { display: block; margin: 0 auto; }
.login-title      { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle   { text-align: center; color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 0.6rem; }
.login-capabilities-link { text-align: center; margin-bottom: 1.25rem; }
.login-capabilities-link a { font-size: 0.8rem; color: var(--accent); text-decoration: none; font-weight: 500; }
.login-capabilities-link a:hover { text-decoration: underline; }

.login-error {
  background: rgba(255,92,92,0.12);
  border: 1px solid rgba(255,92,92,0.4);
  border-radius: var(--radius);
  padding: 0.6rem 0.875rem;
  color: #FF8A8A;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.login-form .form-group { margin-bottom: 1rem; }

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  user-select: none;
}
.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.header-brand        { display: flex; align-items: center; }
.header-logo         { height: 44px; width: auto; display: block; overflow: visible; }
.header-logo--light  { display: none; }
html[data-theme="light"] .header-logo--dark  { display: none; }
html[data-theme="light"] .header-logo--light { display: block; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.current-user   { color: var(--text-secondary); font-size: 0.875rem; }

/* ── Avatar & Profile Popover ───────────────────────────────────────────────── */
.avatar-wrap     { position: relative; }
.header-avatar   {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); border: 2px solid transparent;
  cursor: pointer; overflow: hidden; padding: 0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: border-color 0.15s;
}
.header-avatar:hover { border-color: var(--accent-hover); }
.avatar-img      { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initials { color: #fff; font-size: 0.875rem; font-weight: 700; line-height: 1; pointer-events: none; }

.profile-popover {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  padding: 1rem; width: 210px; z-index: 500;
}
.profile-pop-header {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem; padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}
.pop-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pop-avatar-img      { width: 100%; height: 100%; object-fit: cover; display: block; }
.pop-avatar-initials { color: #fff; font-size: 1.25rem; font-weight: 700; line-height: 1; }
.pop-username        { font-weight: 600; font-size: 0.9375rem; color: var(--text-primary); word-break: break-all; }
.profile-popover .btn + .btn { margin-top: 0.4rem; }
.profile-divider { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0 0.5rem; }

/* ── Profile dialogs (Change Log + Sessions) ─────────────────────────────────── */
.profile-dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.25rem;
}
.profile-dialog-header h3 { margin-bottom: 0; }
.profile-dialog-sub {
  font-size: 0.825rem; color: var(--text-secondary);
  margin-bottom: 1rem; line-height: 1.5;
}
.profile-dialog-list {
  display: flex; flex-direction: column; gap: 0.5rem;
  max-height: 360px; overflow-y: auto;
  margin-bottom: 0.5rem;
}
.profile-dialog-empty { font-size: 0.875rem; color: var(--text-muted); padding: 1rem 0; text-align: center; }

.pdialog-row {
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated); border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
}
/* Column-layout variant used by changelog + sessions */
.pdialog-row--col { display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; }
.pdialog-row-top  { display: flex; align-items: center; gap: 0.5rem; }
.pdialog-row-info { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 0.2rem; }
.pdialog-row-label { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); flex: 1; min-width: 0; }
.pdialog-row-meta  { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* Change log specifics */
.cl-action-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: var(--radius-pill); padding: 0.15rem 0.55rem;
  flex-shrink: 0;
}
.cl-action-add  { background: rgba(67,191,142,0.15);  color: var(--success); }
.cl-action-edit { background: rgba(108,99,255,0.15); color: var(--accent); }
.cl-action-del  { background: rgba(255,92,92,0.15);  color: var(--danger); }
.cl-detail {
  font-size: 0.8rem; color: var(--text-secondary); line-height: 1.45;
  padding-left: 0.25rem; word-break: break-word;
}

/* Session detail grid */
.session-detail-grid { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.session-detail-item { font-size: 0.775rem; color: var(--text-secondary); }

.session-current-badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  color: var(--success); background: rgba(67,191,142,0.12);
  border-radius: var(--radius-pill); padding: 0.1rem 0.5rem;
  margin-left: 0.4rem; vertical-align: middle;
}

/* ── Tab Bar ────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 0.25rem;
}

.tab-btn {
  padding: 0 1rem;
  height: 44px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-btn:hover         { color: var(--text-primary); }
.tab-btn.active        { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn[draggable="true"] { cursor: grab; }
.tab-btn[draggable="true"]:active { cursor: grabbing; }
.tab-btn.tab-dragging  { opacity: 0.4; }
.tab-btn.tab-drag-over { border-bottom-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.sidebar-toggle {
  margin-left: auto;
  padding: 0 0.875rem;
  height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── App Body ───────────────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ── Tab Content ────────────────────────────────────────────────────────────── */
.tab-content         { display: none; height: 100%; }
.tab-content.active  { display: flex; flex-direction: column; }

/* ── Board ──────────────────────────────────────────────────────────────────── */
.board-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.board-canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  min-height: 0;
  background:
    radial-gradient(circle, var(--border) 1px, transparent 1px) 0 0 / 28px 28px;
}

/* ── Sticky Note ────────────────────────────────────────────────────────────── */
.sticky-note {
  position: absolute;
  width: 240px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  transition: box-shadow 0.15s;
  color: #e8e8f0;
}
.sticky-note:hover   { box-shadow: 0 8px 32px rgba(0,0,0,0.55); }
.sticky-note.dragging { z-index: 1000; box-shadow: 0 12px 40px rgba(0,0,0,0.65); }
.sticky-note.minimised .note-body { display: none; }

.note-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.5rem;
  cursor: grab;
  user-select: none;
  background: var(--overlay-header);
  flex-shrink: 0;
}
.note-header:active { cursor: grabbing; }

.note-colour-btn {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.note-colour-btn:hover { transform: scale(1.2); }

.note-read-label {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 0.15rem;
}
.note-read-check {
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: #43BF8E;
  flex-shrink: 0;
}
.note-read-text {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.45);
  user-select: none;
}
.note-read-label:has(.note-read-check:checked) .note-read-text {
  color: #43BF8E;
}

.sticky-note.note-read { opacity: 0.45; }
.sticky-note.note-read .note-textarea { text-decoration: line-through; color: rgba(255,255,255,0.5); }

.note-actions      { display: flex; gap: 0.2rem; margin-left: auto; }
.note-action-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  line-height: 1.4;
}
.note-action-btn:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.9); }

.note-body { padding: 0.5rem; flex: 1; }

.note-textarea {
  width: 100%;
  min-height: 100px;
  background: none;
  border: none;
  outline: none;
  color: inherit;
  font-family: var(--font);
  font-size: 0.875rem;
  resize: vertical;
  line-height: 1.55;
}

/* ── Colour Palette Popover ─────────────────────────────────────────────────── */
.colour-palette {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem;
  display: grid;
  grid-template-columns: repeat(5, 22px);
  gap: 4px;
  z-index: 5000;
  box-shadow: var(--shadow);
}

.colour-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.1s, transform 0.1s;
}
.colour-swatch:hover { border-color: rgba(255,255,255,0.6); transform: scale(1.1); }

/* ── Image Tile ─────────────────────────────────────────────────────────────── */
.image-tile {
  position: absolute;
  min-width: 120px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.image-tile:hover   { box-shadow: 0 8px 32px rgba(0,0,0,0.55); }
.image-tile.dragging { z-index: 1000; }

.image-tile-header {
  display: flex;
  align-items: center;
  padding: 0.3rem 0.5rem;
  background: var(--overlay-header);
  cursor: grab;
  user-select: none;
  gap: 0.375rem;
  flex-shrink: 0;
}
.image-tile-header:active { cursor: grabbing; }

.image-caption {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font);
  min-width: 0;
}
.image-caption:focus { color: var(--text-primary); }

.image-delete-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.image-delete-btn:hover { background: rgba(255,92,92,0.2); color: #FF8A8A; }

.image-tile img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.image-resize-handle,
.tile-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--border-light) 50%);
  z-index: 1;
}

/* ── Calendar ───────────────────────────────────────────────────────────────── */
#tab-calendar {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.calendar-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  min-width: 200px;
  text-align: center;
}

/* View toggle */
.cal-view-toggle {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  margin-left: auto;
}
.cal-view-btn {
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.cal-view-btn:hover { color: var(--text-primary); }
.cal-view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Week view ── */
.cal-week-grid {
  display: grid !important;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-week-col {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 180px;
}
.cal-week-col:hover { background: var(--bg-hover); }
.cal-week-col.today { border-color: var(--accent); background: var(--accent-dim); }
.cal-week-col-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 6px;
  border-bottom: 1px solid var(--border);
  gap: 2px;
}
.cal-week-dayname {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.cal-week-daynum {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.cal-week-daynum.today {
  background: var(--accent);
  color: #fff;
}
.cal-week-events {
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Day view ── */
.cal-day-view {
  display: flex !important;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-dv-allday,
.cal-dv-slot {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}
.cal-dv-slot:last-child { border-bottom: none; }
.cal-dv-slot.current-hour { background: var(--accent-dim); }
.cal-dv-allday { background: var(--bg-elevated); }
.cal-dv-time-label {
  flex-shrink: 0;
  width: 56px;
  padding: 10px 8px 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}
.cal-dv-slot-body {
  flex: 1;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  cursor: pointer;
}
.cal-dv-slot-body:hover { background: var(--bg-hover); }
.cal-dv-event-chip {
  font-size: 0.75rem !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  cursor: pointer;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.35rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-day {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 82px;
  padding: 0.4rem;
  cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
}
.cal-day:hover        { background: var(--bg-hover); }
.cal-day.today        { border-color: var(--accent); background: var(--accent-dim); }
.cal-day.other-month  { opacity: 0.3; pointer-events: none; }

.cal-day-number {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
}
.cal-day.today .cal-day-number { color: var(--accent); }

.cal-event-chip {
  display: block;
  font-size: 0.68rem;
  padding: 0.13rem 0.3rem;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  cursor: pointer;
}
.cal-event-chip:hover { filter: brightness(1.15); }

/* ── Tasks ──────────────────────────────────────────────────────────────────── */
#tab-tasks {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.tasks-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tasks-filters { display: flex; align-items: center; gap: 0.5rem; }

.task-list { display: flex; flex-direction: column; gap: 0.5rem; }

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--priority-medium);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}
.task-item:hover                    { background: var(--bg-hover); }
.task-item[data-priority="high"]    { border-left-color: var(--priority-high); }
.task-item[data-priority="medium"]  { border-left-color: var(--priority-medium); }
.task-item[data-priority="low"]     { border-left-color: var(--priority-low); }
.task-item.completed                { opacity: 0.5; }
.task-item.completed .task-title    { text-decoration: line-through; }

.task-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
  accent-color: var(--accent);
}

.task-info  { flex: 1; min-width: 0; }
.task-title { font-size: 0.9rem; color: var(--text-primary); margin-bottom: 0.2rem; }
.task-meta  { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }

.priority-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.priority-high   { background: rgba(255,92,92,0.15);  color: #FF8A8A; }
.priority-medium { background: rgba(245,166,35,0.15); color: #FFCC70; }
.priority-low    { background: rgba(67,191,142,0.15); color: #6FDDBA; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 290px;
  min-width: 290px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 0; min-width: 0; }

.sidebar-powered {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sidebar-powered strong { color: var(--accent); font-weight: 600; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header h3 { font-size: 0.9rem; font-weight: 600; }

.sidebar-content { overflow-y: auto; flex: 1; padding: 0.75rem; }

.next7-day-group  { margin-bottom: 1rem; }

.next7-day-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border);
}
.next7-day-label.today    { color: var(--accent); }
.next7-day-label.tomorrow { color: var(--priority-medium); }

.next7-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.815rem;
}

.next7-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.next7-text { color: var(--text-secondary); word-break: break-word; }
.next7-time { color: var(--text-muted); font-size: 0.73rem; margin-top: 1px; }

/* ── Forms & Inputs ─────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.875rem;
}

.form-row      { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }

label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
label small { color: var(--text-muted); font-weight: 400; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea,
select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

select {
  cursor: pointer;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

.input-emoji-row { display: flex; gap: 0.375rem; align-items: center; }
.input-emoji-row input { flex: 1; }

.select-sm { padding: 0.35rem 2rem 0.35rem 0.6rem; font-size: 0.8rem; width: auto; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost     { background: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger    { background: rgba(255,92,92,0.12); color: #FF8A8A; border: 1px solid rgba(255,92,92,0.3); }
.btn-danger:hover { background: rgba(255,92,92,0.22); }

.btn-sm   { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

.emoji-trigger {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.44rem 0.55rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}
.emoji-trigger:hover { background: var(--bg-hover); }

/* ── Dialogs ────────────────────────────────────────────────────────────────── */
.app-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  padding: 0;
  max-width: 490px;
  width: calc(100vw - 2rem);
  box-shadow: var(--shadow);
}
.app-dialog::backdrop {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
}

.dialog-form { padding: 1.5rem; }
.dialog-form h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.25rem; }

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}

/* Colour swatches (event dialog) */
.colour-swatches { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.event-colour-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.1s, transform 0.1s;
}
.event-colour-swatch:hover   { transform: scale(1.15); }
.event-colour-swatch.selected { border-color: #fff; transform: scale(1.1); }

/* ── Emoji Picker ───────────────────────────────────────────────────────────── */
.emoji-picker {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 9999;
  width: 284px;
  overflow: hidden;
}
/* When inside a dialog the picker must be absolute so it renders in the top layer */
dialog .emoji-picker {
  position: absolute;
  z-index: 100;
}

.emoji-categories {
  display: flex;
  padding: 0.35rem 0.4rem;
  gap: 0.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.emoji-cat-btn {
  background: none;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 5px;
  transition: background 0.1s;
  flex: 1;
  text-align: center;
}
.emoji-cat-btn:hover, .emoji-cat-btn.active { background: var(--bg-hover); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0.35rem;
  gap: 1px;
  max-height: 196px;
  overflow-y: auto;
}

.emoji-btn {
  font-size: 1.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.28rem;
  border-radius: 4px;
  line-height: 1;
  text-align: center;
  transition: background 0.1s;
}
.emoji-btn:hover { background: var(--bg-hover); }

/* ── Toasts ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9998;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  max-width: 300px;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Groceries ──────────────────────────────────────────────────────────────── */
#tab-groceries { overflow: hidden; }

.groceries-layout {
  display: flex;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

.grocery-list-panel,
.grocery-dict-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.grocery-list-panel {
  flex: 1;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.grocery-dict-panel {
  width: 340px;
  min-width: 260px;
  flex-shrink: 0;
}

.grocery-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.grocery-panel-header h3 { font-size: 0.9rem; font-weight: 600; }

.grocery-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.grocery-add-inputs {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  align-items: center;
  min-width: 0;
}

.grocery-autocomplete-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.grocery-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}

.grocery-suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.1s;
}
.grocery-suggestion-item:hover { background: var(--bg-hover); }
.grocery-suggestion-item img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.grocery-suggestion-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.grocery-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.grocery-category-group { margin-bottom: 0.25rem; }

.grocery-cat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.4rem 1rem 0.2rem;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  transition: background 0.1s;
  cursor: default;
}
.grocery-item:hover { background: var(--bg-hover); }
.grocery-item.checked { opacity: 0.45; }
.grocery-item.checked .grocery-item-name { text-decoration: line-through; }

.grocery-item-check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.grocery-item-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.grocery-item-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.grocery-item-info { flex: 1; min-width: 0; }
.grocery-item-name { font-size: 0.875rem; color: var(--text-primary); }
.grocery-item-qty  { font-size: 0.75rem; color: var(--text-muted); }

.grocery-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s;
}
.grocery-item:hover .grocery-item-del { opacity: 1; }
.grocery-item-del:hover { background: rgba(255,92,92,0.15); color: #FF8A8A; }

/* Dictionary */
.grocery-dict-search-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.grocery-dict-search-row input { flex: 1; }

.grocery-dict-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  align-content: start;
}

.dict-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
  display: flex;
  flex-direction: column;
}
.dict-card:hover { background: var(--bg-hover); box-shadow: var(--shadow-sm); }

.dict-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}
.dict-card-icon {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--bg-elevated);
}

.dict-card-label {
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dict-card-cat {
  padding: 0 0.4rem 0.3rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Dict image in dialog */
.dict-image-row { display: flex; align-items: center; gap: 0.6rem; }
.dict-image-preview {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.dict-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dict-image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Wide dialog ────────────────────────────────────────────────────────────── */
.app-dialog-wide {
  max-width: 640px;
}
.app-dialog-wide .dialog-form {
  max-height: 85vh;
  overflow-y: auto;
}

/* ── Detail panels inside popup dialogs (Recipes, Trips) ───────────────────── */
#recipe-detail-dialog,
#trip-detail-dialog {
  width: calc(100vw - 2rem);
  max-width: 720px;
  height: 90vh;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}
#recipe-detail-dialog[open],
#trip-detail-dialog[open],
#recipe-detail-dialog.hp-dialog-open,
#trip-detail-dialog.hp-dialog-open {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  margin: 0;
}
#recipe-detail-dialog .recipe-detail-panel,
#trip-detail-dialog .trip-detail-panel {
  width: 100%;
  min-width: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-right: none;
}
#recipe-detail-dialog .recipe-detail-content,
#trip-detail-dialog .trip-detail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#recipe-detail-dialog .recipe-detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#trip-detail-dialog .trip-section-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Recipes ─────────────────────────────────────────────────────────────────── */
#tab-recipes { overflow: hidden; }

.recipes-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.recipe-grid-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.recipe-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.recipe-panel-header h3 { font-size: 0.9rem; font-weight: 600; }

.recipe-search-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.recipe-search-row input { flex: 1; }

.recipe-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
  align-content: start;
}

.recipe-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
}
.recipe-card:hover       { background: var(--bg-hover); box-shadow: var(--shadow-sm); }
.recipe-card.selected    { border-color: var(--accent); background: var(--accent-dim); }

.recipe-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}
.recipe-card-icon {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: var(--bg-elevated);
}
.recipe-card-body  { padding: 0.4rem 0.5rem; }
.recipe-card-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-card-meta  { font-size: 0.68rem; color: var(--text-muted); }

/* ── Recipe detail panel ────────────────────────────────────────────────────── */
.recipe-detail-panel {
  width: 360px;
  min-width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}

.recipe-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.recipe-detail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.recipe-detail-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.rd-image-wrap { flex: 1; }

.recipe-detail-header-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.recipe-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.recipe-detail-body h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.recipe-tag {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.recipe-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.recipe-meta span { display: flex; align-items: center; gap: 0.25rem; }

.recipe-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1rem;
}

.recipe-section { margin-bottom: 1rem; }
.recipe-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.recipe-ingredient-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.recipe-ingredient-list li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.2rem 0;
  display: flex;
  gap: 0.4rem;
}
.recipe-ingredient-list li::before { content: '•'; color: var(--accent); flex-shrink: 0; }

.recipe-step-list {
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.recipe-step-list li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Recipe detail header image ─────────────────────────────────────────────── */
.rd-header-img {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
}

/* ── Recipe form (dialog) ───────────────────────────────────────────────────── */
.recipe-form-ingredients,
.recipe-form-steps {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.recipe-ing-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.recipe-ing-row input[type="text"] { flex: 2; }
.recipe-ing-row input[type="number"] { width: 64px; flex: 0 0 64px; }
.recipe-ing-row .ing-unit { flex: 1; }

.recipe-step-row {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
}
.recipe-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.5rem;
}
.recipe-step-row textarea {
  flex: 1;
  resize: vertical;
  min-height: 52px;
}

.recipe-row-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem 0.3rem;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 0.45rem;
}
.recipe-row-remove:hover { background: rgba(255,92,92,0.12); color: #FF8A8A; }

/* ── Vacation Banner ────────────────────────────────────────────────────────── */
.vacation-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 1.25rem;
  background: linear-gradient(90deg, #2A1F5A, #1E2A5A);
  color: #B8B0FF;
  font-size: 0.825rem;
  border-bottom: 1px solid #3A308A;
  flex-shrink: 0;
}
html[data-theme="light"] .vacation-banner {
  background: linear-gradient(90deg, #EAE8FF, #E0DDFF);
  color: #4A40AA;
  border-bottom-color: #C5BFEE;
}
.vacation-banner .btn { color: #B8B0FF; margin-left: auto; }
html[data-theme="light"] .vacation-banner .btn { color: #4A40AA; }
.vacation-banner--hidden { height: 0 !important; padding: 0 !important; overflow: hidden !important; border: none !important; }

/* ── Recurring task badge ────────────────────────────────────────────────────── */
.recurrence-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-pill);
  background: rgba(108,99,255,0.15);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Board tiles (shared base for countdown + poll) ─────────────────────────── */
.board-tile {
  position: absolute;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
  transition: box-shadow 0.15s;
  min-width: 190px;
}
.board-tile:hover   { box-shadow: 0 8px 32px rgba(108,99,255,0.22); }
.board-tile.dragging { z-index: 1000; }

.tile-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.tile-header:active { cursor: grabbing; }
.tile-drag-handle { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }

.tile-edit-btn,
.tile-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
  color: var(--text-muted);
  line-height: 1;
  transition: background 0.1s;
}
.tile-colour-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tile-colour-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  padding: 0;
}
.tile-colour-swatch:hover   { transform: scale(1.15); }
.tile-colour-swatch.selected { border-color: var(--accent); transform: scale(1.1); }

.tile-edit-btn   { margin-left: auto; }
.tile-edit-btn:hover   { background: var(--bg-hover); color: var(--text-primary); }
.tile-delete-btn:hover { background: rgba(255,92,92,0.15); color: #FF8A8A; }

/* ── Countdown tile ──────────────────────────────────────────────────────────── */
.countdown-tile-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.countdown-tile-body {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}
.countdown-number {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.countdown-unit {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.countdown-today {
  font-size: 1rem;
  font-weight: 700;
  color: var(--success);
}
.countdown-past {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Poll tile ───────────────────────────────────────────────────────────────── */
.poll-tile-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.poll-tile-body {
  padding: 0.6rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.poll-question {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.poll-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-family: var(--font);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-align: left;
}
.poll-option:hover  { background: var(--bg-hover); border-color: var(--accent); }
.poll-option.voted  { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); font-weight: 600; }

.poll-pct {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.poll-bar {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.1rem 0;
}
.poll-bar-a {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.poll-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

.poll-reset-btn {
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  align-self: center;
  margin-top: 0.1rem;
  opacity: 0.6;
}
.poll-reset-btn:hover { opacity: 1; }

/* ── Task progress ───────────────────────────────────────────────────────────── */
.task-progress-pct {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 0.5rem;
  opacity: 0.85;
}
.task-progress-bar-wrap {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin: 5px 0 3px;
  overflow: hidden;
}
.task-progress-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.task-progress-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 3px;
}

/* ── Grocery total bar ───────────────────────────────────────────────────────── */
.grocery-total-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.grocery-total-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.grocery-total-amount {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}
.grocery-total-got {
  font-size: 0.75rem;
  color: var(--success);
  margin-left: auto;
}

/* ── Grocery item price ──────────────────────────────────────────────────────── */
.grocery-item-price {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 40px;
  text-align: right;
  margin-right: 0.25rem;
}

/* ── Grocery list search ─────────────────────────────────────────────────────── */
.grocery-list-search-row {
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.grocery-list-search-row input { width: 100%; }

/* ── Notification toasts ────────────────────────────────────────────────────── */
.toast-notif {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  cursor: default;
}
.toast-notif .notif-title { font-weight: 600; color: var(--text-primary); margin-bottom: 0.15rem; }
.toast-notif .notif-body  { color: var(--text-secondary); font-size: 0.8rem; }
.toast-notif.notif-1hr    { border-left-color: var(--warning); }
.toast-notif.notif-task   { border-left-color: var(--priority-medium); }
.toast-notif .notif-close {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.1rem 0.25rem;
}
.toast-notif { position: relative; }

/* ── Watchlist ───────────────────────────────────────────────────────────────── */
#tab-watchlist { flex-direction: column; overflow: hidden; }

.wl-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.wl-filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.wl-search-input { width: 180px; }

.wl-grid {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wl-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.875rem;
  transition: background 0.12s;
}
.wl-card:hover { background: var(--bg-hover); }
.wl-card.wl-watched { opacity: 0.5; }
.wl-card.wl-watched .wl-card-title { text-decoration: line-through; }

.wl-card-icon { font-size: 1.6rem; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.wl-card-body { flex: 1; min-width: 0; }
.wl-card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }

.wl-card-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.2rem; }

.wl-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--accent-dim);
  color: var(--accent);
}
.wl-platform {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
}
.wl-notes { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 0.2rem; }

/* Poster on card */
.wl-card-poster {
  width: 56px;
  min-width: 56px;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.wl-card-poster-placeholder {
  width: 56px;
  min-width: 56px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  flex-shrink: 0;
}

/* Genre tags on card */
.wl-genres { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.wl-genre-tag {
  font-size: 0.68rem; font-weight: 500;
  background: var(--bg-elevated); color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 1px 7px; border-radius: var(--radius-pill);
}

/* Synopsis on card */
.wl-synopsis {
  font-size: 0.78rem; color: var(--text-secondary);
  line-height: 1.5; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* Creators line on card */
.wl-creators {
  font-size: 0.73rem; color: var(--text-muted);
  margin-top: 3px;
}

/* Meta pills (year, runtime, content rating) */
.wl-meta-pill {
  font-size: 0.68rem; font-weight: 600;
  background: var(--bg-elevated); color: var(--text-muted);
  padding: 1px 7px; border-radius: var(--radius-pill);
}

/* Episode title on card */
.wl-ep-title {
  display: block;
  font-size: 0.73rem; color: var(--text-muted); font-style: italic;
  margin: 2px 0 3px;
}

/* ── IMDB import dialog ── */
.imdb-import-dialog { max-width: 640px; }

.imdb-preview-card {
  display: flex; gap: 16px;
  padding: 16px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.imdb-preview-poster-wrap { flex-shrink: 0; }
.imdb-preview-poster {
  width: 100px; height: 148px;
  object-fit: cover; border-radius: 8px;
  display: none;
}
.imdb-preview-poster-placeholder {
  width: 100px; height: 148px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; display: flex;
  align-items: center; justify-content: center;
  font-size: 2.4rem;
}
.imdb-preview-meta { flex: 1; min-width: 0; }
.imdb-preview-title {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 8px;
  line-height: 1.2;
}
.imdb-preview-badges {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px;
}
.imdb-preview-synopsis {
  font-size: 0.82rem; color: var(--text-secondary);
  line-height: 1.55; margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.imdb-preview-cast {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.7;
}
.wl-creators-label { font-weight: 600; color: var(--text-secondary); }

/* Seasons accordion */
.imdb-preview-seasons-wrap {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 12px;
}
.imdb-seasons-header {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.imdb-season-details { border-bottom: 1px solid var(--border); }
.imdb-season-details:last-child { border-bottom: none; }
.imdb-season-summary {
  list-style: none; cursor: pointer;
  padding: 9px 14px; font-size: 0.85rem; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
.imdb-season-summary::-webkit-details-marker { display: none; }
.imdb-season-summary::after {
  content: '›'; font-size: 1rem; color: var(--text-muted);
  transition: transform 0.15s;
}
details[open] .imdb-season-summary::after { transform: rotate(90deg); }
.imdb-season-summary:hover { background: var(--bg-hover); }
.imdb-season-ep-count {
  font-size: 0.72rem; font-weight: 500; color: var(--text-muted);
  background: var(--bg-surface); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: var(--radius-pill);
}
.imdb-episode-list { padding: 4px 0 8px; }
.imdb-episode-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px; font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.imdb-episode-row:last-child { border-bottom: none; }
.imdb-ep-num {
  flex-shrink: 0; width: 28px;
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
}
.imdb-ep-title { flex: 1; min-width: 0; color: var(--text-primary); }
.imdb-ep-runtime { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.imdb-ep-rating  { font-size: 0.7rem; color: #c9a900; white-space: nowrap; }
.imdb-ep-aired   { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }

/* IMDB chip on card */
.wl-imdb-chip {
  font-size: 0.72rem; font-weight: 700;
  background: rgba(245,197,24,.15); color: #c9a900;
  padding: 0.1rem 0.45rem; border-radius: var(--radius-pill);
}
html[data-theme="light"] .wl-imdb-chip { background: rgba(245,197,24,.2); color: #9a7a00; }

.wl-imdb-link {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted); text-decoration: none;
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 0.08rem 0.4rem; border-radius: var(--radius-pill);
  transition: color .12s, border-color .12s;
}
.wl-imdb-link:hover { color: var(--accent); border-color: var(--accent); }

/* Episode progress on card */
.wl-progress-chip {
  display: inline-block;
  font-size: 0.73rem; font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.15rem 0.5rem; border-radius: var(--radius-pill);
  margin-top: 0.3rem; margin-bottom: 0.25rem;
}
.wl-ep-bar {
  height: 3px; background: var(--bg-elevated);
  border-radius: 999px; overflow: hidden;
  margin-top: 2px; max-width: 160px;
}
.wl-ep-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* IMDB input row in dialog */
.wl-imdb-input-row {
  display: flex; gap: 0.5rem; align-items: center;
}
.wl-imdb-input-row input { flex: 1; }

#wl-imdb-status { margin-top: 6px; min-height: 20px; }
.wl-imdb-badge {
  display: inline-block; font-size: 0.8rem; font-weight: 700;
  background: rgba(245,197,24,.15); color: #c9a900;
  padding: 3px 10px; border-radius: var(--radius-pill);
}
html[data-theme="light"] .wl-imdb-badge { color: #9a7a00; }
.wl-imdb-badge--dim { background: var(--bg-elevated); color: var(--text-muted); }
.wl-imdb-fetching { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }
.wl-imdb-error    { font-size: 0.8rem; color: var(--danger); }

/* Progress section in dialog */
.wl-progress-section {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 0.875rem;
  margin-bottom: 0.75rem;
}
.wl-progress-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent); margin-bottom: 0.6rem;
}

.wl-card-actions { display: flex; flex-direction: column; gap: 0.3rem; flex-shrink: 0; }
.wl-watched-btn, .wl-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.15rem;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.1s;
}
.wl-watched-btn:hover, .wl-edit-btn:hover { background: var(--bg-elevated); }

/* ── Documents ───────────────────────────────────────────────────────────────── */
#tab-documents { flex-direction: column; overflow: hidden; }

.docs-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.docs-filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.docs-search-input { width: 180px; }

.docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.doc-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--bg-hover); }

.doc-row-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; line-height: 1; }
.doc-row-body { flex: 1; min-width: 0; }
.doc-row-name { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.doc-row-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

.doc-cat-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.doc-value {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
  background: var(--bg-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.doc-expiry-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
}
.doc-ok           { background: rgba(67,191,142,0.12); color: var(--success); }
.doc-expiring     { background: rgba(245,166,35,0.15); color: var(--warning); }
.doc-expiring-soon{ background: rgba(255,92,92,0.15);  color: var(--danger); }
.doc-expired      { background: rgba(255,92,92,0.2);   color: var(--danger); font-weight: 700; }

.doc-notes { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 0.25rem; }
.doc-edit-btn { flex-shrink: 0; margin-top: 2px; }

/* ── Star rating ─────────────────────────────────────────────────────────────── */
.star-rating { display: flex; gap: 0.15rem; }
.star-btn {
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  color: var(--border); line-height: 1; padding: 0.1rem 0.05rem;
  transition: color 0.1s; font-family: var(--font);
}
.star-btn.lit { color: var(--warning); }
.star-display { display: inline-flex; gap: 0.05rem; font-size: 0.85rem; vertical-align: middle; }
.star-display span { color: var(--border); }
.star-display span.filled { color: var(--warning); }

/* ── Cook mode overlay ───────────────────────────────────────────────────────── */
#cook-mode-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg-base);
  display: flex; flex-direction: column;
}
.cook-mode-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 1rem;
  flex-shrink: 0;
}
#cook-step-counter { color: var(--text-muted); font-size: 0.875rem; font-weight: 400; }
.cook-mode-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2rem 3rem; overflow-y: auto;
}
.cook-step-text {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  line-height: 1.7;
  max-width: 700px;
  text-align: center;
  white-space: pre-wrap;
}
.cook-mode-footer {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.cook-mode-footer .btn { min-height: 48px; padding: 0.6rem 2rem; font-size: 1rem; }

/* ── Calendar popover ────────────────────────────────────────────────────────── */
#cal-popover {
  position: fixed; z-index: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.75rem;
  min-width: 180px; max-width: 260px;
}
#cal-popover h5 {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem;
}
.cal-popover-item { display: flex; align-items: flex-start; gap: 0.4rem; padding: 0.2rem 0; }
.cal-popover-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.cal-popover-text { font-size: 0.8rem; line-height: 1.35; }
.cal-popover-close {
  position: absolute; top: 0.4rem; right: 0.5rem;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.85rem;
}

/* ── Task tags ───────────────────────────────────────────────────────────────── */
.task-tag {
  font-size: 0.65rem; font-weight: 600; padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill); background: var(--accent-dim); color: var(--accent);
}
.task-subtask-count { font-size: 0.72rem; color: var(--text-muted); }

/* ── Subtask dialog rows ─────────────────────────────────────────────────────── */
.subtask-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.35rem; border-radius: var(--radius); }
.subtask-row:hover { background: var(--bg-elevated); }
.subtask-row input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.subtask-row-label { flex: 1; font-size: 0.875rem; }
.subtask-row-del { background: none; border: none; color: var(--danger); cursor: pointer; opacity: 0; font-size: 0.8rem; padding: 0 0.2rem; }
.subtask-row:hover .subtask-row-del { opacity: 1; }

/* ── Link tile ───────────────────────────────────────────────────────────────── */
.link-tile {
  position: absolute; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-width: 200px; width: 220px;
}
.link-tile-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.65rem; background: var(--overlay-header);
  cursor: move; font-size: 0.78rem; font-weight: 600;
  user-select: none;
}
.link-tile-edit-btn {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.8rem; padding: 0 0.2rem;
  opacity: 0;
}
.link-tile-header:hover .link-tile-edit-btn { opacity: 1; }
.link-tile-body { padding: 0.6rem 0.75rem; }
.link-tile-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.15rem; }
.link-tile-url { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.25rem; word-break: break-all; }
.link-tile-notes { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.link-tile-open {
  display: inline-block; font-size: 0.78rem; color: var(--accent);
  text-decoration: none; font-weight: 500;
}
.link-tile-open:hover { text-decoration: underline; }

/* ── Recipe scaling control ──────────────────────────────────────────────────── */
.recipe-servings-ctrl { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-secondary); }
.recipe-servings-ctrl button {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elevated);
  cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text-primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.recipe-servings-ctrl button:hover { background: var(--bg-hover); }
.recipe-servings-value { font-weight: 700; color: var(--accent); min-width: 22px; text-align: center; }
.scaled-qty { color: var(--accent); font-weight: 600; }

/* ── Grocery template rows ───────────────────────────────────────────────────── */
.template-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.6rem; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 0.35rem;
}
.template-row-name { flex: 1; font-weight: 500; font-size: 0.875rem; }
.template-row-count { font-size: 0.75rem; color: var(--text-muted); }

/* ── Trips ───────────────────────────────────────────────────────────────────── */
.trips-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.trip-list-panel {
  width: 310px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.trip-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  flex-shrink: 0;
}
.trip-panel-header h3 { font-size: 1rem; font-weight: 600; }

.trip-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.trip-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.trip-card:hover { background: var(--bg-hover); }
.trip-card.active { background: var(--accent-dim); border-color: var(--accent); }

.trip-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}
.trip-card-emoji { font-size: 1.15rem; flex-shrink: 0; }
.trip-card-name  { font-weight: 600; font-size: 0.9rem; flex: 1; }

.trip-status-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.trip-status-planning  { background: var(--accent-dim);             color: var(--accent); }
.trip-status-booked    { background: rgba(67,191,142,0.15);         color: var(--success); }
.trip-status-ongoing   { background: rgba(245,166,35,0.15);         color: var(--warning); }
.trip-status-completed { background: var(--bg-elevated);            color: var(--text-muted); }

.trip-card-dates { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.trip-card-countdown { font-size: 0.78rem; font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; }

.trip-budget-bar-wrap { margin-top: 0.25rem; }
.trip-budget-bar-track {
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  height: 6px;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.trip-budget-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.3s;
}
.trip-budget-bar-label { font-size: 0.7rem; color: var(--text-muted); }

/* Detail panel */
.trip-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.trip-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 0.5rem;
  text-align: center;
}
.trip-detail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.trip-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.trip-detail-emoji { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.trip-detail-info  { flex: 1; min-width: 0; }
.trip-detail-name  { font-size: 1.15rem; font-weight: 700; }
.trip-detail-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.trip-detail-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* Inner section tabs */
.trip-section-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 0.75rem;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.trip-section-tabs::-webkit-scrollbar { display: none; }
.trip-section-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.trip-section-tab:hover { color: var(--text-primary); }
.trip-section-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.trip-section-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.25rem;
  min-height: 0;
}

/* Overview section */
.trip-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.trip-info-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.trip-info-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.trip-info-card-value { font-size: 0.95rem; font-weight: 600; }
.trip-info-card-value.big { font-size: 1.3rem; color: var(--accent); }

.trip-destinations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.trip-destinations-header h4 { font-size: 0.9rem; font-weight: 600; }

.trip-destination-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 0.3rem;
}
.trip-destination-place { flex: 1; font-weight: 500; font-size: 0.875rem; }
.trip-destination-dates { font-size: 0.76rem; color: var(--text-secondary); }

/* Budget section */
.trip-savings-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.trip-savings-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.trip-savings-label { font-weight: 600; font-size: 0.9rem; }
.trip-savings-pct { font-size: 0.9rem; color: var(--accent); font-weight: 700; }
.trip-savings-amounts { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.3rem; }
.trip-savings-edit-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.trip-savings-edit-row label { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; }

.trip-budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin-bottom: 0.5rem;
}
.trip-budget-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.trip-budget-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.trip-budget-table tr:last-child td { border-bottom: none; }
.trip-budget-total-row td { font-weight: 600; background: var(--bg-elevated); }
.trip-budget-paid { color: var(--success); }

/* Checklist (tasks, packing) */
.trip-checklist-group { margin-bottom: 0.85rem; }
.trip-checklist-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.trip-checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  margin-bottom: 0.15rem;
}
.trip-checklist-item:hover { background: var(--bg-elevated); }
.trip-checklist-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; width: 15px; height: 15px; }
.trip-checklist-label { flex: 1; font-size: 0.875rem; }
.trip-checklist-label.done { text-decoration: line-through; color: var(--text-muted); }
.trip-checklist-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.trip-checklist-item:hover .trip-checklist-delete { opacity: 1; }

.trip-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.trip-add-row input  { flex: 1 1 120px; min-width: 0; }
.trip-add-row select { flex-shrink: 1; }

/* Itinerary */
.trip-itinerary-day { margin-bottom: 1rem; }
.trip-itinerary-day-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.trip-itinerary-entry {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 0.3rem;
}
.trip-itinerary-time { font-size: 0.76rem; font-weight: 700; color: var(--accent); min-width: 40px; flex-shrink: 0; margin-top: 2px; }
.trip-itinerary-label { font-size: 0.875rem; font-weight: 500; }
.trip-itinerary-notes { font-size: 0.76rem; color: var(--text-secondary); }
.trip-itinerary-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0.3rem;
  flex-shrink: 0;
}
.trip-itinerary-entry:hover .trip-itinerary-delete { opacity: 1; }

/* Bookings */
.trip-booking-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
}
.trip-booking-info { flex: 1; }
.trip-booking-label { font-weight: 500; font-size: 0.875rem; }
.trip-booking-meta { font-size: 0.76rem; color: var(--text-secondary); margin-top: 0.15rem; }
.trip-booking-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0.3rem;
  flex-shrink: 0;
}
.trip-booking-row:hover .trip-booking-delete { opacity: 1; }

/* Notes section */
.trip-notes-area {
  width: 100%;
  min-height: 180px;
  resize: vertical;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 599;
}
#sidebar-overlay.active { display: block; }

/* ── App shell height — use dvh when supported to handle mobile address bar ─── */
@supports (height: 100dvh) {
  .app-shell { height: 100dvh; }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar — slides in from right as overlay */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 600;
    box-shadow: var(--shadow);
    width: 88vw;
    max-width: 320px;
    min-width: 0;
  }
  .sidebar.collapsed { width: 0; }

  /* Header — keep compact */
  .app-header { padding: 0 0.75rem; height: 52px; }
  .header-logo { height: 34px; }
  .current-user { display: none; }
  .header-actions { gap: 0.4rem; }
  .header-actions .btn { padding: 0.4rem 0.5rem; }

  /* Tab bar — horizontally scrollable, no wrap */
  .tab-bar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    gap: 0;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex-shrink: 0;
    padding: 0 0.85rem;
    font-size: 0.8rem;
    height: 44px;
  }
  .sidebar-toggle {
    flex-shrink: 0;
    margin-left: 0;
    border-radius: 0;
    height: 44px;
    font-size: 0.8rem;
  }

  /* Dialogs — nearly full screen */
  .app-dialog {
    max-width: calc(100vw - 1rem);
    width: calc(100vw - 1rem);
  }
  .app-dialog-wide { max-width: calc(100vw - 1rem); }
  .app-dialog-wide .dialog-form { max-height: 82vh; }
  .dialog-form { max-height: 82vh; overflow-y: auto; }

  /* Forms */
  .form-row { flex-direction: column; }

  /* Tasks */
  .tasks-header { gap: 0.5rem; flex-wrap: wrap; }
  .tasks-filters { flex-wrap: wrap; }

  /* Calendar — smaller cells */
  #tab-calendar { padding: 0.75rem; }
  .cal-day { min-height: 62px; padding: 0.25rem; }
  .cal-day-number { font-size: 0.7rem; }
  .cal-event-chip { font-size: 0.6rem; padding: 0.08rem 0.2rem; }
  .calendar-header h2 { font-size: 1rem; min-width: 160px; }

  /* Board toolbar */
  .board-toolbar { flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.75rem; }

  /* Groceries — stacked panels */
  .groceries-layout { flex-direction: column; }
  .grocery-dict-panel { width: 100%; min-width: 0; border-top: 1px solid var(--border); border-right: none; min-height: 260px; }
  .grocery-list-panel { flex: none; max-height: 55dvh; }
  .grocery-add-inputs { flex-wrap: wrap; gap: 0.35rem; }
  .grocery-add-inputs > input { flex: 1 1 60px; min-width: 52px; }

  /* Recipes — stacked panels; whole layout scrolls as one page */
  .recipes-layout { flex-direction: column; overflow-y: auto; height: 100%; -webkit-overflow-scrolling: touch; }
  .recipe-grid-panel { flex: none; max-height: 45dvh; border-right: none; border-bottom: 1px solid var(--border); }
  .recipe-detail-panel { width: 100%; min-width: unset; border-top: none; flex: none; overflow: visible; }
  .recipe-detail-content { overflow: visible; }
  .recipe-detail-body { overflow: visible; flex: none; }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  /* Cook mode */
  .cook-mode-body { padding: 1.5rem 1.25rem; }
  .cook-step-text { font-size: 1.1rem; }
  .cook-mode-footer .btn { padding: 0.5rem 1rem; }
  .cook-mode-header { padding: 0.75rem 1rem; }

  /* Board search */
  #board-search { width: 120px; }

  /* Trips — stacked panels; whole layout scrolls as one page */
  .trips-layout { flex-direction: column; overflow-y: auto; height: 100%; -webkit-overflow-scrolling: touch; }
  .trip-list-panel { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); flex: none; max-height: 45dvh; }
  .trip-detail-panel { width: 100%; min-width: 0; flex: none; overflow: visible; }
  .trip-detail-content { overflow: visible; }
  .trip-overview-grid { grid-template-columns: 1fr 1fr; }

  /* Sticky notes — narrower default width on mobile */
  .sticky-note { width: 200px !important; }

  /* Touch-friendly tap targets */
  .btn-sm { min-height: 36px; padding: 0.4rem 0.75rem; }
  .tab-btn, .sidebar-toggle { min-height: 44px; }
  .task-checkbox, .grocery-item-check { width: 22px; height: 22px; }
  .dict-card { min-height: 80px; }
  .recipe-card-body { padding: 0.5rem; }
}

/* Extra-small phones */
@media (max-width: 380px) {
  .tab-btn { padding: 0 0.6rem; font-size: 0.75rem; }
  .header-logo { height: 30px; }
  .cal-day { min-height: 52px; }
}

/* ── Board note search states ─────────────────────────────────────────────── */
.sticky-note.note-search-hidden { opacity: 0.12; pointer-events: none; }
.sticky-note.note-search-match  { outline: 2px solid var(--accent); box-shadow: 0 0 0 4px rgba(108,99,255,0.18); }

/* ── Document contact line ────────────────────────────────────────────────── */
.doc-contact { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.2rem; }

/* ── Task subtask done strikethrough ─────────────────────────────────────── */
.subtask-row-label.done { text-decoration: line-through; color: var(--text-muted); }
.task-tags-row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }

/* ── Trip savings per-person row ─────────────────────────────────────────── */
.trip-savings-edit-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; flex-wrap: wrap; }
