:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #dde2e8;
  --accent: #2456c9;
  --accent-text: #ffffff;
  --accent-soft: #e6edfb;
  --good: #1f7a4d;
  --good-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --high: #c0362c;
  --medium: #b7791f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", "Latha", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f25;
    --surface-2: #222830;
    --text: #e7eaee;
    --muted: #9aa5b1;
    --border: #2e3640;
    --accent: #6c97f5;
    --accent-text: #0d1117;
    --accent-soft: #1d2a44;
    --good: #4cc38a;
    --good-soft: #15291f;
    --warn: #e8a948;
    --warn-soft: #2e2413;
    --bad: #f07167;
    --bad-soft: #321a19;
    --high: #f07167;
    --medium: #e8a948;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
.muted { color: var(--muted); font-weight: normal; }
.center-msg { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* buttons */
button { cursor: pointer; }
.primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: .65rem 1.1rem; font-weight: 600;
}
.primary:disabled { opacity: .6; cursor: progress; }
.primary.small { padding: .45rem .8rem; font-size: .9rem; }
.secondary {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .9rem;
}
.link { background: none; border: 0; color: var(--accent); padding: 0 0 0 .75rem; text-decoration: underline; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; }
.lede { color: var(--muted); margin: 0 0 1.25rem; }
.tabs { display: flex; gap: .25rem; background: var(--surface-2); border-radius: 9px; padding: .25rem; margin-bottom: 1rem; }
.tab { flex: 1; border: 0; background: none; border-radius: 7px; padding: .5rem; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form input, .form select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-weight: normal;
}
.hint { font-size: .85rem; color: var(--muted); margin: 0; }
.error { color: var(--bad); margin: 0; min-height: 0; font-size: .9rem; }
.error:empty { display: none; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: .6rem 16px; display: flex; flex-wrap: wrap; gap: .4rem 1rem;
  align-items: center; justify-content: space-between;
}
.brand { font-weight: 700; }
.lang-chip { font-weight: 600; font-size: .85rem; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: .1rem .55rem; margin-left: .35rem; }
.who { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.status { font-size: .85rem; border-radius: 999px; padding: .15rem .65rem; background: var(--surface-2); color: var(--muted); }
.status.saved { background: var(--good-soft); color: var(--good); }
.status.offline { background: var(--warn-soft); color: var(--warn); }
.status.error { background: var(--bad-soft); color: var(--bad); }
.overall { max-width: 920px; margin: 0 auto; padding: 0 16px .4rem; display: flex; gap: .75rem; align-items: center; font-size: .82rem; color: var(--muted); }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--good); transition: width .3s; }
.task-tabs {
  max-width: 920px; margin: 0 auto; padding: 0 16px; display: flex; gap: .25rem; overflow-x: auto;
  scrollbar-width: none;
}
.task-tabs button {
  flex: 0 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; padding: .5rem .6rem .45rem;
  color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.task-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.task-tabs .count { font-weight: normal; font-size: .8rem; margin-left: .3rem; }
.task-tabs .count.done { color: var(--good); }

/* content */
.content { max-width: 920px; margin: 0 auto; padding: 1rem 16px 4rem; }
.welcome, .task-head, .task-done {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.welcome { background: var(--accent-soft); border-color: transparent; }
.welcome h2 { font-size: 1.05rem; }
.welcome ul { margin: 0 0 .75rem; padding-left: 1.2rem; }
.welcome li { margin-bottom: .3rem; }
.welcome p { margin: 0 0 .6rem; }
.welcome h3 { font-size: .98rem; margin: .8rem 0 .35rem; }
.welcome ol { margin: 0 0 .75rem; padding-left: 1.3rem; }
.task-head .how-title { font-size: .95rem; margin: .75rem 0 .3rem; }
.task-head .how { margin: 0; padding-left: 1.2rem; font-size: .93rem; }
.task-head .how li { margin-bottom: .3rem; }
.notice-box { background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn); border-radius: 6px; padding: .45rem .65rem; font-size: .9rem; margin: 0 0 .7rem; }
.task-head h2 { font-size: 1.2rem; }
.task-head p { margin: 0 0 .5rem; }
.task-head details { margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.task-head summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.task-head .ref-list { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.task-head .ref-list li { margin-bottom: .35rem; }
.task-head .ref-pairs { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.task-head .ref-pairs span { background: var(--surface-2); border-radius: 6px; padding: .05rem .45rem; font-size: .85rem; }
.task-done { text-align: center; background: var(--good-soft); border-color: transparent; color: var(--good); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: .25rem .75rem; font-size: .88rem; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* cards */
.cards { display: grid; gap: .9rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); scroll-margin-top: 170px;
}
.card.answered { border-left-color: var(--good); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-bottom: .35rem; }
.card-head h3 { font-size: 1.15rem; margin: 0; overflow-wrap: anywhere; }
.card-head .sub { color: var(--muted); font-size: .88rem; }
.card-head .num { margin-left: auto; color: var(--muted); font-size: .8rem; }
.card-head .done-mark { color: var(--good); font-size: .82rem; font-weight: 600; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em; border-radius: 5px; padding: .1rem .4rem; color: #fff; vertical-align: middle; }
.badge.high { background: var(--high); }
.badge.medium { background: var(--medium); }
@media (prefers-color-scheme: dark) { .badge { color: #111418; } }

.facts { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.facts b { color: var(--text); font-weight: 600; }
.entries { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .45rem; }
.entries li { background: var(--surface-2); border-radius: 8px; padding: .45rem .6rem; font-size: .93rem; overflow-wrap: anywhere; }
.entries .who { font-weight: 700; font-size: .78rem; color: var(--accent); margin-right: .35rem; white-space: nowrap; }
.entries .tag { font-size: .75rem; border-radius: 5px; padding: 0 .35rem; margin-right: .35rem; background: var(--surface); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.entries .tag.rejects { color: var(--bad); border-color: var(--bad); }
.entries .low { font-size: .72rem; color: var(--warn); margin-left: .35rem; white-space: nowrap; }
.entries .note { display: block; font-size: .84rem; color: var(--muted); margin-top: .2rem; }

.question { font-weight: 600; margin: .2rem 0 .55rem; }
.options { display: flex; flex-wrap: wrap; gap: .45rem; }
.opt {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 8px; padding: .5rem .85rem;
  font-weight: 600; font-size: .92rem; min-height: 44px;
}
.opt:hover { border-color: var(--accent); }
.opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.opt.multi::before { content: "☐ "; font-weight: normal; }
.opt.multi[aria-pressed="true"]::before { content: "☑ "; }
.merge-row { margin-top: .6rem; display: grid; gap: .3rem; font-size: .9rem; font-weight: 600; }
.merge-row input, .card textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font-weight: normal;
}
.card textarea { min-height: 70px; resize: vertical; }
.freetext textarea { min-height: 130px; }
.comment-toggle { margin-top: .6rem; background: none; border: 0; color: var(--accent); padding: 0; font-size: .88rem; }
.comment-box { margin-top: .45rem; }

@media (max-width: 560px) {
  body { font-size: 15px; }
  #user-email { display: none; }
  .who .link { padding-left: 0; }
  .topbar-inner { padding: .45rem 16px .3rem; gap: .3rem .6rem; }
  .brand { font-size: .95rem; }
  .overall { padding-bottom: .2rem; }
  .task-tabs button { padding: .4rem .5rem .35rem; font-size: .86rem; }
  .card { padding: .85rem .8rem; }
  .opt { flex: 1 1 auto; }
  .card-head .num { margin-left: 0; }
  .card { scroll-margin-top: 200px; }
}

/* admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.admin table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: .9rem; }
.admin th, .admin td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin th { background: var(--surface-2); font-weight: 600; }
.admin td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin .bar { min-width: 80px; }
.admin .table-wrap { overflow-x: auto; margin: .75rem 0 1.5rem; }
.admin .exports { display: flex; flex-wrap: wrap; gap: .75rem; margin: .5rem 0 1rem; }
.admin .exports div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.admin .exports a { color: var(--accent); margin-left: .5rem; }
.admin .temp { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--warn-soft); color: var(--warn); padding: .1rem .4rem; border-radius: 5px; }
.admin-login { max-width: 360px; margin: 4rem auto; }
