/*
  Life Buddies UI
  Direction: a checklist on the fridge door. Quiet graphite chrome, one ballpoint-ink
  accent, a hand-drawn pen tick as the signature, buddy notes as paper slips.
  Visual pass guided by "unslop" by Damir Sokolovsky (@heydamir), CC BY 4.0.
*/

/* ===== Tokens ===== */
:root {
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* graphite light ramp */
  --bg: #fafafa;
  --card: #ffffff;
  --raised: #f4f4f5;
  --line: rgba(23, 23, 23, 0.08);
  --line-strong: rgba(23, 23, 23, 0.16);
  --text: #171717;
  --text-2: #525252;
  --text-3: #6e6e6e;

  /* one accent: ballpoint ink */
  --ink: #2447b3;
  --ink-hover: #1d3a94;
  --ink-soft: rgba(36, 71, 179, 0.08);
  --ink-ring: rgba(36, 71, 179, 0.28);

  /* semantic, toned */
  --positive: #15803d;
  --negative: #c81e1e;
  --negative-soft: rgba(200, 30, 30, 0.06);

  /* paper, only for the note slips and the login checklist */
  --paper: #fbf8ef;
  --paper-line: rgba(120, 96, 40, 0.16);
  --paper-rule: rgba(36, 71, 179, 0.10);

  --r-sm: 6px; --r: 8px; --r-card: 12px; --r-panel: 16px;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --sh-float: 0 8px 24px rgba(0, 0, 0, 0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/22px var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 15px; line-height: 22px; }
h3 { font-size: 16px; line-height: 24px; }
p { margin: 0; }
a { color: var(--ink); text-decoration-color: var(--ink-ring); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.muted { color: var(--text-3); }
.secondary { color: var(--text-2); }
.small { font-size: 13px; line-height: 20px; }
.mono { font-family: var(--mono); font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.i-18 { width: 18px; height: 18px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Signature: the pen tick ===== */
.tick { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--ink); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.box { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); background: var(--card); }
.box .tick { width: 22px; height: 22px; margin: -6px -8px 0 0; }
.box.is-checked { border-color: var(--line-strong); }

/* ===== App shell ===== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 16px 16px; background: var(--bg); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-sm); background: var(--ink); }
.brand-mark .tick { width: 16px; height: 16px; stroke: #fff; stroke-width: 2.5; }
.brand-name { font-size: 16px; font-weight: 600; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 24px; }
.nav-label { padding: 0 8px; margin-bottom: 8px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.nav a { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px; border-radius: var(--r); color: var(--text-2); font-weight: 500; text-decoration: none; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.nav a .i { color: var(--text-3); }
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a[aria-current="page"] { background: var(--card); color: var(--text); box-shadow: var(--sh-sm), inset 0 0 0 1px var(--line); }
.nav a[aria-current="page"] .i { color: var(--text); }
.me { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 8px; border-radius: var(--r-card); }
.me-info { flex: 1; min-width: 0; line-height: 18px; }
.me-info strong { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info span { font-size: 12px; color: var(--text-3); }
.content { width: 100%; max-width: 1440px; padding: 32px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; color: var(--text-2); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 4px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); background: rgba(250, 250, 250, 0.96); }
  .nav { flex-direction: row; margin: 0 0 0 auto; }
  .nav-label, .nav a span, .me-info { display: none; }
  .nav a { width: 36px; justify-content: center; padding: 0; }
  .me { margin: 0; padding: 0; }
  .content { padding: 24px 16px 48px; }
  h1 { font-size: 24px; }
}

/* ===== Components ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 56px; padding: 12px 20px; border-bottom: 1px solid var(--line); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r); font: 500 14px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-hover); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line-strong); box-shadow: var(--sh-sm); }
.btn-secondary:hover { background: var(--raised); }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r); background: transparent; color: var(--text-3); cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.danger:hover { background: var(--negative-soft); color: var(--negative); }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: 12px; font-weight: 600; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* status: a dot and a word, no pill */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status.done { color: var(--positive); } .status.done::before { background: var(--positive); }
.status.late { color: var(--negative); } .status.late::before { background: var(--negative); }
.role { font-size: 13px; color: var(--text-3); }
.meta { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; color: var(--text-3); }
.meta.late { color: var(--negative); }

/* stats: one strip, numbers only */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; }
.stat { padding: 16px 20px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-label { font-size: 13px; line-height: 20px; color: var(--text-2); }
.stat-value { display: block; margin-top: 4px; font-size: 28px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat-value.late { color: var(--negative); }
@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* layout */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.stack { display: grid; gap: 24px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* tabs */
.tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--raised); }
.tabs a { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: var(--r); font-size: 14px; font-weight: 500; color: var(--text-2); text-decoration: none; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--card); color: var(--text); box-shadow: var(--sh-sm), inset 0 0 0 1px var(--line); }
.tabs .mono { color: var(--text-3); }

/* admin task rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 176px 96px 36px; gap: 16px; align-items: start; padding: 16px 20px; border-bottom: 1px solid var(--line); transition: background-color 150ms var(--ease); }
.row:last-child { border-bottom: 0; }
.row:hover { background: #fcfcfc; }
.row > .box, .row > .who, .row > .status, .row > form { margin-top: 2px; }
.row > .who { margin-top: -4px; }
.row-title { font-weight: 500; }
.row.is-done .row-title { color: var(--text-3); }
.row-desc { margin-top: 2px; font-size: 14px; color: var(--text-2); }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--text-2); }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .row { grid-template-columns: 20px minmax(0, 1fr) 36px; gap: 8px 12px; }
  .row > .who, .row > .status { grid-column: 2; margin-top: 0; }
  .row > form { grid-column: 3; grid-row: 1; }
}

/* moment: the note slip */
.slip { position: relative; max-width: 520px; margin-top: 12px; padding: 8px 12px 8px 20px; border: 1px solid var(--paper-line); border-radius: var(--r-sm); background: var(--paper); box-shadow: 0 1px 2px rgba(120, 96, 40, 0.08); color: var(--text); font-size: 14px; line-height: 22px; white-space: pre-wrap; }
.slip::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 10px; width: 1px; background: rgba(200, 30, 30, 0.25); }
.slip-by { display: block; margin-top: 2px; font-size: 12px; line-height: 16px; color: #7b7266; white-space: normal; }

/* buddy task cards */
.progress { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.progress .bar { flex: 1; }
.tasks { display: grid; gap: 12px; }
.task { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 16px; padding: 20px; }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.task.is-done h3 { color: var(--text-3); }
.task-desc { margin-top: 4px; color: var(--text-2); white-space: pre-wrap; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.complete-form { display: flex; align-items: flex-end; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.complete-form .field { flex: 1; margin: 0; }
.complete-form textarea { min-height: 40px; }
@media (max-width: 600px) { .complete-form { flex-direction: column; align-items: stretch; } }

/* forms */
.field { margin-bottom: 16px; }
.field label, .label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--text); }
.field label .muted { font-weight: 400; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--card);
  font: 400 15px/22px var(--font); color: var(--text); transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease); }
textarea { resize: vertical; }
::placeholder { color: #8f8f8f; }
input:hover, select:hover, textarea:hover { border-color: rgba(23, 23, 23, 0.28); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-ring); }
.help { display: block; margin-top: 6px; font-size: 13px; line-height: 20px; color: var(--text-3); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--negative); }
ul.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--negative); font-size: 13px; line-height: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-opt { position: relative; display: flex; gap: 8px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--r); cursor: pointer; transition: border-color 150ms var(--ease), background-color 150ms var(--ease); }
.role-opt input { position: absolute; opacity: 0; }
.role-opt:hover { background: var(--raised); }
.role-opt:has(input:checked) { border-color: var(--ink); background: var(--ink-soft); }
.role-opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.role-opt strong { display: block; font-size: 14px; font-weight: 500; line-height: 20px; }
.role-opt small { display: block; color: var(--text-2); font-size: 13px; line-height: 18px; }
.role-opt .i { margin-top: 2px; color: var(--text-3); }
.role-opt:has(input:checked) .i { color: var(--ink); }

/* messages */
.toasts { display: grid; gap: 8px; margin-bottom: 24px; }
.toast { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); box-shadow: var(--sh-sm); font-size: 14px; }
.toast .tick { width: 18px; height: 18px; }
.toast.error { border-color: rgba(200, 30, 30, 0.2); background: #fffafa; color: var(--negative); }

/* empty state */
.empty { display: grid; justify-items: center; gap: 4px; padding: 48px 24px; text-align: center; }
.empty .box { width: 28px; height: 28px; margin-bottom: 8px; }
.empty p { color: var(--text-2); }

/* moment: buddy progress, a ranked list with thin bars */
.progress-list { list-style: none; margin: 0; padding: 8px 20px 12px; }
.progress-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 0; }
.progress-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.count { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }

/* people */
.people { list-style: none; margin: 0; padding: 0; }
.person { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 36px; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person-name { font-weight: 500; }

/* login */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-side { display: flex; flex-direction: column; justify-content: space-between; gap: 48px; padding: 32px 48px; background: var(--raised); border-right: 1px solid var(--line); }
.auth-copy h1 { font-size: 40px; line-height: 1.08; letter-spacing: -0.02em; max-width: 16ch; }
.auth-copy p { margin-top: 12px; max-width: 36rem; font-size: 18px; line-height: 28px; color: var(--text-2); }
.auth-form { display: grid; place-items: center; padding: 32px 16px; }
.auth-form form { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 24px; line-height: 1.2; }

/* moment: the fridge-door checklist, built in code */
.fridge { position: relative; align-self: center; width: min(100%, 400px); padding: 40px 32px 28px 48px; border-radius: 4px; background: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 39px, var(--paper-rule) 39px 40px);
  background-position: 0 64px; box-shadow: 0 1px 1px rgba(80, 60, 20, 0.08), 0 12px 28px rgba(80, 60, 20, 0.10); transform: rotate(-1.5deg); }
.fridge::before { content: ""; position: absolute; top: 0; bottom: 0; left: 32px; width: 1px; background: rgba(200, 30, 30, 0.25); }
.magnet { position: absolute; top: -12px; left: 50%; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: #3d3d40; box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.2), inset 0 -3px 4px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.25); }
.fridge-title { margin-bottom: 4px; font-size: 13px; line-height: 20px; color: #7b7266; }
.fridge ul { list-style: none; margin: 0; padding: 0; }
.fridge li { display: flex; align-items: center; gap: 12px; height: 40px; color: var(--text); }
.fridge li.done span { color: #7b7266; text-decoration: line-through; text-decoration-color: rgba(36, 71, 179, 0.55); text-decoration-thickness: 1.5px; }
.fridge .box { background: transparent; border-color: rgba(80, 60, 20, 0.3); }
.fridge-note { margin: 4px 0 0 32px; font-size: 14px; line-height: 20px; color: var(--ink); transform: rotate(-1deg); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { order: 2; padding: 32px 16px; border-right: 0; border-top: 1px solid var(--line); }
  .auth-copy h1 { font-size: 32px; }
  .fridge { width: 100%; }
}

/* motion: one entrance for the main content */
@media (prefers-reduced-motion: no-preference) {
  .content > *, .auth-form form { animation: rise 400ms var(--ease) both; }
  .content > :nth-child(2) { animation-delay: 50ms; }
  .content > :nth-child(3) { animation-delay: 100ms; }
  .content > :nth-child(4) { animation-delay: 150ms; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
