:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #74736e;
  --line: #e2e1dc;
  --accent: #2f6f4e;
  --accent-soft: #dfeee6;
  --danger: #a8382f;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --panel: #1f2124;
    --ink: #eceae5;
    --muted: #9a9892;
    --line: #32353a;
    --accent: #6fbf94;
    --accent-soft: #23342b;
    --danger: #e0796d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: inherit; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.danger { color: var(--danger); }

input[type="text"], input:not([type]), input[type="password"], select, textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; }

/* ------------------------------------------------------------ connexion */

.login {
  max-width: 340px;
  margin: 14vh auto;
  padding: 0 20px;
}
.login h1 { font-size: 20px; margin-bottom: 24px; }
.login label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login label > * { margin-top: 5px; }
.login button { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; }
.error { color: var(--danger); font-size: 14px; }

/* ------------------------------------------------------------ chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar .brand { font-weight: 600; text-decoration: none; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.topbar .who { color: var(--muted); }

main { max-width: 820px; margin: 0 auto; padding: 0 24px 96px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  padding-top: 28px;
  padding-bottom: 12px;
}
.page-head h1 { font-size: 22px; margin: 4px 0; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; }
.sub { color: var(--muted); font-size: 13px; margin: 0; max-width: 52ch; }
.editable { cursor: pointer; border-bottom: 1px dashed var(--line); }
.empty { color: var(--muted); }

.switch { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.switch input { width: auto; }

/* ------------------------------------------------------------ liste projets */

.cards { list-style: none; margin: 0 0 28px; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card.archived { opacity: .55; }
.card-main { display: grid; grid-template-columns: 32px 1fr 120px auto; gap: 16px; align-items: center; text-decoration: none; }
.card-name { font-weight: 500; }
/* The cell is always laid out, even with no icon, so names stay aligned across cards. */
.card-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.card-icon img { max-width: 32px; max-height: 32px; border-radius: 4px; }
.card-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.card-url { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.bar { display: block; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.new-project { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }

/* ------------------------------------------------------------ projet */

.score { text-align: right; display: grid; gap: 6px; justify-items: end; font-size: 13px; color: var(--muted); }
.score strong { font-size: 20px; color: var(--ink); }
.score .bar { width: 160px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-top: 28px; margin-bottom: 24px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.group { margin-bottom: 28px; }
.group h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 8px;
}

.tasks { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.task {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
.task:last-child { border-bottom: 0; }
.task-line { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.task-line input { width: auto; margin-top: 3px; flex: none; }
.task.is-done .task-label { color: var(--muted); text-decoration: line-through; }
.task-side { display: flex; align-items: center; gap: 6px; }
.stamp { font-size: 11px; color: var(--muted); white-space: nowrap; }
.icon { border: 0; background: none; padding: 2px 6px; color: var(--muted); border-radius: 6px; }
.icon:hover { background: var(--accent-soft); color: var(--ink); }
.note { grid-column: 1 / -1; font-size: 13px; background: var(--bg); }

.new-task { display: flex; gap: 8px; margin-top: 8px; }
.new-task input { background: transparent; border-style: dashed; }
.new-task button { flex: none; width: 40px; }

.template-form { display: grid; gap: 12px; justify-items: start; }
.template-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ------------------------------------------------------------ toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
#toast.ok { background: var(--accent); }

@media (max-width: 620px) {
  main { padding: 20px 16px 80px; }
  .page-head { flex-direction: column; }
  .score { text-align: left; justify-items: start; }
  .card-main { grid-template-columns: 32px 1fr; gap: 8px 12px; }
  .card-icon { grid-row: 1 / -1; align-self: start; }
  .new-project { grid-template-columns: 1fr; }
}
