:root {
  --red: #e30613;
  --red-dark: #b8050f;
  --black: #0a0a0a;
  --navy: #0a0a66;
  --grey: #585858;
  --grey-light: #d9d9d9;
  --surface: #f6f5f2;
  --card: #ffffff;
  --text: #171717;
  --muted: #6b6b6b;
  --amber: #b26a00;
  --amber-bg: #fff4e0;
  --green: #1f6f3f;
  --green-bg: #e7f4ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--navy); }
a:hover { color: var(--red); }
button, input, textarea, select { font: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }

/* ---- layout ---- */
.topbar {
  background: var(--black);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.topbar .brand img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.topbar .brand b { font-style: italic; color: var(--red); font-size: 1.1rem; letter-spacing: 0.2px; }
.topbar .brand span { display: block; font-size: 0.75rem; color: #cfcfcf; letter-spacing: 0.4px; text-transform: uppercase; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { color: #e6e6e6; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { background: #262626; color: #fff; }
.topbar .who { color: #cfcfcf; font-size: 0.9rem; white-space: nowrap; }
.topbar .who button { background: none; border: 1px solid #444; color: #ddd; padding: 4px 10px; border-radius: 6px; margin-left: 8px; cursor: pointer; }
.topbar .who button:hover { border-color: #888; color: #fff; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.wrap.narrow { max-width: 820px; }
.wrap.wide { max-width: 1400px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.btn {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--red-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--grey-light); }
.btn.secondary:hover { border-color: var(--navy); background: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eee;
  color: var(--grey);
  vertical-align: middle;
}
.badge.partial { background: var(--amber-bg); color: var(--amber); }
.badge.open { background: #fde8ea; color: var(--red-dark); }
.badge.new { background: #e8e8f7; color: var(--navy); }
.badge.answered { background: var(--green-bg); color: var(--green); }
.badge.owner { background: #f1f1f1; color: #444; text-transform: none; letter-spacing: 0; font-weight: 600; }
.badge.mine { background: var(--navy); color: #fff; text-transform: none; letter-spacing: 0; }
.badge.final { background: var(--green); color: #fff; }

.progress { height: 8px; background: #e8e8e8; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); width: 0; transition: width 0.3s; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 420px; text-align: center; padding: 32px 28px; }
.login img { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; margin-bottom: 12px; }
.login input {
  width: 100%;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  border: 2px solid var(--grey-light);
  border-radius: 8px;
  margin: 12px 0;
}
.login input:focus { outline: none; border-color: var(--navy); }
.login .btn { width: 100%; padding: 12px; font-size: 1.05rem; }
.error { color: var(--red-dark); font-weight: 600; min-height: 1.4em; }

/* ---- home ---- */
.hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.hero img { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; }
.stat { font-size: 2rem; font-weight: 700; line-height: 1; }
.tile a { text-decoration: none; }
.tile h3 { margin-bottom: 4px; }

/* ---- artifacts ---- */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } .side { position: static !important; } }
.side { position: sticky; top: 80px; align-self: start; }
.side a { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.side a:hover { background: #ececec; }
.side a.active { background: var(--black); color: #fff; }

.doc { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; overflow-wrap: anywhere; }
.doc h1 { font-size: 1.7rem; margin-top: 0; }
.doc h2 { font-size: 1.3rem; margin-top: 1.8em; padding-bottom: 0.25em; border-bottom: 2px solid #eee; }
.doc h3 { font-size: 1.1rem; margin-top: 1.4em; }
.doc table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.93rem; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid #e3e3e3; padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { background: #f3f3f3; }
.doc code { background: #f2f2f2; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.doc pre { background: #111; color: #eee; padding: 14px; border-radius: 8px; overflow-x: auto; }
.doc pre code { background: none; color: inherit; padding: 0; }
.doc blockquote { border-left: 4px solid var(--red); margin: 1em 0; padding: 4px 16px; color: #444; background: #faf6f6; }
.doc img { max-width: 100%; }
.doc hr { border: 0; border-top: 1px solid #e5e5e5; margin: 2em 0; }
.doc li { margin: 0.25em 0; }
.doc input[type=checkbox] { margin-right: 6px; }

/* ---- questionnaire ---- */
.sec-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.sec-nav a { text-decoration: none; font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--grey-light); color: var(--text); }
.sec-nav a.mine { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.sec-nav a.done { background: var(--green-bg); border-color: var(--green-bg); color: var(--green); }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.section-head .meta { color: var(--muted); font-size: 0.9rem; }
.section-head .progress { flex-basis: 100%; }
.q { border-left: 4px solid transparent; }
.q.partial { border-left-color: var(--amber); }
.q.open { border-left-color: var(--red); }
.q.new { border-left-color: var(--navy); }
.q.answered { border-left-color: var(--green); background: #fafaf8; color: var(--muted); }
.q-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; font-size: 1.05rem; }
.q.answered .q-title { color: #444; }
.q-num { color: var(--muted); font-weight: 500; }
.q-detail { margin: 6px 0 0; color: #444; }
.q.answered .q-detail { color: var(--muted); }
.q-still { margin: 8px 0 0; padding: 8px 12px; background: var(--amber-bg); border-radius: 6px; color: #5e3a00; }
.q-still b { color: var(--amber); }
.q-answer { margin-top: 12px; }
.q-answer textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--grey-light);
  border-radius: 8px;
  resize: vertical;
  background: #fff;
}
.q-answer textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(10, 10, 102, 0.1); }
.q-answer textarea:disabled { background: #f3f3f3; color: #999; }
.q-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 0.9rem; }
.q-tools label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.q-tools input[type=text] { padding: 6px 10px; border: 1px solid var(--grey-light); border-radius: 6px; width: 180px; }
.q-tools .status { margin-left: auto; color: var(--muted); }
.q-tools .status.saving { color: var(--amber); }
.q-tools .status.saved { color: var(--green); }
.q-tools .status.error { color: var(--red-dark); }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.95rem; }
.switch { cursor: pointer; }

.mic { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--navy); border: 1px solid var(--navy); border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer; }
.mic:hover { background: #f0f0fa; }
.mic.listening { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.mic.busy { opacity: 0.7; cursor: wait; }
.mic svg { width: 16px; height: 16px; fill: currentColor; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(227, 6, 19, 0.45); } 50% { box-shadow: 0 0 0 8px rgba(227, 6, 19, 0); } }
.q-answer textarea.listening { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12); }
.interim { color: var(--muted); font-style: italic; font-size: 0.9rem; min-height: 1.2em; margin-top: 4px; }

/* ---- admin ---- */
.admin-q { margin-bottom: 14px; }
.admin-q .q-title { font-size: 1rem; }
.answers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 10px; }
.ans { border: 1px solid #e6e6e6; border-radius: 8px; padding: 10px 12px; background: #fcfcfc; font-size: 0.95rem; display: flex; flex-direction: column; gap: 6px; }
.ans.is-final { border-color: var(--green); background: var(--green-bg); }
.ans.empty { color: #aaa; background: #fafafa; border-style: dashed; }
.ans .who { font-weight: 700; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.ans .when { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.ans .body { white-space: pre-wrap; }
.ans .nma { color: var(--amber); font-style: italic; }
.ans .mark { margin-top: auto; align-self: flex-start; }
.summary-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.summary-row .stat { font-size: 1.6rem; }
table.progress-table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
table.progress-table th, table.progress-table td { padding: 6px 10px; border-bottom: 1px solid #eee; text-align: left; }
table.progress-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- placeholder ---- */
.placeholder { min-height: 100vh; display: grid; place-items: center; background: var(--black); color: #fff; text-align: center; padding: 24px; }
.placeholder img { width: 180px; height: 180px; border-radius: 16px; object-fit: cover; margin-bottom: 20px; }
.placeholder h1 { font-style: italic; color: var(--red); font-size: 2.2rem; margin-bottom: 4px; }
.placeholder .sub { text-transform: uppercase; letter-spacing: 2px; font-size: 0.9rem; color: #ddd; margin-bottom: 20px; }
.placeholder .tag { color: #fff; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.placeholder .tag b { color: var(--red); }
.placeholder p { color: #bbb; }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar .brand b { white-space: nowrap; }
  .topbar .brand span { display: none; }
  .topbar nav { order: 3; flex-basis: 100%; margin-left: 0; justify-content: space-between; }
  .topbar nav a { padding: 6px 8px; font-size: 0.9rem; flex: 1; text-align: center; }
  .topbar .who { margin-left: auto; }
  .topbar .who span { display: none; }
  .wrap { padding: 16px 12px 60px; }
  .doc { padding: 18px 16px; }
  .card { padding: 14px; }
}
