/* tasks — modern card UI on Dracula palette */

:root {
  color-scheme: dark;
  --bg:        #1e1f29;
  --bg-soft:   #282a36;
  --bg-card:   #2d2f3e;
  --bg-hover:  #353748;
  --bg-focus:  #44475a;
  --fg:        #f8f8f2;
  --fg-dim:    #d8d8d2;
  --fg-mute:   #a8acc0;
  --accent:    #8be9fd;
  --accent-2:  #bd93f9;
  --green:     #50fa7b;
  --yellow:    #f1fa8c;
  --orange:    #ffb86c;
  --red:       #ff5555;
  --pink:      #ff79c6;
  --border:    #44475a;
  --border-2:  #6272a4;
  --shadow:    0 1px 2px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.5);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow-x: hidden;       /* prevent horizontal scroll/jitter from off-screen elements */
  max-width: 100vw;
}

body {
  min-height: 100vh;
  padding: 12px 14px 80px;
  max-width: 720px;
  margin: 0 auto;
}

@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px));
  }
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  cursor: pointer;
  min-height: var(--tap);
  font-weight: 500;
  transition: background 80ms, border-color 80ms, transform 80ms;
}
button:hover { background: var(--bg-hover); border-color: var(--border-2); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--bg); }
button.danger { color: var(--red); border-color: var(--red); }
button.danger:hover { background: rgba(255,85,85,0.12); }
button.icon-btn {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

input[type="text"], input[type="search"], input[type="password"], textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--r-md);
  padding: 12px 14px;
  width: 100%;
  font-size: 16px;     /* prevents iOS zoom on focus */
  min-height: var(--tap);
  outline: none;
  transition: border-color 80ms;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ──── app bar ────────────────────────────────────────────────── */
.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.appbar h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.counts {
  font-size: 12px;
  color: var(--fg-mute);
  margin: 0 0 12px;
  line-height: 1.4;
}
.appbar .conn { display: flex; gap: 6px; }

/* ──── add bar + search ───────────────────────────────────────── */
#add-form, .filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;          /* let filter chips wrap below on narrow screens */
}
#add-form > input, .filters > input {
  flex: 1;
  min-width: 200px;         /* keep input usable; wraps below other items if needed */
  width: auto;              /* override the global width:100% */
}
.prefix { display: none; }   /* drop the [+] / [/] terminal-style hints */

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ──── banners ────────────────────────────────────────────────── */
.banner {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
}
.banner-warn  { background: rgba(241,250,140,0.12); color: var(--yellow); border: 1px solid var(--yellow); }
.banner-error { background: rgba(255,85,85,0.10); color: var(--red);    border: 1px solid var(--red); }

/* ──── rails (projects / contexts) ────────────────────────────── */
.layout {
  display: block;
}
.rail {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.rail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rail-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: background 80ms;
}
.rail-list li:hover { background: var(--bg-hover); }
.rail-list li.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.rail-list input[type="checkbox"] { display: none; }
.rail-list .name { font-weight: 500; }
.rail-list .count { color: var(--fg-mute); font-size: 11px; }
.rail-list li.active .count { color: var(--bg); }
.rail-list .empty {
  font-style: italic;
  color: var(--fg-mute);
  font-size: 13px;
  padding: 6px 2px;
  background: transparent;
  border: none;
  cursor: default;
}

/* widescreen: rails on the sides, less padding */
@media (min-width: 980px) {
  body { max-width: 1100px; padding-bottom: 32px; }
  .layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 200px;
    gap: 16px;
    align-items: start;
  }
  .rail { margin-bottom: 0; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
}

/* ──── section headers ────────────────────────────────────────── */
.table-header { display: none; }    /* legacy column header — gone */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 4px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.section-header.section-urgent { color: var(--red); }
.section-header.section-today { color: var(--accent); }
.section-header.section-tomorrow { color: var(--accent-2); }
.section-header.section-later { color: var(--fg-dim); }
.section-header.section-done { color: var(--fg-mute); }
.section-count {
  font-weight: 600;
  font-size: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--fg-dim);
}

/* ──── task list ──────────────────────────────────────────────── */
#task-list {
  outline: none;
  background: transparent;
  border: none;
}
#rows { display: flex; flex-direction: column; gap: 8px; }

/* ──── task card ──────────────────────────────────────────────── */
.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 14px;       /* tighter vertical padding so larger title doesn't grow the card */
  box-shadow: var(--shadow);
  transition: transform 80ms, background 80ms, border-color 80ms;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* allow text selection inside the inline edit input */
.row .edit-input { user-select: text; -webkit-user-select: text; }
.row:active { transform: scale(0.995); }
.row.focused { border-color: var(--accent); }
.row.done { opacity: 0.55; }
.row.done .row-title { text-decoration: line-through; color: var(--fg-mute); }

/* priority left-edge stripe */
.row.prio-p1 { border-left: 4px solid var(--red); padding-left: 11px; }
.row.prio-p2 { border-left: 4px solid var(--orange); padding-left: 11px; }
.row.prio-p3 { border-left: 4px solid var(--yellow); padding-left: 11px; }

.row-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.row-body { flex: 1; min-width: 0; padding-top: 2px; }
.row-title {
  font-size: 19px;          /* bigger task title */
  font-weight: 500;
  line-height: 1.25;
  word-wrap: break-word;
  color: var(--fg);
  cursor: text;
}
.row.prio-p1 .row-title { font-weight: 700; }

/* round checkbox button */
.checkbox {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border-2);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  min-height: 28px;
  transition: background 80ms, border-color 80ms;
}
.checkbox:hover { border-color: var(--accent); background: rgba(139,233,253,0.08); }
.checkbox.checked {
  background: var(--green);
  border-color: var(--green);
}
.checkbox.checked::after {
  content: "✓";
  color: var(--bg);
  font-weight: 800;
  font-size: 16px;
  line-height: 1;
}

/* meta row */
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 40px;     /* align under title (past the checkbox) */
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
}
.pill:hover { background: var(--bg-hover); }
.prio-pill.prio-p0 { background: rgba(139,233,253,0.14); color: var(--accent); border-color: rgba(139,233,253,0.35); }
.prio-pill.prio-p1 { background: rgba(255,85,85,0.18); color: var(--red); border-color: var(--red); }
.prio-pill.prio-p2 { background: rgba(255,184,108,0.18); color: var(--orange); border-color: var(--orange); }
.prio-pill.prio-p3 { background: rgba(241,250,140,0.18); color: var(--yellow); border-color: var(--yellow); }
.due-pill { background: rgba(216,216,210,0.10); color: var(--fg-dim); border-color: var(--border); }
.due-pill.overdue { background: rgba(255,85,85,0.18); color: var(--red); border-color: var(--red); }
.due-pill.today   { background: rgba(255,184,108,0.18); color: var(--orange); border-color: var(--orange); }
.due-pill.week    { background: rgba(241,250,140,0.15); color: var(--yellow); border-color: var(--yellow); }
.proj-pill { background: rgba(139,233,253,0.14); color: var(--accent); border-color: rgba(139,233,253,0.35); }
.ctx-pill  { background: rgba(189,147,249,0.14); color: var(--accent-2); border-color: rgba(189,147,249,0.35); }
.note-pill { background: rgba(80,250,123,0.12); color: var(--green); border-color: rgba(80,250,123,0.45); }
/* dotted-blue placeholder variant of note-pill (overrides .placeholder green) */
.note-pill.placeholder { background: rgba(139,233,253,0.10); color: var(--accent); border: 1px dashed rgba(139,233,253,0.45); font-style: italic; }
.note-pill.placeholder:hover { background: rgba(139,233,253,0.18); border-style: solid; }

/* inline edit */
.row .edit-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  margin: -2px 0;
}

/* empty state */
.empty {
  color: var(--fg-mute);
  font-size: 14px;
  text-align: center;
  padding: 40px 16px;
}

/* sort/filter chips at top */
.chip {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--fg-dim);
}
.chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ──── floating add button (FAB) ──────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  border: none;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab:hover { background: var(--accent-2); }
@supports (padding: env(safe-area-inset-bottom)) {
  .fab { bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px)); }
}

/* footer hidden — keybind hints are not useful on touch UI */
footer { display: none; }

kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  color: var(--fg);
}

/* ──── login panel ────────────────────────────────────────────── */
.panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  margin: 56px auto;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.panel h1 { font-size: 22px; margin: 0 0 16px; color: var(--fg); }
.panel a { color: var(--accent); }

/* ──── dialogs ────────────────────────────────────────────────── */
dialog {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 0;
  max-width: 720px;
  width: 92vw;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }

#note-dialog { max-width: 520px; }
#note-dialog .panel, #help-dialog .panel { box-shadow: none; margin: 0; padding: 16px; }
#note-editor {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  min-height: 180px;
  max-height: 50vh;
}
#note-editor:focus { border-color: var(--accent); }

.markdown-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  min-height: 180px;
  max-height: 50vh;
  overflow: auto;
}
.markdown-preview h1 { font-size: 1.5em; margin: 0.4em 0; color: var(--accent); }
.markdown-preview h2 { font-size: 1.25em; margin: 0.4em 0; color: var(--accent); }
.markdown-preview code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 0.92em; }
.markdown-preview pre { background: var(--bg-soft); padding: 12px; border-radius: var(--r-sm); overflow-x: auto; }
.markdown-preview pre code { background: transparent; padding: 0; }
.markdown-preview a { color: var(--accent-2); }
.markdown-preview blockquote { border-left: 3px solid var(--accent); margin: 0.5em 0; padding-left: 12px; color: var(--fg-dim); }

/* placeholder pills (date / p / c when unset) */
.pill.placeholder {
  background: rgba(139,233,253,0.10);
  color: var(--accent);
  border: 1px dashed rgba(139,233,253,0.45);
  font-weight: 500;
  font-style: italic;
}
.pill.placeholder:hover { background: rgba(139,233,253,0.18); border-style: solid; }

/* picker dialog (date / project / context) */
#picker { max-width: 460px; }
.picker-panel {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.picker-panel h3 {
  margin: 0;
  font-size: 14px;
  color: var(--fg-mute);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.picker-panel button { width: auto; text-align: center; }    /* override default modal button-stretching */
.picker-panel input { font-size: 16px; }
.picker-content { display: flex; flex-direction: column; gap: 14px; }
.picker-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.picker-quick button {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.picker-quick button:hover { border-color: var(--accent); }
.picker-row { display: flex; flex-direction: column; gap: 6px; }
.picker-label { font-size: 12px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.06em; }
.picker-input-row { display: flex; gap: 8px; align-items: stretch; }
.picker-input-row input { flex: 1; }
.picker-chip-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow-y: auto; }
.picker-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  min-height: 0;       /* override default button min-height */
}
.picker-chip:hover { border-color: var(--accent); color: var(--fg); }
.picker-chip.selected { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.picker-footer { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.picker-footer button { flex: 1; }
#picker input[type="date"] { font-family: var(--sans); }

/* action sheet */
#action-sheet { max-width: 420px; }
.action-sheet-panel { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.action-sheet-panel h3 {
  margin: 0 4px 8px;
  font-size: 13px;
  color: var(--fg-mute);
  font-weight: 500;
  word-break: break-word;
}
.action-sheet-panel button {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  font-size: 15px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
}

/* desktop refinements */
@media (min-width: 980px) {
  .row { padding: 12px 16px; }
  .row-title { font-size: 15px; }
  body { font-size: 14px; }
}
