:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1d2626;
  --muted: #5d6b6b;
  --line: #e2ddd2;
  --brand: #0f5257;
  --brand-ink: #ffffff;
  --brand-soft: #e3efee;
  --accent: #f2b134;
  --ok: #1f7a4a;
  --ok-soft: #e4f3ea;
  --bad: #b3361f;
  --bad-soft: #fbe9e5;
  --me: #dff0ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121717;
    --card: #1b2222;
    --ink: #e8eded;
    --muted: #9aa8a8;
    --line: #2c3636;
    --brand: #4fb3a9;
    --brand-ink: #0b1414;
    --brand-soft: #1d3332;
    --accent: #f2b134;
    --ok: #5cc48b;
    --ok-soft: #173126;
    --bad: #ef7d66;
    --bad-soft: #3a1f1a;
    --me: #1f3533;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 Inter, "Noto Sans Tamil", system-ui, sans-serif;
  min-height: 100vh;
}
:lang(ta) body, body:lang(ta) { font-family: "Noto Sans Tamil", Inter, system-ui, sans-serif; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.chip {
  border: 1px solid currentColor; background: transparent; color: inherit;
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 14px; cursor: pointer;
}

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.loading { text-align: center; font-size: 28px; margin-top: 30vh; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.text { white-space: pre-line; overflow-wrap: anywhere; }
.text code { background: var(--brand-soft); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.text i { color: var(--muted); }
.crumb { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.level { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-bottom: 10px; }
.level.l2 { background: #fdf1d8; color: #8a5a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .level.l2 { background: #3a2e14; color: var(--accent); } }

.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 2px 0 12px; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .2s; }

.btns { display: grid; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .05s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn:hover { background: var(--brand-soft); }
.btn.left { justify-content: flex-start; text-align: left; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; width: auto; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .badge { margin-left: auto; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.nav { margin-top: 14px; }
.nav .btn { min-height: 46px; font-weight: 500; color: var(--muted); }

.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 13px; padding: 1px 9px; font-weight: 700; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-grid .btn { min-height: 92px; flex-direction: column; gap: 4px; font-size: 15px; line-height: 1.3; }
.home-grid .btn .ico { font-size: 28px; }
.home-grid .btn.wide { grid-column: 1 / -1; min-height: 56px; flex-direction: row; }

.notice { border-left: 4px solid var(--accent); }
.notice .when { color: var(--muted); font-size: 13px; }
.alert { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 600; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=tel], input[type=password], input[type=search], textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; }
.err { color: var(--bad); font-weight: 600; margin: 8px 0 0; }
.link { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; padding: 8px 0; }
.muted { color: var(--muted); font-size: 14px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble { max-width: 86%; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); white-space: pre-line; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--me); border-color: transparent; }
.bubble .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.bubble img, .bubble video { max-width: 100%; border-radius: 10px; display: block; margin-top: 6px; }
.bubble audio { width: 240px; max-width: 100%; margin-top: 6px; }
.bubble .case-lines { font-size: 15px; margin-top: 6px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 6px; }
.composer textarea { min-height: 52px; height: 52px; }
.composer .row { margin-top: 8px; }
.composer .row .btn { min-height: 46px; }
.attach-note { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 6px; }

.list-item { display: flex; align-items: center; gap: 10px; }
.list-item .btn { flex: 1; }
.list-item .btn.small { flex: 0 0 auto; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); font-size: 15px; z-index: 10;
}
