:root {
  --bg: #14110d;
  --bg-vignette: radial-gradient(ellipse at 50% -10%, #26201a 0%, #14110d 55%);
  --surface: #1e1811;
  --surface-raised: #241d15;
  --ink: #f2ead9;
  --muted: #a89a83;
  --muted-dim: #756a58;
  --line: rgba(198, 161, 91, 0.22);
  --line-strong: rgba(198, 161, 91, 0.4);
  --accent: #c6a15b;
  --accent-bright: #e3c27f;
  --accent-ink: #201808;
  --danger: #b06a5a;
  --later: #7fa7c4;
  --done: #9db98a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg) var(--bg-vignette);
  font-family: 'Manrope', -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  display: flex;
  justify-content: center;
  padding: 56px 16px;
}
.card {
  width: 100%;
  max-width: 420px;
}
h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
  color: var(--ink);
}
h1::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  margin: 12px 0 22px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
/* Inside a project, the title accent and active-task rows pick up that project's color */
#projectTitle::after { background: linear-gradient(90deg, var(--project-color, var(--accent)), transparent); }
h2 {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 30px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
#laterHeading, #doneHeading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.01em;
  margin-top: 46px;
  margin-bottom: 14px;
}
#laterHeading { color: var(--later); }
#doneHeading { color: var(--done); }
#laterHeading::after { background: var(--later); opacity: 0.4; }
#doneHeading::after { background: var(--done); opacity: 0.4; }
#laterSeeAll { color: var(--later); }
#doneSeeAll { color: var(--done); }
#laterSeeAll:hover, #doneSeeAll:hover { filter: brightness(1.15); }

/* Later / Done are collapsible — closed until their heading is clicked */
.accordion-toggle { cursor: pointer; }
.accordion-toggle::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.accordion.open .accordion-toggle::before { transform: rotate(90deg); }
.accordion-toggle:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
.accordion-body { display: none; }
.accordion.open .accordion-body { display: block; }

/* Rename / delete a project from its row on the Projects list */
.project-row:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.project-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.project-mini {
  background: none;
  border: none;
  color: var(--muted-dim);
  font-size: 12px;
  line-height: 1;
  padding: 6px 7px;
  border-radius: 5px;
  cursor: pointer;
}
.project-mini:hover { color: var(--accent-bright); background: rgba(198, 161, 91, 0.1); filter: none; }
.project-mini.project-del:hover { color: var(--danger); background: rgba(176, 106, 90, 0.12); }
input[type="text"].project-name-edit {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 2px 6px;
  width: 100%;
}

/* Undo toast (task deletion) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 10px 10px 16px;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button {
  background: none;
  border: none;
  color: var(--accent-bright);
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.toast button:hover { filter: brightness(1.12); }
#taskForm, #projectForm {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}
input[type="text"], input[type="email"], input[type="password"], textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Manrope', sans-serif;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input[type="text"]::placeholder, input[type="email"]::placeholder, input[type="password"]::placeholder, textarea::placeholder { color: var(--muted-dim); }
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.15);
}
textarea {
  resize: none;
  line-height: normal;
  max-height: 40vh;
  overflow-y: hidden;
}
button {
  padding: 11px 18px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
button:disabled { opacity: 0.6; cursor: default; filter: none; }

.back-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--accent-bright); }

ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  position: relative;
  touch-action: pan-y;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
li.armed {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  border-color: var(--line-strong);
  transform: scale(1.02);
  touch-action: none;
  z-index: 2;
}
.drop-indicator {
  height: 2px;
  margin: -1px 0;
  border-radius: 2px;
  background: var(--accent-bright);
  box-shadow: 0 0 6px rgba(227, 194, 127, 0.6);
}
li.done { border-color: var(--line); background: var(--surface); opacity: 0.7; }
li.done span { text-decoration: line-through; color: var(--muted-dim); }

/* Tint task rows to match their section colour */
.section-list[data-status="later"] li {
  background: rgba(127, 167, 196, 0.09);
  border-color: rgba(127, 167, 196, 0.3);
  border-left: 3px solid var(--later);
}
.section-list[data-status="done"] li,
.section-list[data-status="done"] li.done {
  background: rgba(157, 185, 138, 0.08);
  border-color: rgba(157, 185, 138, 0.28);
  border-left: 3px solid var(--done);
}
li span { flex: 1; word-break: break-word; white-space: pre-wrap; cursor: text; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; }
li span:hover { background: rgba(198, 161, 91, 0.08); }
li .edit-input {
  flex: 1;
  font-size: 14px;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 4px;
  margin: -3px -5px;
  background: var(--surface-raised);
}
li .edit-input:focus { outline: none; }
li textarea.edit-input { display: block; }
li input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--muted-dim);
  border-radius: 4px;
  background: var(--surface-raised);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
li input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
li input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.remove {
  background: none;
  border: none;
  color: var(--muted-dim);
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}
.remove:hover { color: var(--danger); }
.later-toggle {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--accent);
  cursor: pointer;
}
.later-toggle:hover { color: var(--accent-bright); }
.empty {
  color: var(--muted-dim);
  font-size: 13px;
  font-style: italic;
  padding: 14px 2px;
}
.see-all {
  display: none;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 2px 0;
  cursor: pointer;
}
.see-all:hover { color: var(--accent-bright); text-decoration: underline; }

/* "To Test" — a side bucket, reached by a button rather than shown as a board */
.totest-btn {
  display: block;
  width: 100%;
  margin: 0 0 22px;
  background: none;
  border: 1px dashed var(--line-strong);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.totest-btn:hover { border-color: var(--accent); color: var(--accent-bright); filter: none; }
.section-list[data-status="totest"] li {
  background: rgba(198, 161, 91, 0.06);
  border-color: rgba(198, 161, 91, 0.3);
  border-left: 3px solid var(--accent);
}
.section-list[data-status="todo"] li {
  border-left: 3px solid var(--project-color, var(--accent));
}

/* Project list on the home screen */
.project-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--project-color, var(--line));
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.project-row:hover { border-color: var(--line-strong); border-left-color: var(--project-color, var(--line-strong)); transform: translateY(-1px); }
.project-monogram {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--project-color, var(--accent)) 55%, var(--line-strong));
  background: color-mix(in srgb, var(--project-color, var(--accent)) 22%, var(--surface-raised));
  color: var(--project-color, var(--accent-bright));
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.project-body { flex: 1; min-width: 0; }
.project-name { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 600; color: var(--ink); }
.project-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: 0.01em; }
.project-chevron { color: var(--muted-dim); font-size: 16px; flex-shrink: 0; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.65);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 19px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.modal-header h2::after { content: none; }
.modal #modalList {
  overflow-y: auto;
}

/* ---------- Auth screen ---------- */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 24px;
}
.auth-card h1 { font-size: 22px; }
.auth-card h1::after { margin: 10px 0 20px; }
.auth-field {
  margin-bottom: 14px;
}
.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}
.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 18px;
}
.auth-error {
  display: none;
  background: rgba(176, 106, 90, 0.12);
  border: 1px solid rgba(176, 106, 90, 0.4);
  color: #e0a698;
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.app-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.logout-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.logout-link:hover { color: var(--danger); }

.loading-note {
  color: var(--muted-dim);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  padding: 40px 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent);
  margin-bottom: 10px;
}
.brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* ---------- Sections (task groups) ---------- */
#taskForm { flex-wrap: wrap; align-items: flex-start; }
#taskForm #taskInput { flex: 1 1 55%; min-height: 44px; }
#taskForm #addBtn { flex: 0 0 auto; min-height: 44px; }
#taskForm #taskSection { flex: 1 1 100%; order: 3; }

#sectionForm {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23c6a15b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  cursor: pointer;
  max-width: 100%;
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.15);
}
select option {
  background: var(--surface-raised);
  color: var(--ink);
}

.section-block { margin-bottom: 6px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 9px;
}
.section-head::after {
  content: '';
  order: 5;
  flex: 1;
  height: 1px;
  background: var(--line);
}
.section-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  border-radius: 4px;
  padding: 1px 4px;
  margin: 0 -4px;
}
.section-name.editable { cursor: text; }
.section-name.editable:hover { background: rgba(198, 161, 91, 0.1); }
.section-head-plain .section-name {
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.section-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted-dim);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  padding: 1px 6px;
}
.section-mini {
  order: 6;
  background: none;
  border: none;
  color: var(--muted-dim);
  font-size: 10px;
  line-height: 1;
  padding: 3px 4px;
  cursor: pointer;
}
.section-mini:hover { color: var(--accent-bright); filter: none; }
.section-mini.section-del:hover { color: var(--danger); }
.section-head .edit-input { font-size: 13px; }

.edit-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  align-items: stretch;
  cursor: default;
}
/* column flex item: use the height autogrow sets, not flex-basis */
.edit-group .edit-input { flex: 0 0 auto; width: 100%; margin: 0; }
.edit-section {
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 30px 6px 8px;
  font-size: 13px;
  background-position: right 9px center;
}

#modalList {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
}

/* Give the column a bit more room on desktop-sized screens. */
@media (min-width: 720px) {
  .card { max-width: 560px; }
  .modal { max-width: 560px; }
}

/* Mobile browsers (iOS Safari) zoom in when a focused field's text is < 16px.
   Keep every editable control at 16px on small screens so the page doesn't jump. */
@media (max-width: 600px) {
  input[type="text"], input[type="email"], input[type="password"], textarea, select,
  li .edit-input, li .edit-section, .section-head .edit-input {
    font-size: 16px;
  }
}
