/* Served as /styles.css (stored as .txt so the Worker bundles it as text). */
:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --accent-soft: #e6efeb;
  --danger: #b42318;
  --warn-bg: #fef6e7;
  --warn-text: #8a5300;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1d1c1a;
    --text: #ece9e6;
    --muted: #a19b95;
    --border: #2f2d2a;
    --accent: #7fb8a4;
    --accent-text: #0f1a16;
    --accent-soft: #20302a;
    --danger: #f97066;
    --warn-bg: #33270f;
    --warn-text: #f5c56b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
code { background: var(--accent-soft); padding: 0.1em 0.35em; border-radius: 4px; word-break: break-all; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }
.narrow { max-width: 680px; margin: 0 auto; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.topnav { display: flex; align-items: center; gap: 16px; font-size: 0.95rem; }
.project-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.project-bar .wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 10px; }
.project-name { font-weight: 700; font-size: 1.1rem; color: var(--text); padding-bottom: 10px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  padding: 8px 12px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Building blocks */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.wrap-row { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2, .section-head h1 { margin: 0; }
.section-head h2 a { color: var(--text); }
.crumbs { margin: 0 0 12px; font-size: 0.9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid .card { margin: 0; }
.project-card, .doc-card { color: var(--text); display: block; }
.project-card:hover, .doc-card:hover { text-decoration: none; border-color: var(--accent); }
.project-card p, .doc-card p { margin: 0.25em 0 0; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.flash { background: var(--accent-soft); color: var(--text); padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: 8px 12px; border-radius: 8px; }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: middle;
}
.status-quarantined { background: var(--warn-bg); color: var(--warn-text); }
.status-discarded, .status-ignored { background: var(--border); color: var(--muted); }
.email-callout { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; margin: 0 0 20px; overflow-wrap: anywhere; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea, button, .button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.input-suffix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow: hidden; }
.input-suffix input { border: 0 !important; border-radius: 0 !important; min-width: 0; }
.input-suffix span { padding: 0 11px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.title-input { font-size: 1.4rem !important; font-weight: 700 !important; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 0.92rem; line-height: 1.3; white-space: nowrap;
}
button:hover, .button:hover { text-decoration: none; border-color: var(--muted); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.danger { color: var(--danger); }
.small.button, button.small { padding: 4px 10px; font-size: 0.82rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; font-size: inherit; }
form.stack > button { align-self: flex-start; }
.file-input { flex-direction: row; align-items: center; font-weight: 400; cursor: pointer; color: var(--accent); position: relative; }
.file-input input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Editor */
.editor { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); }
.editor-bar { display: flex; align-items: center; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
.editor-bar .seg { border: 0; background: none; padding: 4px 10px; font-size: 0.85rem; color: var(--muted); }
.editor-bar .seg.active { background: var(--accent-soft); color: var(--text); }
.editor-bar .hint { margin-left: auto; font-size: 0.78rem; color: var(--muted); padding-right: 6px; }
.editor textarea { border: 0 !important; border-radius: 0 !important; outline: none; }
.editor .preview { padding: 12px 14px; min-height: 120px; }

/* Rendered markdown */
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose img { max-width: 100%; border-radius: 6px; }
.prose blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--border); color: var(--muted); }
.prose pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; }
pre.email-body { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 8px; max-height: 400px; overflow: auto; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
ul.list.card { padding: 4px 20px; }
.avatar {
  --hue: 160;
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: hsl(var(--hue) 45% 28%); background: hsl(var(--hue) 45% 88%);
}
@media (prefers-color-scheme: dark) {
  .avatar { color: hsl(var(--hue) 50% 85%); background: hsl(var(--hue) 30% 26%); }
}
.avatar.h0 { --hue: 0; } .avatar.h1 { --hue: 30; } .avatar.h2 { --hue: 60; } .avatar.h3 { --hue: 90; }
.avatar.h4 { --hue: 120; } .avatar.h5 { --hue: 150; } .avatar.h6 { --hue: 180; } .avatar.h7 { --hue: 210; }
.avatar.h8 { --hue: 240; } .avatar.h9 { --hue: 270; } .avatar.h10 { --hue: 300; } .avatar.h11 { --hue: 330; }

.overview { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.overview .card { margin: 0; }

.threads { list-style: none; padding: 0; overflow: hidden; }
.threads li + li { border-top: 1px solid var(--border); }
.thread-link { display: flex; gap: 14px; align-items: center; padding: 14px 20px; color: var(--text); }
.thread-link:hover { background: var(--bg); text-decoration: none; }
.threads.card { padding: 0; }
.thread-title { font-weight: 600; }
.thread-link .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 8px; font-weight: 700; }
.pager { display: flex; justify-content: space-between; }

.message header, .comment header { margin-bottom: 12px; }
.comments { margin-left: 24px; }
.comment { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-form { margin-top: 16px; }
.attachments { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments li { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 0.88rem; }

/* To-dos */
.todos { list-style: none; padding: 0; margin: 0 0 8px; }
.todo { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.todo-title { color: var(--text); }
.todo.done .todo-title { text-decoration: line-through; color: var(--muted); }
.assignee { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.due { font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); white-space: nowrap; margin-left: 6px; }
.due.overdue { color: var(--danger); border-color: currentColor; }
.add-todo { display: grid; grid-template-columns: 1fr 160px 150px auto; gap: 8px; margin-top: 8px; }
.completed summary { cursor: pointer; margin-top: 8px; }
.new-list { padding: 12px; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 280px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}

/* Docs */
.doc h1 { font-size: 1.8rem; }
.doc-form .editor textarea { min-height: 50vh; }

/* Files */
.table { width: 100%; border-collapse: collapse; padding: 0; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table td a { overflow-wrap: anywhere; }
.num { text-align: right !important; white-space: nowrap; }

/* Inbox */
.inbound-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.inbound-actions select { width: auto; }

@media (max-width: 720px) {
  .overview, .two { grid-template-columns: 1fr; }
  .project-bar .wrap { gap: 0; }
  .project-name { padding-bottom: 2px; }
  .tabs { margin: 0 -12px; }
  .todo { flex-wrap: wrap; row-gap: 2px; }
  .todo .grow { flex-basis: calc(100% - 40px); }
  .todo form + .grow ~ .assignee, .todo form + .grow ~ .due { margin-left: 0; }
  .todo form + .grow + .assignee { margin-left: 28px; }
  .todo form + .grow + .due { margin-left: 28px; }
  .add-todo { grid-template-columns: 1fr 1fr; }
  .add-todo input[name=title] { grid-column: 1 / -1; }
  .comments { margin-left: 0; }
  .hide-sm { display: none; }
  .thread-link { padding: 12px 14px; }
  .card { padding: 16px; }
  ul.list.card { padding: 4px 16px; }
  .topnav { gap: 12px; font-size: 0.88rem; }
}
