:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #5f656d;
  --line: #e1ded6;
  --accent: #1f5a4c;
  --accent-soft: #e6efec;
  --late: #a3401c;
  --late-soft: #f8ebe5;
  --demo: #7a5a00;
  --demo-soft: #fbf3d9;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 "Noto Naskh Arabic", "Noto Kufi Arabic", system-ui, sans-serif;
}
h1, h2, nav, .brand, button, .value, .tag, th, .time, .meta, label { font-family: "Noto Kufi Arabic", system-ui, sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.num, .time { font-variant-numeric: tabular-nums; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.top nav a:hover { background: var(--bg); }
.top nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who form { margin: 0; }

.banner { background: var(--demo-soft); color: var(--demo); text-align: center; padding: 6px; font-weight: 600;
  border-bottom: 1px solid #ecdca6; font-family: "Noto Kufi Arabic", system-ui, sans-serif; font-size: 14px; }
main { max-width: 1120px; margin: 0 auto; padding: 24px; }
h1.page { font-size: 20px; margin: 0 0 16px; }

.notice { display: block; margin-bottom: 16px; padding: 10px 14px; background: var(--accent-soft); color: var(--accent);
  border-radius: var(--radius); text-decoration: none; font-family: "Noto Kufi Arabic", system-ui, sans-serif; }
.error { padding: 10px 14px; background: var(--late-soft); color: var(--late); border-radius: var(--radius); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card .question { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }
.card .value { margin: 0 0 6px; font-size: 24px; font-weight: 700; line-height: 1.3; }
.card ul { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.card li { padding: 2px 0; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { margin-bottom: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .time { min-width: 72px; color: var(--muted); font-size: 13px; }
.rows.board .num { margin-inline-start: auto; }
.late { color: var(--late); }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg);
  color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.late { background: var(--late-soft); color: var(--late); border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 600; font-size: 13px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.form-table input, .form-table select { width: 100%; }

input, select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text);
}
button {
  font-size: 14px; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer;
}
button.quiet { background: var(--surface); color: var(--text); border-color: var(--line); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chatlist { list-style: none; margin: 0; padding: 0; }
.chatlist a { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto auto; gap: 12px; align-items: baseline;
  padding: 10px 4px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.chatlist li:first-child a { border-top: 0; }
.chatlist a:hover { background: var(--bg); }
.chatlist .name { font-weight: 600; }
.chatlist .last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.chatlist .time { color: var(--muted); font-size: 13px; }

.thread { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.msg, .draft { max-width: 80%; padding: 8px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; background: var(--accent-soft); border-color: #cfe0db; }
.draft { align-self: flex-end; border-style: dashed; background: transparent; }
.draft.status-review_failed, .draft.status-lint_failed, .draft.status-failed { border-color: var(--late); }
.meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kind { font-size: 13px; color: var(--muted); }
.text { white-space: pre-wrap; }
.notes { margin-top: 6px; font-size: 13px; color: var(--late); }

.approval .bubbles p { margin: 6px 0; padding: 8px 12px; background: var(--accent-soft); border-radius: var(--radius); display: inline-block; }
.approval .bubbles { display: flex; flex-direction: column; align-items: flex-start; }
.question-text { white-space: pre-wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-top: 10px; }
.actions form { display: flex; gap: 8px; margin: 0; }
.actions details summary { cursor: pointer; color: var(--accent); padding: 6px 0; font-family: "Noto Kufi Arabic", system-ui, sans-serif; font-size: 14px; }
.edit { flex-direction: column; min-width: min(420px, 80vw); }
.edit textarea { width: 100%; }
.file { margin-inline-end: 8px; font-family: system-ui, sans-serif; font-size: 13px; }
.demo-controls { display: flex; gap: 8px; margin-top: 24px; }
.demo-controls form { margin: 0; }

.login { max-width: 340px; margin: 12vh auto; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login h1 { margin: 0; font-size: 22px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

@media (max-width: 720px) {
  main { padding: 16px; }
  .top { padding: 10px 16px; }
  /* 14 links: wrap into rows (a scroll strip hid most of them); no link breaks across lines */
  .top nav { order: 3; flex-basis: 100%; gap: 2px; }
  .top nav a { white-space: nowrap; padding: 5px 8px; font-size: 13px; }
  .who { margin-inline-start: auto; }
  .two { grid-template-columns: 1fr; }
  .chatlist a { grid-template-columns: 1fr auto; }
  .chatlist .last { grid-column: 1 / -1; grid-row: 2; }
  .msg, .draft { max-width: 92%; }
  table { display: block; overflow-x: auto; }
}
