@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0b0d;
  --side: #111114;
  --panel: rgba(255, 255, 255, 0.025);
  --raise: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);
  --text: #f2f2f3;
  --muted: #9a9aa3;
  --dim: #62626a;
  --accent: #e9e9ec;
  --accent-hi: #ffffff;
  --danger: #f87171;
  --ok: #6fcf97;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.6 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
svg { flex: none; }

/* App shell: sidebar + content */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 240px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--side);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; border-bottom: 1px solid var(--border); margin-bottom: 14px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: 13px;  }
.nav-item:hover { background: var(--raise); color: var(--text); }
.nav-item.active { color: var(--text); background: linear-gradient(90deg, rgba(91, 76, 245, 0.12), rgba(91, 76, 245, 0.35)); box-shadow: inset -3px 0 0 var(--accent-hi); }

.account {
  margin: auto 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); font-weight: 600; font-size: 13px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.who strong { font-size: 13px; font-weight: 600; }
.who span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--raise); color: var(--text); }

.content { flex: 1; min-width: 0; padding: 40px 48px 80px; max-width: 880px; }

h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin: 0; line-height: 1.2; }
.sub { color: var(--muted); margin: 6px 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); }
.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.back { display: inline-block; margin-bottom: 14px; }
.back:hover { color: var(--text); }

/* Panel */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 6px 18px 14px; }

/* Layout helpers */
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.narrow { max-width: 360px; }
.push { margin-left: auto; }

/* Task list */
.tasks, .list { list-style: none; margin: 0; padding: 0; }

.task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task > form { margin: 0; display: flex; }
.task.editing { display: block; padding: 14px 0; }

.body { flex: 1; min-width: 0; }
.title { display: block; overflow-wrap: anywhere; }
a.title:hover { color: #fff; text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }
.done .title { color: var(--dim); text-decoration: line-through; }
.note { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }

.check { flex: none; position: relative; width: 18px; height: 18px; margin-top: 1px; padding: 0; border: 1.5px solid var(--border-2); border-radius: 6px; background: transparent; cursor: pointer;  }
span.check { cursor: default; }
button.check:hover { border-color: var(--accent-hi); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after { content: ""; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.badge { flex: none; margin-top: 1px; padding: 3px 7px; border: 1px solid var(--border-2); border-radius: 6px; font-size: 10px; font-weight: 600; line-height: 1.2; letter-spacing: 0.05em; color: var(--muted); }
.badge.p3 { color: #fb7185; border-color: #4c2230; background: rgba(251, 113, 133, 0.08); }
.badge.p2 { color: #fbbf24; border-color: #4a3a17; background: rgba(251, 191, 36, 0.06); }
.badge.p1 { color: #a5b4fc; border-color: #2f3160; background: rgba(129, 140, 248, 0.07); }
.badge.p0 { color: var(--dim); border-color: var(--border); }
.done .badge { opacity: 0.45; }

/* Client list (admin) */
.list li { border-bottom: 1px solid var(--border); }
.list a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; }
.list a:hover span:first-child { color: #fff; text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--raise); color: var(--text); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;  }
.btn:hover { border-color: #45454c; }
.btn.primary { background: var(--accent); border-color: var(--accent-hi); color: #fff; font-weight: 500; box-shadow: 0 0 16px rgba(91, 76, 245, 0.35); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { border-color: #5a2a2a; }
.btn.block { width: 100%; height: 38px; }

/* Inputs */
input[type="text"], input[type="email"], input[type="password"], select { height: 36px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; width: 100%; }
select { width: auto; padding-right: 8px; cursor: pointer; }
.row input[type="text"] { flex: 1 1 220px; width: auto; }
input::placeholder { color: var(--dim); }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }

input:focus, select:focus, .btn:focus-visible, .check:focus-visible, summary:focus-visible, .icon-btn:focus-visible { outline: none; border-color: var(--accent-hi); box-shadow: 0 0 0 3px rgba(91, 76, 245, 0.25); }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; }

/* Disclosure blocks */
summary { list-style: none; cursor: pointer; width: fit-content; }
summary::-webkit-details-marker { display: none; }
details.add { margin-top: 10px; }
details.add > summary { padding-left: 0; }
details.add[open] > summary { margin-bottom: 8px; }
details.settings { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }
details.settings > summary:hover { color: var(--text); }
details.settings[open] > summary { margin-bottom: 16px; }
.danger-zone { margin-top: 24px; }

/* Login */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.login h1 { font-size: 24px; margin-bottom: 22px; }

/* Mobile: sidebar becomes a top bar */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; height: auto; width: 100%; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { border: 0; margin: 0; padding: 0 4px; font-size: 15px; }
  .nav { flex-direction: row; }
  .nav-item span { display: none; }
  .account { margin: 0 0 0 auto; padding: 4px; border: 0; background: transparent; }
  .who { display: none; }
  .content { padding: 24px 16px 60px; }
  h1 { font-size: 24px; }
  .panel { padding: 4px 14px 12px; }
}

/* ---------- Plain monochrome theme ---------- */
:root { --panel: #141417; --raise: #1d1d21; --border: #2a2a2f; --border-2: #3a3a40; --muted: #b4b4bc; --dim: #85858d; }
.brand > span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 15px; }
.brand small { font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.welcome { margin: 4px 8px 22px; font-size: 20px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.nav-label { margin: 0 8px 8px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.nav-item.active { background: var(--raise); color: var(--text); box-shadow: none; }
.avatar { background: var(--raise); border: 1px solid var(--border-2); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 48px; border-bottom: 1px solid var(--border); font-size: 13px; }
.dim { color: var(--dim); }
h1 { font-size: 28px; letter-spacing: -0.02em; }
.hot { color: #fb7185; }
.panel { border-radius: 10px; }
.check.on { background: var(--text); border-color: var(--text); }
.check.on::after { border-color: var(--bg); }
button.check:hover { border-color: var(--text); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); box-shadow: none; }
.btn.primary:hover { background: #fff; }
input:focus, select:focus, .btn:focus-visible, .check:focus-visible, summary:focus-visible, .icon-btn:focus-visible { border-color: var(--muted); box-shadow: none; outline: 2px solid var(--border-2); outline-offset: 1px; }
.badge { background: none !important; border-color: var(--border-2) !important; }
.badge.p1 { color: var(--muted); }
.login { border-radius: 10px; }
@media (max-width: 760px) {
  .welcome, .nav-label, .brand small { display: none; }
  .topbar { padding: 0 16px; height: 44px; }
  h1 { font-size: 24px; }
}

/* Square corners everywhere */
*, *::before, *::after { border-radius: 0 !important; }

/* Security log + misc */
.mono { font-size: 12px; }
.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th { text-align: left; font-weight: 500; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 8px 8px 0; border-bottom: 1px solid var(--border); }
.log td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--border); color: var(--muted); vertical-align: top; }
.log td:nth-child(2) { color: var(--text); }
.panel:has(.log) { overflow-x: auto; }
.login .muted.small { margin: -12px 0 18px; }

/* JetBrains Mono everywhere, including form controls */
button, input, select, textarea { font-family: inherit; }
h1 { letter-spacing: -0.03em; }

/* Task page */
.task-title { font-size: 26px; margin-bottom: 10px; overflow-wrap: anywhere; }
.task-meta { margin-bottom: 18px; }
.task-meta form { margin: 0; }
.status { font-size: 11px; padding: 3px 7px; border: 1px solid var(--border-2); color: var(--muted); }
.status.is-done { color: var(--ok); border-color: rgba(111, 207, 151, 0.35); }
.desc { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 18px; max-width: 70ch; }
.desc.muted { color: var(--dim); }
.callout { border: 1px solid var(--border); background: var(--panel); padding: 10px 14px; margin-bottom: 18px; }
.callout p { margin: 4px 0 0; white-space: pre-wrap; }
.task-edit { max-width: 640px; margin-bottom: 24px; }
h2.section { font-size: 15px; font-weight: 600; margin: 32px 0 14px; }

textarea { width: 100%; min-height: 80px; padding: 10px 12px; border: 1px solid var(--border-2); background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
textarea:focus { outline: none; border-color: var(--muted); }
textarea::placeholder { color: var(--dim); }

.activity { list-style: none; margin: 0; padding: 0; position: relative; }
.activity::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 1px; background: var(--border); }
.activity .event { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 7px 0; font-size: 12px; color: var(--muted); }
.activity .event strong { color: var(--text); font-weight: 500; }
.event-dot { flex: none; width: 17px; height: 17px; margin-top: 1px; border: 1px solid var(--border-2); background: var(--bg); position: relative; z-index: 1; }
.event-dot::after { content: ""; position: absolute; inset: 5px; background: var(--dim); }
.activity .event .badge { margin: 0 2px; }
.activity .comment { position: relative; z-index: 1; margin: 10px 0; border: 1px solid var(--border-2); background: var(--panel); }
.comment-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; font-size: 12px; }
.comment-head strong { font-weight: 600; }
.comment-body { padding: 6px 14px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.comment-form { margin-top: 14px; border: 1px solid var(--border-2); background: var(--panel); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { border: 0; background: transparent; padding: 4px; min-height: 60px; }

/* ---------- Motion: short, subtle, functional ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes tick { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Page content settles in on load */
.content > *, .login { animation: rise 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.content > :nth-child(2) { animation-delay: 30ms; }
.content > :nth-child(3) { animation-delay: 60ms; }
.content > :nth-child(n + 4) { animation-delay: 90ms; }

/* List rows cascade in */
.tasks .task, .list li, .activity > li { animation: rise 200ms ease-out both; }
.tasks .task:nth-child(2), .activity > li:nth-child(2), .list li:nth-child(2) { animation-delay: 25ms; }
.tasks .task:nth-child(3), .activity > li:nth-child(3), .list li:nth-child(3) { animation-delay: 50ms; }
.tasks .task:nth-child(4), .activity > li:nth-child(4), .list li:nth-child(4) { animation-delay: 75ms; }
.tasks .task:nth-child(n + 5), .activity > li:nth-child(n + 5), .list li:nth-child(n + 5) { animation-delay: 100ms; }

/* Hover / focus feedback */
.btn, .nav-item, .icon-btn, .check, input, select, textarea, .task, .list a, a.title {
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.btn:active, .icon-btn:active { transform: translateY(1px); }
.task:hover, .list li:hover { background: rgba(255, 255, 255, 0.02); }

/* Checkbox: pop + tick draws in */
.check.on { animation: pop 220ms ease-out; }
.check.on::after { animation: tick 180ms 60ms ease-out both; }
.done .title { transition: color 200ms ease; }

/* Disclosure panels (add task / add client / settings) slide open */
details[open] > :not(summary) { animation: rise 180ms ease-out both; }

/* Newest comment highlight when jumping to it */
.activity > li.comment:last-of-type { animation: rise 260ms ease-out both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Image attachments */
.gallery { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }
.gallery a { display: block; border: 1px solid var(--border-2); background: var(--bg); }
.gallery img { display: block; max-width: 220px; max-height: 160px; object-fit: cover; }
.gallery a:hover { border-color: var(--muted); }
label.attach { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
label.attach input[type="file"] { font-size: 12px; color: var(--muted); max-width: 240px; }
label.attach input[type="file"]::file-selector-button { font: inherit; font-size: 12px; background: var(--raise); color: var(--text); border: 1px solid var(--border-2); padding: 4px 10px; margin-right: 8px; cursor: pointer; }

/* Attachment previews (paste / pick) */
.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.previews:empty { display: none; }
.preview { position: relative; border: 1px solid var(--border-2); background: var(--bg); animation: rise 160ms ease-out both; }
.preview img { display: block; width: 88px; height: 66px; object-fit: cover; }
.preview-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border: 1px solid var(--border-2); background: rgba(11, 11, 13, 0.85); color: var(--text); font: inherit; font-size: 13px; line-height: 1; cursor: pointer; }
.preview-remove:hover { border-color: var(--muted); }
