/* Acme Notes - one stylesheet for every page. No inline styles anywhere (strict CSP: style-src 'self'). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #15171c;
  --text-2: #3d424d;
  --muted: #646a76;
  --line: #e5e7ec;
  --line-strong: #d4d8df;
  --accent: #0f6e63;
  --accent-hover: #0b5a51;
  --accent-soft: #e6f3f1;
  --accent-ink: #0a4d45;
  --warn-soft: #fff6e5;
  --warn-ink: #7a4b00;
  --danger: #b42318;
  --ring: 0 0 0 3px rgba(15, 110, 99, .22);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 680; }
h2 { font-size: 1.05rem; font-weight: 640; }
h3 { font-size: .98rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); min-height: 61px; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 28px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 680; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; flex: none; background: var(--accent) url("../img/mark.svg") center / 18px no-repeat; }
.brand small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--text-2); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 520; font-size: .93rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-size: .9rem; font-weight: 560; line-height: 1.2; text-align: right; }
.user-name span { display: block; color: var(--muted); font-weight: 450; font-size: .78rem; }
.signout { font-size: .85rem; color: var(--muted); text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; }
.signout:hover { color: var(--text); border-color: var(--line-strong); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: .78rem; font-weight: 650; color: #fff; background: #5b6472; }
.avatar.u1 { background: #0f6e63; } .avatar.u2 { background: #4f5bd5; } .avatar.u3 { background: #b4527a; } .avatar.u4 { background: #9a6a12; }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.wrap.narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .shared-grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 520; }
.stat .value { font-size: 1.75rem; font-weight: 680; letter-spacing: -.02em; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.loading { color: var(--muted); padding: 24px 0; }
.error-box { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; border-radius: var(--radius-sm); padding: 12px 14px; }
.notice { background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 20px; }
.empty h1 { margin-bottom: 8px; }
.empty p + p { margin-top: 16px; }

/* ---------- buttons, pills ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: 600 .92rem var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); color: var(--text); }
.pill { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); vertical-align: 1px; white-space: nowrap; }
.pill-admin { background: var(--accent-soft); color: var(--accent-ink); border-color: #c4e3de; }
.pill-member { background: #eef0fd; color: #343e9e; border-color: #d5d9f8; }
.pill-guest { background: var(--warn-soft); color: var(--warn-ink); border-color: #f5dfb3; }
.pill-shared { background: var(--warn-soft); color: var(--warn-ink); border-color: #f5dfb3; }
.tag { display: inline-block; font-size: .76rem; padding: 1px 8px; border-radius: 6px; background: #f1f3f6; color: var(--text-2); margin: 0 4px 4px 0; }
.tag::before { content: "#"; color: var(--muted); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 580; overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: .84rem; }
.list li > .pill:first-child { min-width: 72px; text-align: center; }
.team-row .who { flex: 1; min-width: 0; }
.team-row .email { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.team-row .side { text-align: right; font-size: .84rem; color: var(--muted); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label, .field .label { font-weight: 580; font-size: .92rem; }
.field .help { color: var(--muted); font-size: .82rem; }
input[type="text"], input[type="email"], input[type="search"], select, textarea {
  width: 100%; font: 15px/1.4 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea { min-height: 260px; resize: vertical; line-height: 1.6; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 520; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check .help { display: block; font-weight: 400; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.form-actions .status { color: var(--muted); font-size: .86rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.search { max-width: 320px; }

/* ---------- notes table (member/notes.html) ---------- */
/* DEMO BUG 1 (intentional, see DEMO-BUGS.md): the table is forced to 820px and its cells never wrap, and it is NOT inside
   a scroll container, so on a 390px phone the whole page scrolls sideways. The fix is a wrapper with overflow-x: auto
   (or a card layout below 640px). */
.notes-table { width: 100%; min-width: 820px; border-collapse: collapse; white-space: nowrap; background: var(--surface); }
.notes-table th { text-align: left; font-size: .78rem; font-weight: 620; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.notes-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.notes-table tr:last-child td { border-bottom: 0; }
.notes-table tbody tr:hover { background: #fbfcfc; }
.notes-table .t a { color: var(--text); font-weight: 580; text-decoration: none; }
.notes-table .t a:hover { color: var(--accent); text-decoration: underline; }
.notes-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-card { padding: 0; }
.notes-table thead th:first-child { border-top-left-radius: var(--radius); }
.notes-table thead th:last-child { border-top-right-radius: var(--radius); }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

/* ---------- editor ---------- */
.editor-title { font-size: 1.25rem; font-weight: 640; padding: 10px 12px; }
.editor-side .field:last-child { margin-bottom: 0; }

/* ---------- guest shared page ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 220px; align-items: center; gap: 24px; background: linear-gradient(135deg, #ecf6f4, #f6f2ea); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px; }
.hero img { width: 100%; height: auto; display: block; }
.hero p { color: var(--text-2); margin-top: 8px; max-width: 52ch; }
.shared-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.shared-card h2 { margin-bottom: 6px; }
.shared-card .meta { color: var(--muted); font-size: .84rem; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.shared-card .excerpt { color: var(--text-2); }
.shared-card details { margin-top: 12px; }
.shared-card summary { cursor: pointer; color: var(--accent); font-weight: 580; font-size: .9rem; }
.shared-card .full { white-space: pre-line; margin-top: 8px; color: var(--text-2); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); background: #15171c; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- dev sign-in page ---------- */
.dev-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 24px; }
.dev-head .brand-mark { width: 44px; height: 44px; border-radius: 11px; background-size: 26px; }
.dev-head p { margin-top: 4px; }
.dev h2 { margin-bottom: 12px; }
.role-list, .tool-list { list-style: none; margin: 0; padding: 0; }
.role-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.role-list li:first-child { border-top: 0; padding-top: 0; }
.tool-list li { padding: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.tool-list code { white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 1.35rem; }
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .nav a { padding: 6px 10px; }
  .user-name { display: none; }
  .wrap { padding: 20px 16px 48px; }
  .card { padding: 16px; }
  .stat { padding: 14px 16px; }
  .stat .value { font-size: 1.45rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .hero img { max-width: 130px; }
  .page-head .search { width: 100%; margin-bottom: 0; }
  .team-row { flex-wrap: wrap; }
  .team-row .side { flex-basis: 100%; text-align: left; padding-left: 46px; margin-top: -4px; }
  .team-row .side br { display: none; }
  .team-row .side span:last-child::before { content: "\00a0·\00a0"; }
  .shared-grid { grid-template-columns: minmax(0, 1fr); }
  .role-list li { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head .btn { width: 100%; }
  .search { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
