/* Family documents: a household filing cabinet.
   Ledger-paper ground, navy ink, and one bold thing: categories drawn as manila folder tabs. */
:root {
  --paper: #e9eef1;        /* ledger paper */
  --sheet: #ffffff;
  --ink: #1b2a36;          /* fountain-pen navy */
  --muted: #566572;
  --rule: #c9d4db;         /* ledger lines */
  --manila: #e2c472;       /* folder tab */
  --manila-edge: #b99540;
  --stamp: #b2382b;        /* "needs a look" */
  --stamp-wash: #f7e6e3;
  --filed: #2b6a50;
  --focus: #1f6fd1;
  --radius: 6px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.55 var(--font);
}
a { color: var(--ink); text-decoration-color: var(--manila-edge); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 2rem 0 .5rem; }
p { margin: 0 0 1rem; }
.lede { color: var(--muted); max-width: 62ch; }
.quiet { color: var(--muted); font-size: .95rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.is-hidden { display: none !important; }

/* ── top bar ── */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem;
  padding: .75rem max(16px, calc((100% - 960px) / 2));
  background: var(--ink); color: #fff;
}
.top a, .top .link { color: #fff; }
.brand { font-weight: 700; text-decoration: none; margin-right: auto; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; }
.top nav a { text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { border-bottom-color: var(--manila); }
.signout { margin: 0; }

main { max-width: 960px; margin: 0 auto; padding: 1.75rem 16px 4rem; }
.narrow { max-width: 30rem; margin: 3rem auto; }

/* ── the folder tab ── */
.tab {
  display: inline-block; position: relative;
  padding: .15rem .9rem .2rem; font-size: .88rem; font-weight: 700; line-height: 1.35;
  background: var(--manila); color: #3d2f0c;
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 100%, 0 100%);
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 -2px 0 var(--manila-edge);
}

/* ── document drawer: rows ruled like a ledger ── */
.drawer { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--sheet);
  border: 1px solid var(--rule); border-radius: var(--radius); }
.row + .row { border-top: 1px solid var(--rule); }
.row-link, .row.move {
  display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .25rem 1rem; align-items: baseline;
  padding: .8rem 1rem; text-decoration: none; color: inherit;
}
.row.move { grid-template-columns: 1fr auto; }
.row-link:hover { background: #f6f8f9; }
.when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .95rem; }
.what { min-width: 0; }
.sender { font-weight: 700; display: block; overflow-wrap: anywhere; }
.title { display: block; color: var(--muted); overflow-wrap: anywhere; }
.why { display: block; color: var(--stamp); font-size: .92rem; margin-top: .15rem; }
.where { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; text-align: right; }
.person { font-size: .9rem; color: var(--muted); }

/* ── needs a look ── */
.attention { margin-bottom: 2rem; }
.attention h2 { margin-top: 0; color: var(--stamp); display: flex; align-items: center; gap: .6rem; }
.attention .count { background: var(--stamp); color: #fff; border-radius: 999px; padding: 0 .55rem;
  font-size: .9rem; line-height: 1.6; }
.attention .drawer { border-color: #e2b8b1; box-shadow: inset 4px 0 0 var(--stamp); }
.flag { background: var(--stamp-wash); color: var(--stamp); padding: .6rem .9rem;
  border-radius: var(--radius); font-weight: 700; }

/* ── forms ── */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; background: #fff; border: 1px solid #9fb0bc;
  border-radius: var(--radius);
}
textarea { resize: vertical; }
button, .button {
  display: inline-block; padding: .6rem 1.1rem; border: 0; border-radius: var(--radius);
  background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: #2c4253; }
.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.secondary:hover { background: #dfe6ea; }
button.link { background: none; padding: 0; font-weight: 400; text-decoration: underline;
  text-underline-offset: 3px; }
button.link:hover { background: none; }
.danger { color: var(--stamp) !important; }
.stack { display: grid; gap: .6rem; }
.stack label { font-weight: 700; }
.grid-form { display: grid; grid-template-columns: 11rem 1fr; gap: .7rem 1rem; align-items: center;
  max-width: 44rem; }
.grid-form label { font-weight: 700; }
.grid-form button { grid-column: 2; justify-self: start; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-top: 1rem; }
.inline-form select { width: auto; }
.filters { display: grid; grid-template-columns: 1fr 12rem 9rem auto; gap: .5rem; margin: 1rem 0; }

/* ── notices ── */
.notice { background: #e3efe9; color: var(--filed); border-left: 4px solid var(--filed);
  padding: .7rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; }
.notice.error { background: var(--stamp-wash); color: var(--stamp); border-left-color: var(--stamp); }
.empty { background: var(--sheet); border: 1px dashed var(--rule); border-radius: var(--radius);
  padding: 1.25rem; color: var(--muted); }

/* ── a single document ── */
.crumb { margin-bottom: .5rem; font-size: .95rem; }
.byline { color: var(--muted); font-size: 1.05rem; }
.summary { max-width: 62ch; }
.facts { display: grid; grid-template-columns: 11rem 1fr; gap: .35rem 1rem; margin: 1.25rem 0;
  padding: 1rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.fix, .suggest, .add-rule { margin-top: 2rem; }
.suggest { background: #fbf4dd; border: 1px solid var(--manila); border-radius: var(--radius); padding: 1rem 1.25rem; }
.suggest h2 { margin-top: 0; }
.trash { margin-top: 1rem; }

/* ── rules & categories ── */
.rules, .cats { list-style: none; margin: 0; padding: 0; background: var(--sheet);
  border: 1px solid var(--rule); border-radius: var(--radius); }
.rules li, .cats li { padding: .85rem 1rem; }
.rules li + li, .cats li + li { border-top: 1px solid var(--rule); }
.rules li { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.rules form { margin: 0; }
.rule-name { font-weight: 700; display: block; }
.rule-text { color: var(--muted); }
.rule-text .tab { margin-left: .2rem; }
.cats summary { cursor: pointer; display: flex; gap: .75rem; align-items: baseline; list-style: none; }
.cats summary::-webkit-details-marker { display: none; }
.cats .desc { color: var(--muted); font-size: .95rem; }
.cats details[open] summary { margin-bottom: .9rem; }
details.add { margin-top: 1rem; }
details.add summary { cursor: pointer; font-weight: 700; }
details.add form { margin-top: 1rem; }

/* ── reorganise ── */
.notes { padding-left: 1.2rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0; }
.actions form { margin: 0; }
.runs { list-style: none; padding: 0; }
.runs li { display: flex; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--rule); }
.state { font-weight: 700; }
.state.success { color: var(--filed); }
.state.failure { color: var(--stamp); }

/* ── phones ── */
@media (max-width: 640px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.45rem; }
  .top { padding: .6rem 16px; }
  .brand { width: 100%; }
  .row-link { grid-template-columns: 1fr; gap: .15rem; }
  .when { font-size: .85rem; }
  .where { flex-direction: row; align-items: center; justify-content: flex-start; gap: .6rem;
    margin-top: .35rem; text-align: left; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .filters button { grid-column: 1 / -1; }
  .grid-form, .facts { grid-template-columns: 1fr; }
  .grid-form button { grid-column: 1; }
  .grid-form label { margin-bottom: -.4rem; }
  .rules li { flex-direction: column; gap: .4rem; }
  .cats summary { flex-direction: column; gap: .3rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
