@import url("./rose-pine.css");

/* ==========================================================================
   Base
   ========================================================================== */

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

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--rp-base);
  color: var(--rp-text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:disabled { cursor: default; opacity: 0.6; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--rp-overlay);
  color: var(--rp-gold);
  font: 600 0.72rem/1.6 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon svg { display: block; }
.icon-brandLogo { color: var(--rp-pine); }
.icon-today { color: var(--rp-foam); }
.icon-tomorrow { color: var(--rp-gold); }
.icon-weekend { color: var(--rp-iris); }
.icon-nextWeek { color: var(--accent); }
.icon-noDate { color: var(--danger); }

* { scrollbar-width: thin; scrollbar-color: var(--rp-hl-high) transparent; }

/* ==========================================================================
   Controls
   ========================================================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--rp-subtle);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.button:hover { background: var(--rp-overlay); color: var(--rp-text); }
.button.primary, .button.danger { border-color: transparent; color: var(--on-accent); font-weight: 600; }
.button.primary { background: var(--accent); }
.button.danger { background: var(--danger); }
.button.primary:hover:not(:disabled), .button.danger:hover:not(:disabled) { filter: brightness(1.08); }
.button.wide { width: 100%; height: 38px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 6px;
  color: var(--rp-muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: background-color 0.15s, color 0.15s;
}
.icon-button:hover, .icon-button.is-open { background: var(--rp-overlay); color: var(--rp-text); }

.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--rp-overlay);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--rp-muted); }
select.input { cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  color: var(--rp-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app { display: flex; flex: 1; min-height: 0; }

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.main-header, .week-strip, .tasks {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding-inline: 40px;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: flex;
  flex-direction: column;
  width: 272px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--rp-surface);
  transition: border-color 0.15s;
}
.sidebar.keyboard { border-right-color: var(--accent); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 8px; }

.nav-item, .project-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--rp-subtle);
  font-size: 0.86rem;
  font-weight: 500;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.nav-item:hover, .project-row:hover { background: var(--rp-overlay); color: var(--rp-text); }
.nav-item.active, .project-row.active { background: var(--rp-overlay); color: var(--accent); font-weight: 600; }
.nav-item.cursor, .project-row.cursor { box-shadow: inset 3px 0 0 var(--accent); background: var(--rp-overlay); color: var(--rp-text); }
.nav-label, .project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { color: var(--rp-muted); font-size: 0.75rem; }

.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 2px 16px;
  color: var(--rp-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sidebar-section .icon-button { width: 28px; height: 28px; }

.project-tree { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.project-row { padding-right: 2px; }
.project-icon { width: 16px; color: var(--rp-muted); }
.project-more { width: 26px; height: 26px; opacity: 0; }
.project-row:hover .project-more, .project-more.is-open { opacity: 1; }
@media (hover: none) { .project-more { opacity: 0.7; } }
.project-children { margin-left: 15px; padding-left: 4px; border-left: 1px dashed var(--border); }
.sidebar-empty { padding: 6px 10px; color: var(--rp-muted); font-size: 0.82rem; }

.status-dot { width: 16px; display: inline-flex; justify-content: center; flex-shrink: 0; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-dot.overdue { color: var(--rp-love); }
.status-dot.today { color: var(--rp-gold); }

.sidebar-backdrop { display: none; }

/* ==========================================================================
   Header and week strip
   ========================================================================== */

.main-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 28px;
  padding-bottom: 12px;
  background: var(--rp-base);
}
.menu-toggle { display: none; }
.view-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-button { background: var(--rp-surface); }

.week-strip { display: flex; gap: 8px; padding-bottom: 16px; overflow-x: auto; }
.week-day {
  display: flex;
  flex: 1 0 56px;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background-color 0.15s, border-color 0.15s;
}
.week-day:hover { background: var(--rp-overlay); }
.week-day.today { border-color: var(--accent); }
.week-day-name { color: var(--rp-muted); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.week-day-number { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.week-day-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: 0; }
.week-day.busy .week-day-dot { opacity: 1; }

/* ==========================================================================
   Task lists
   ========================================================================== */

.tasks { padding-top: 4px; padding-bottom: 80px; }
.task-groups { display: flex; flex-direction: column; gap: 28px; }
.task-group { display: flex; flex-direction: column; border-radius: 10px; }

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
.group-header[data-drag] { cursor: grab; }
.group-title { font-size: 0.95rem; font-weight: 600; }
.group-count { flex: 1; color: var(--rp-muted); font-size: 0.75rem; }
.task-group.overdue .group-title { color: var(--rp-love); }
.task-group.today .group-title { color: var(--accent); }
.group-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.group-action:hover { background: var(--rp-overlay); }
.group-action .icon svg { width: 14px; height: 14px; }

.task-list { display: flex; flex-direction: column; gap: 2px; min-height: 6px; border-radius: 8px; }
.empty-list { padding: 10px 8px; color: var(--rp-muted); font-size: 0.85rem; }

.task-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 40px;
  margin: 0 -8px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: background-color 0.12s;
}
.task-row:hover { background: var(--rp-surface); }
.task-row.cursor { background: var(--rp-overlay); box-shadow: inset 3px 0 0 var(--accent); }
.task-row.selected { background: color-mix(in srgb, var(--rp-iris) 16%, transparent); box-shadow: inset 3px 0 0 var(--rp-iris); }

.task-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid var(--rp-muted);
  border-radius: 50%;
  color: transparent;
  transition: background-color 0.15s, color 0.15s;
}
.task-check::after { content: ""; position: absolute; inset: -10px; } /* larger touch target */
.task-check:hover { color: currentColor; }
.task-check .icon svg { width: 10px; height: 10px; }
.p1 > .task-check, .task-check.p1 { border-color: var(--rp-love); }
.p2 > .task-check, .task-check.p2 { border-color: var(--rp-gold); }
.p3 > .task-check, .task-check.p3 { border-color: var(--rp-foam); }
.p1 > .task-check:hover, .task-check.p1:hover { color: var(--rp-love); background: color-mix(in srgb, var(--rp-love) 15%, transparent); }
.p2 > .task-check:hover, .task-check.p2:hover { color: var(--rp-gold); background: color-mix(in srgb, var(--rp-gold) 15%, transparent); }
.p3 > .task-check:hover, .task-check.p3:hover { color: var(--rp-foam); background: color-mix(in srgb, var(--rp-foam) 15%, transparent); }

.task-body { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.task-title { font-size: 0.9rem; line-height: 1.4; overflow-wrap: anywhere; }
.task-description {
  display: -webkit-box;
  overflow: hidden;
  color: var(--rp-muted);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 1px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--rp-subtle) 13%, transparent);
  color: var(--rp-subtle);
  font-size: 0.72rem;
  line-height: 1.6;
  text-decoration: none;
}
.badge .icon svg { width: 11px; height: 11px; }
.badge.due.overdue { color: var(--rp-love); background: color-mix(in srgb, var(--rp-love) 15%, transparent); }
.badge.due.today { color: var(--rp-gold); background: color-mix(in srgb, var(--rp-gold) 15%, transparent); }
.badge.recurrence { color: var(--rp-iris); }
.badge.location { max-width: 260px; color: var(--rp-foam); }
.badge.location:hover { background: var(--rp-hl-med); }
.badge.project { max-width: 200px; }
.badge-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.subtasks { display: flex; flex-direction: column; gap: 2px; margin-left: 20px; padding-left: 8px; border-left: 1px dashed var(--border); }

.add-task {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px -8px 0;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--rp-muted);
  font-size: 0.86rem;
  text-align: left;
  transition: color 0.15s, background-color 0.15s;
}
.add-task:hover { background: var(--rp-surface); color: var(--accent); }

/* ==========================================================================
   Composer
   ========================================================================== */

.composer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--rp-surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.composer-title, .composer-description {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
}
.composer-title { font-size: 0.95rem; font-weight: 600; }
.composer-description { min-height: 22px; color: var(--rp-subtle); font-size: 0.85rem; resize: none; }
.composer-title::placeholder, .composer-description::placeholder { color: var(--rp-muted); font-weight: 400; }
.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.composer-chips, .composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.composer-actions { margin-left: auto; }
.composer-submit-icon { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--rp-overlay);
  color: var(--rp-subtle);
  font-size: 0.78rem;
  transition: background-color 0.15s, color 0.15s;
}
.chip:hover, .chip.is-open { background: var(--rp-hl-med); color: var(--rp-text); }
.chip.has-value { color: var(--rp-text); }
.chip.p1 { color: var(--rp-love); }
.chip.p2 { color: var(--rp-gold); }
.chip.p3 { color: var(--rp-foam); }
.chip-text { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.token-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.token-chip {
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--rp-overlay);
  color: var(--rp-text);
  font-size: 0.72rem;
  line-height: 1.6;
}
.token-chip:hover { text-decoration: line-through; opacity: 0.75; }
.token-chip.date { color: var(--rp-gold); background: color-mix(in srgb, var(--rp-gold) 15%, transparent); }
.token-chip.recurrence { color: var(--rp-iris); background: color-mix(in srgb, var(--rp-iris) 15%, transparent); }
.token-chip.location { color: var(--rp-foam); background: color-mix(in srgb, var(--rp-foam) 15%, transparent); }
.token-chip.p1 { color: var(--rp-love); background: color-mix(in srgb, var(--rp-love) 15%, transparent); }
.token-chip.p2 { color: var(--rp-gold); background: color-mix(in srgb, var(--rp-gold) 15%, transparent); }
.token-chip.p3 { color: var(--rp-foam); background: color-mix(in srgb, var(--rp-foam) 15%, transparent); }

/* ==========================================================================
   Popovers and menus
   ========================================================================== */

.popover {
  position: fixed;
  z-index: 1500;
  max-width: min(340px, calc(100vw - 16px));
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--rp-surface);
  box-shadow: var(--shadow);
}
.popover.scrollable { max-height: 320px; }
.sheet-handle, .sheet-title { display: none; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 1400; background: var(--backdrop); }

.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--rp-text);
  font-size: 0.84rem;
  text-align: left;
  transition: background-color 0.12s;
}
.menu-item:hover { background: var(--rp-overlay); }
.menu-item.selected { color: var(--accent); font-weight: 600; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.menu-item.p1 .icon { color: var(--rp-love); }
.menu-item.p2 .icon { color: var(--rp-gold); }
.menu-item.p3 .icon { color: var(--rp-foam); }
.menu-item > .icon { color: var(--rp-subtle); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { color: var(--rp-muted); font-size: 0.74rem; }
.menu-separator { height: 1px; margin: 4px 2px; background: var(--border); }

.popover-form { display: flex; flex-direction: column; gap: 8px; padding: 6px 4px 4px; }
.popover-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Date picker */
.datepicker { display: flex; flex-direction: column; gap: 6px; width: 272px; max-width: 100%; }
.datepicker > .input { margin: 2px 0 0; }
.datepicker-hint { min-height: 1em; padding: 0 4px; color: var(--rp-muted); font-size: 0.74rem; }
.datepicker-hint:empty { display: none; }
.datepicker > .menu + .calendar, .datepicker-time + .menu { padding-top: 6px; border-top: 1px solid var(--border); }
.datepicker-time { display: flex; align-items: center; gap: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.datepicker-time > .input { flex: 1; min-width: 0; }
.calendar-header { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px 6px; }
.calendar-title { font-size: 0.84rem; font-weight: 600; }
.calendar-nav { display: flex; }
.calendar-nav .icon-button { width: 28px; height: 28px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-weekday { color: var(--rp-muted); font-size: 0.68rem; font-weight: 600; text-align: center; }
.calendar-day {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 1px solid transparent;
  border-radius: 50%;
  font-size: 0.78rem;
  transition: background-color 0.12s;
}
.calendar-day:hover { background: var(--rp-overlay); }
.calendar-day.outside { color: var(--rp-muted); opacity: 0.5; }
.calendar-day.today { border-color: var(--accent); }
.calendar-day.selected { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-overlay.open { opacity: 1; }

.modal {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: 88dvh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--rp-surface);
  box-shadow: var(--shadow);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease;
}
.modal-overlay.open .modal { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 14px 12px 20px; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { display: flex; flex-direction: column; gap: 14px; min-height: 0; padding: 0 20px 18px; overflow-y: auto; }
.modal-header + .modal-body { padding-top: 2px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.dialog-message { color: var(--rp-subtle); font-size: 0.9rem; }
.modal.help { width: min(680px, 100%); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
.help-grid h3 { margin: 10px 0 4px; }
.help-grid h3:first-child { margin-top: 0; }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 0.84rem; }
.help-keys { display: flex; gap: 4px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-error {
  padding: 8px 12px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 0.84rem;
}

/* Picker (search, move to…) */
.modal.picker { width: min(600px, 100%); align-self: flex-start; margin-top: 10dvh; }
.modal.picker .modal-body { gap: 0; padding: 0; }
.picker-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--rp-muted); }
.picker-input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--rp-text); font-size: 1rem; outline: none; }
.picker-list { display: flex; flex-direction: column; gap: 1px; max-height: 55dvh; padding: 6px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 6px; text-align: left; }
.picker-item > .icon { color: var(--rp-muted); }
.picker-item.active { background: var(--rp-overlay); box-shadow: inset 3px 0 0 var(--accent); }
.picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-badge { flex-shrink: 0; padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; color: var(--rp-muted); font-size: 0.72rem; }
.picker-empty { padding: 14px 12px; color: var(--rp-muted); font-size: 0.86rem; }

/* Quick add */
.modal.quick-add { width: min(600px, 100%); border: none; background: transparent; box-shadow: none; overflow: visible; }
.modal.quick-add .modal-body { padding: 0; overflow: visible; }
.modal.quick-add .composer { margin: 0; box-shadow: var(--shadow); }

/* ==========================================================================
   Task detail
   ========================================================================== */

.modal.detail-modal { width: min(880px, 100%); height: min(680px, 88dvh); }
.modal.detail-modal .modal-body { flex: 1; padding: 0; overflow: hidden; }
.detail { display: flex; flex-direction: column; height: 100%; }
.detail-header { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.spacer { flex: 1; }
.modal:focus { outline: none; }
.detail-place { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--rp-subtle); font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.detail-place .icon { color: var(--rp-muted); }
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 60%;
  height: 30px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--rp-subtle);
  font-size: 0.82rem;
}
.detail-back:hover { background: var(--rp-overlay); color: var(--rp-text); }
.detail-back-arrow { font-size: 1.2rem; line-height: 1; }
.detail-back-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-body { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) 280px; min-height: 0; }
.detail-main { display: flex; flex-direction: column; gap: 12px; padding: 22px 26px; overflow-y: auto; }
.detail-title-row { display: flex; align-items: flex-start; gap: 12px; }
.task-check.large { width: 22px; height: 22px; margin-top: 4px; }
.detail-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  outline: none;
  resize: none;
}
.detail-description {
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--rp-subtle);
  font-size: 0.88rem;
  line-height: 1.5;
  outline: none;
  resize: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.detail-description:hover { border-color: var(--border); }
.detail-description:focus { border-color: var(--border); background: var(--rp-overlay); color: var(--rp-text); }
.detail-title::placeholder, .detail-description::placeholder { color: var(--rp-muted); }
.detail-subtasks { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.task-list.compact .task-row { margin: 0; }

.detail-fields { display: flex; flex-direction: column; gap: 14px; padding: 20px 18px; overflow-y: auto; border-left: 1px solid var(--border); }
.field-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--rp-overlay);
  font-size: 0.84rem;
  text-align: left;
  transition: border-color 0.15s;
}
.field-button:hover, .field-button.is-open { border-color: var(--rp-muted); }
.field-button > .icon { color: var(--rp-subtle); }
.field-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-caret { color: var(--rp-muted); font-size: 0.7rem; }
.field-button.p1 > .icon, .field-button.due.overdue { color: var(--rp-love); }
.field-button.p2 > .icon, .field-button.due.today { color: var(--rp-gold); }
.field-button.p3 > .icon { color: var(--rp-foam); }
.field-button.due.overdue > .icon, .field-button.due.today > .icon { color: inherit; }
.maps-link { display: inline-flex; align-items: center; gap: 4px; color: var(--rp-foam); font-size: 0.8rem; text-decoration: none; }
.maps-link:hover { text-decoration: underline; }

/* ==========================================================================
   Drag and drop
   ========================================================================== */

.drag-ghost {
  position: fixed;
  z-index: 2000;
  margin: 0;
  pointer-events: none;
  background: var(--rp-surface);
  box-shadow: var(--shadow);
  opacity: 0.92;
}
.dragging { opacity: 0.35; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

.drop-before { box-shadow: inset 0 2px 0 var(--accent) !important; }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent) !important; }
.drop-inside, .drop-into { background: color-mix(in srgb, var(--accent) 14%, transparent) !important; outline: 1px dashed var(--accent); outline-offset: -1px; }
.task-row.drop-inside::after, .project-row.drop-inside::after {
  content: "↳ nest";
  position: absolute;
  right: 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}
.project-row { position: relative; }
.task-group.drop-before { box-shadow: 0 -3px 0 var(--accent) !important; }
.task-group.drop-after { box-shadow: 0 3px 0 var(--accent) !important; }

/* ==========================================================================
   Status bar, FAB, toast
   ========================================================================== */

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 28px;
  flex-shrink: 0;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--rp-surface);
  color: var(--rp-subtle);
  font-size: 0.76rem;
}
.status-left, .status-hints { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.status-hints { overflow: hidden; color: var(--rp-muted); }
.status-hints kbd + kbd { margin-left: 2px; }
.status-mode { padding: 0 6px; border-radius: 3px; background: var(--rp-overlay); color: var(--rp-gold); font-weight: 700; letter-spacing: 0.05em; }
.status-mode.insert { background: var(--rp-love); color: var(--on-accent); }
.status-mode.visual { background: var(--rp-iris); color: var(--on-accent); }
.status-mode.sidebar { color: var(--rp-foam); }
.status-position { font-family: "JetBrains Mono", ui-monospace, monospace; }
.status-help { color: inherit; font-size: inherit; }

.fab { display: none; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 44px;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--rp-surface);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.open { opacity: 1; pointer-events: auto; transform: none; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--rp-foam); }
.toast-message { flex: 1; min-width: 0; }
.toast-action {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--rp-iris);
  border-radius: 6px;
  color: var(--rp-iris);
  font-size: 0.8rem;
  font-weight: 700;
}
.toast-action:hover { background: var(--rp-iris); color: var(--on-accent); }

/* ==========================================================================
   Phones
   ========================================================================== */

@media (max-width: 768px) {
  /* 16px text keeps iOS Safari from zooming into focused fields. */
  .input, .composer-title, .composer-description, .detail-title, .detail-description, .picker-input { font-size: 16px; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 200;
    width: min(300px, 85vw);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.3, 1, 0.3, 1), box-shadow 0.25s;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 190;
    display: block;
    background: var(--backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .nav-item, .project-row { min-height: 40px; font-size: 0.92rem; }

  .main-header, .week-strip, .tasks { padding-inline: 14px; }
  .main-header { gap: 8px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .menu-toggle { display: inline-flex; margin-left: -6px; color: var(--rp-text); }
  .view-title { font-size: 1.35rem; }
  #sort-label, #add-section .label { display: none; }
  .header-button { width: 36px; padding: 0; }

  .week-day { flex-basis: 44px; }
  .task-row { min-height: 48px; padding: 10px 8px; }
  .task-check { width: 22px; height: 22px; margin-top: 0; }
  .add-task { display: none; }
  .tasks { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

  .statusbar { display: none; }
  .fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow);
  }
  .fab .icon svg { width: 24px; height: 24px; stroke-width: 2.5; }
  .fab:active { transform: scale(0.94); }
  body.has-modal .fab { display: none; }
  .toast { right: 16px; left: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: none; }

  /* Popovers become bottom sheets. */
  .popover.sheet {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 85dvh;
    padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    animation: sheet-up 0.25s cubic-bezier(0.3, 1, 0.3, 1);
  }
  .sheet .sheet-handle, .detail .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 2px;
    background: var(--rp-muted);
    opacity: 0.6;
  }
  .sheet .sheet-title { display: block; padding: 0 4px 10px; font-size: 1rem; font-weight: 700; }
  .sheet .menu-item { min-height: 46px; font-size: 0.95rem; }
  .sheet .datepicker { width: 100%; }
  .sheet .calendar-day { width: 40px; height: 40px; font-size: 0.9rem; }

  /* Bottom sheet dialogs */
  .modal-overlay { padding: 0; }
  .modal { width: min(440px, calc(100% - 24px)); }
  .modal.picker { width: calc(100% - 24px); margin-top: max(12px, env(safe-area-inset-top)); }
  .modal-overlay:has(.quick-add), .modal-overlay:has(.detail-modal) { align-items: flex-end; }
  .modal.quick-add, .modal.detail-modal {
    width: 100%;
    border-radius: 18px 18px 0 0;
    animation: sheet-up 0.25s cubic-bezier(0.3, 1, 0.3, 1);
  }
  .modal.quick-add .composer {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }
  .modal.quick-add .composer-cancel, .modal.quick-add .composer-submit-label { display: none; }
  .modal.quick-add .composer-submit { width: 38px; height: 38px; padding: 0; border-radius: 50%; }
  .modal.quick-add .composer-submit-icon { display: inline-flex; }

  .modal.detail-modal { height: 78dvh; transition: height 0.25s ease, transform 0.25s ease; }
  .modal.detail-modal.expanded { height: calc(100dvh - max(12px, env(safe-area-inset-top))); }
  .detail-header { position: relative; padding-top: 14px; }
  .detail .sheet-handle { position: absolute; top: 6px; left: 50%; margin: 0; transform: translateX(-50%); }
  .detail-body { display: block; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
  .detail-main { padding: 16px; overflow: visible; }
  .detail-fields { padding: 16px; overflow: visible; border-top: 1px solid var(--border); border-left: none; }
  .field-button { height: 42px; }
  .help-grid { grid-template-columns: 1fr; }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
