/* Tasks — dark, clean, minimal (spec: UI). */

:root {
  --bg: #0e1114;
  --panel: #14181d;
  --panel2: #1a2027;
  --border: #242c35;
  --text: #dbe2ea;
  --muted: #7d8894;
  --accent: #4c8dff;
  --red: #f0554d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ---- header -------------------------------------------------------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#topbar h1 { font-size: 17px; font-weight: 600; flex: 1; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; color: var(--muted);
  font-size: 24px;
}
.icon-btn:hover { color: var(--text); background: var(--panel2); }
#back-btn { display: none; }
#print-btn {
  color: var(--muted); font-size: 13px;
  border: 1.5px solid var(--muted); border-radius: 999px;
  padding: 4px 14px;
}
#print-btn:hover { color: var(--text); border-color: var(--text); background: var(--panel2); }

/* ---- layout -------------------------------------------------------- */
#layout {
  display: flex;
  height: calc(100% - 52px);
  height: calc(100dvh - 52px - env(safe-area-inset-top));
}
#projects-pane, #right-pane { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
#projects-pane {
  width: 264px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 10px;
}
#right-pane { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* ---- projects pane ------------------------------------------------- */
#project-list { list-style: none; }
.project {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.project:hover { background: var(--panel2); }
.project.selected { background: var(--panel2); }
.project .pname {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project.overdue .pname { color: var(--red); }
.project .count { color: var(--muted); font-size: 13px; }
.project .pdelete {
  color: var(--muted); font-size: 17px; line-height: 1;
  padding: 2px 5px; border-radius: 6px; visibility: hidden;
}
.project:hover .pdelete { visibility: visible; }
.project .pdelete:hover { color: var(--red); background: var(--bg); }
.project .drag-handle {
  color: var(--muted); cursor: grab; flex-shrink: 0;
  padding: 2px 4px; font-size: 14px; opacity: 0.6;
  touch-action: none; -webkit-touch-callout: none;
}
.project .drag-handle:active { cursor: grabbing; }
#add-project { margin-top: 10px; }
#add-project input { width: 100%; background: var(--panel); }
#add-project input:focus { background: var(--panel2); }
.sortable-ghost { opacity: 0.4; }
.sortable-drag { background: var(--panel2); }

/* ---- tasks pane ---------------------------------------------------- */
.pane-head {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 14px; max-width: 720px;
}
.pane-head h2 { font-size: 19px; font-weight: 600; flex: 1; min-width: 0; }
#right-pane .pane-head h2 { cursor: pointer; }
#rename-input { font-size: 19px; font-weight: 600; width: 100%; padding: 4px 8px; }
.link { color: var(--muted); font-size: 13px; }
.link:hover { color: var(--accent); }
#quick-add { max-width: 720px; margin-bottom: 12px; }
#quick-add input { width: 100%; }
#task-list, #done-list { list-style: none; max-width: 720px; }
.task {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.task .complete {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  border: 1.5px solid var(--muted); border-radius: 50%;
  cursor: pointer; padding: 0; background: none;
}
.task .complete:hover { border-color: var(--accent); }
.task .complete:checked { background: var(--accent); border-color: var(--accent); }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task .title { display: block; overflow-wrap: break-word; }
.task.overdue .title { color: var(--red); }
.task .due { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.task.overdue .due { color: var(--red); }
.task .drag-handle {
  color: var(--muted); cursor: grab; flex-shrink: 0;
  padding: 2px 6px; margin-top: 1px; touch-action: none;
  -webkit-touch-callout: none; font-size: 14px; opacity: 0.6;
}
.task .drag-handle:active { cursor: grabbing; }
.task.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { background: rgba(76, 141, 255, 0.18); } 100% { background: none; } }
.empty { color: var(--muted); padding: 18px 4px; }

/* completed view */
.task.done .title { color: var(--muted); }
.task.done .check { color: var(--accent); margin-top: 1px; flex-shrink: 0; width: 18px; text-align: center; }
.task .tdelete {
  color: var(--muted); font-size: 17px; line-height: 1;
  padding: 2px 6px; border-radius: 6px; flex-shrink: 0;
}
.task .tdelete:hover { color: var(--red); background: var(--panel2); }

/* ---- inline edit --------------------------------------------------- */
.task-edit {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin: 2px 0;
}
.task-edit textarea { resize: vertical; min-height: 44px; }
.edit-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-row input[type="date"], .edit-row input[type="time"] { color-scheme: dark; }
.task-edit:not(.has-date) input[type="time"],
.task-edit:not(.has-date) .notify-label { display: none; }
.notify-label {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13.5px; cursor: pointer;
}
.edit-actions { display: flex; gap: 8px; }
.edit-actions button { padding: 7px 14px; border-radius: 8px; font-size: 13.5px; }
.edit-actions .primary { background: var(--accent); color: #fff; }
.edit-actions .primary:hover { filter: brightness(1.1); }
.edit-actions button:not(.primary) { color: var(--muted); }
.edit-actions button:not(.primary):hover { background: var(--panel2); color: var(--text); }
.edit-actions .danger:hover { color: var(--red); }

/* ---- search -------------------------------------------------------- */
#search-input { width: 100%; max-width: 720px; margin-bottom: 12px; display: block; }
.results { list-style: none; max-width: 720px; }
.result {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 6px; border-bottom: 1px solid var(--border);
}
.result:not(.done) { cursor: pointer; }
.result:not(.done):hover { background: var(--panel); }
.result .rtitle { flex: 1; min-width: 0; overflow-wrap: break-word; }
.result .rproject { color: var(--muted); }
.result.done .rtitle { color: var(--muted); }
.result.overdue .rtitle { color: var(--red); }
.result .when { color: var(--muted); font-size: 12.5px; flex-shrink: 0; }

/* ---- login --------------------------------------------------------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 20px;
}
#login-form {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 300px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
}
#login-form h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
#login-form button {
  background: var(--accent); color: #fff;
  padding: 9px; border-radius: 8px; font-weight: 600;
}
#login-form button:hover { filter: brightness(1.1); }
#login-error { color: var(--red); font-size: 13.5px; text-align: center; min-height: 1em; }

/* ---- phone: stacked navigation ------------------------------------ */
@media (max-width: 768px) {
  /* On the phone home screen there's no project list on screen to print —
     the button appears once you're inside a project. */
  #print-btn { display: none; }
  body.show-right #print-btn { display: inline-block; }
  #projects-pane { width: 100%; border-right: none; }
  #right-pane { display: none; }
  body.show-right #projects-pane { display: none; }
  body.show-right #right-pane { display: block; }
  body.show-right #back-btn { display: flex; }
  .project .pdelete { visibility: visible; }
  #right-pane { padding: 14px; }
}

/* ---- print: current project list ---------------------------------- */
@media print {
  body { background: #fff; color: #000; }
  #topbar, #projects-pane, #quick-add, .pane-head .link,
  .task .complete, .task .drag-handle, .task .due, .task .tdelete,
  #search-input { display: none !important; }
  #layout { display: block; height: auto; }
  #right-pane { display: block !important; overflow: visible; padding: 0; }
  .pane-head h2 { color: #000; font-size: 18pt; margin-bottom: 12pt; }
  .task { border-bottom: none; padding: 4pt 0; }
  .task::before {
    content: ""; display: inline-block; flex-shrink: 0;
    width: 11pt; height: 11pt; border: 1.2pt solid #000; border-radius: 2pt;
    margin-right: 8pt; margin-top: 1pt;
  }
  .task .title, .task.overdue .title { color: #000; }
}
