:root {
  --wa-green: #25d366;
  --wa-teal: #075e54;
  --bg: #eae6df;
  --ink: #111b21;
  --muted: #667781;
  --card: #ffffff;
  --line: #e9edef;
  --err: #b42318;
  --bub-out: #d9fdd3;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- login ---------- */
.login-body, .home-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 400px at 50% -10%, #d9fdd3 0%, transparent 60%), var(--bg);
}
.login-card, .placeholder {
  background: var(--card);
  width: 100%;
  max-width: 340px;
  padding: 32px 28px;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; margin-bottom: 8px; }
h1 { font-size: 22px; margin: 4px 0 2px; color: var(--wa-teal); }
.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
input[type="password"], .sb-search input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #d1d7db;
  border-radius: 8px;
  font-size: 14px;
}
input[type="password"]:focus, .sb-search input:focus {
  outline: none;
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}
input[type="password"] { margin-bottom: 12px; }
button {
  padding: 11px 13px;
  border: none;
  border-radius: 8px;
  background: var(--wa-green);
  color: #04391f;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
button:hover { filter: brightness(0.97); }
.err { background: #fde8e8; color: var(--err); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }

/* ---------- app shell ---------- */
.app-body { overflow: hidden; }
.app { display: flex; height: 100vh; }

.sidebar { width: 312px; min-width: 312px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #f0f2f5; border-bottom: 1px solid var(--line); }
.sb-title { font-weight: 700; color: var(--wa-teal); }
.ghost-sm { width: auto; padding: 5px 12px; background: transparent; border: 1px solid #d1d7db; color: var(--muted); font-size: 12px; font-weight: 500; }
.sb-search { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.sb-list { overflow-y: auto; flex: 1; }
.sb-empty { padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }

.conv-item { display: block; padding: 9px 14px; border-bottom: 1px solid #f3f5f6; text-decoration: none; color: var(--ink); cursor: pointer; }
.conv-item:hover { background: #f5f6f7; }
.conv-item.active { background: #eef1f2; }
.ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ci-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-ts { font-size: 11px; color: #8696a0; white-space: nowrap; }
.ci-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ---------- main (thread + context) ---------- */
.main { flex: 1; display: flex; min-width: 0; }
.main.loading { opacity: 0.5; transition: opacity 0.15s; }

.center { flex: 1; display: flex; flex-direction: column; min-width: 0; background-image: linear-gradient(rgba(229, 221, 213, 0.45), rgba(229, 221, 213, 0.45)); }
.center.empty { align-items: center; justify-content: center; color: var(--muted); }
.empty-ic { font-size: 48px; opacity: 0.5; }
.empty-sm { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

.thread-head { background: #f0f2f5; padding: 10px 16px; border-bottom: 1px solid #e0e0e0; }
.th-name { font-weight: 700; font-size: 15px; }
.th-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge { background: var(--wa-green); color: #04391f; border-radius: 9px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.badge.warn { background: #fde8c8; color: #92400e; }
.pd-link { color: #1f6feb; text-decoration: none; }
.pd-link:hover { text-decoration: underline; }

.thread { flex: 1; overflow-y: auto; padding: 16px 18px; }
.fup { text-align: center; margin: 12px 0; }
.fup span { background: #ffeecf; color: #7a5c1e; font-size: 11px; padding: 3px 12px; border-radius: 10px; }
.bub { max-width: 70%; padding: 6px 10px; border-radius: 8px; font-size: 13.5px; line-height: 1.35; margin: 5px 0; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06); white-space: pre-wrap; word-wrap: break-word; }
.bub.out { background: var(--bub-out); margin-left: auto; }
.bub.in { background: #fff; }
.aud { opacity: 0.7; }

.context { width: 288px; min-width: 288px; background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; padding: 6px 0; }
.cx { padding: 10px 14px; border-bottom: 1px solid #f3f5f6; font-size: 13px; line-height: 1.45; }
.cx h5 { margin: 0 0 5px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #8696a0; }
.acc { display: inline-block; padding: 2px 8px; border-radius: 9px; font-size: 12px; font-weight: 600; }
.acc.bad { background: #fde8e8; color: #b42318; }
.acc.warn { background: #fef3c7; color: #92400e; }
.acc.ok { background: #e7f8ec; color: #1a7f43; }
.acc.muted { background: #eef1f2; color: var(--muted); }
.ck { display: block; margin: 3px 0; font-size: 12.5px; }
.ck .y { color: #1a7f43; font-weight: 700; }
.ck .n { color: #c0392b; }
.ck .v { color: var(--muted); }
.ck-count { margin-top: 6px; font-size: 11px; color: #8696a0; }
.cad { font-size: 12.5px; margin: 2px 0; }

@media (max-width: 820px) {
  .context { display: none; }
  .sidebar { width: 220px; min-width: 220px; }
}
