/* Pulse design system. Light + dark, responsive. No framework. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.14), rgba(236,72,153,.14));
  --accent: #7c5cff;
  --accent-ink: #6d28d9;

  --bg: #f6f7fb;
  --bg-2: #eef0f7;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --text: #191b2a;
  --muted: #6b7186;
  --border: #e7e9f2;
  --shadow: 0 1px 2px rgba(16,18,40,.04), 0 8px 24px rgba(16,18,40,.06);
  --shadow-lg: 0 12px 40px rgba(16,18,40,.12);

  --green: #16a34a; --green-bg: rgba(22,163,74,.12);
  --red: #e11d48;   --red-bg: rgba(225,29,72,.12);
  --amber: #d97706; --amber-bg: rgba(217,119,6,.13);
  --blue: #2563eb;  --blue-bg: rgba(37,99,235,.12);
  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f16; --bg-2: #12141d; --surface: #161925; --surface-2: #1b1f2c;
    --text: #e8eaf3; --muted: #9aa0b6; --border: #262a3a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
    --shadow-lg: 0 16px 50px rgba(0,0,0,.5);
    --green-bg: rgba(22,163,74,.18); --red-bg: rgba(225,29,72,.18);
    --amber-bg: rgba(217,119,6,.2); --blue-bg: rgba(37,99,235,.2);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { a { color: #b9a6ff; } }
h1,h2,h3,h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
small { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem 1.5rem; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800;
  font-size: 1.15rem; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(124,92,255,.4); }
.brand .mark svg { width: 18px; height: 18px; }
.nav { display: flex; gap: .25rem; align-items: center; }
.nav a { padding: .4rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent-ink); background: var(--grad-soft); }
@media (prefers-color-scheme: dark){ .nav a.active { color: #c4b5fd; } }
.topbar .spacer { margin-left: auto; }
.balance-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem;
  border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: .85rem;
  background: var(--surface-2); }
.balance-chip b { color: var(--green); }
.menu-btn { display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: .35rem .5rem; cursor: pointer; color: var(--text); }

main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.crumb { color: var(--muted); font-size: .85rem; margin-bottom: .3rem; }
.crumb a { color: var(--muted); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  padding: .55rem 1rem; border-radius: 10px; font-weight: 600; font-size: .9rem;
  border: 1px solid transparent; cursor: pointer; transition: .15s; font-family: inherit;
  background: var(--surface); color: var(--text); border-color: var(--border); }
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--grad); color: #fff; border: none;
  box-shadow: 0 6px 18px rgba(124,92,255,.32); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(124,92,255,.42); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { color: var(--red); border-color: var(--border); background: transparent; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

/* ---------- cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); }

.tile { display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.25rem; color: inherit;
  box-shadow: var(--shadow); transition: .18s; position: relative; overflow: hidden; }
.tile::before { content:''; position:absolute; inset:0 auto 0 0; width:4px; background:var(--grad);
  opacity: 0; transition:.18s; }
.tile:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tile:hover::before { opacity: 1; }
.tile h3 { margin-bottom: .35rem; }
.tile .meta { display: flex; gap: 1.1rem; color: var(--muted); font-size: .85rem; margin-top: .7rem; }
.tile .meta b { color: var(--text); font-weight: 700; }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted);
  margin-bottom: .3rem; }
input, textarea, select {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: .92rem;
  transition: .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,.16); }
textarea { resize: vertical; min-height: 68px; }
.field { margin-bottom: 1rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 130px; }
.hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  margin: 0 0 1.1rem; }
legend { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 0 .4rem; }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem;
  border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg-2);
  border: 1px solid var(--border); color: var(--muted); }
.chip.on { color: var(--accent-ink); background: var(--grad-soft); border-color: transparent; }
.badge { display:inline-block; padding:.15rem .5rem; border-radius:6px; font-size:.72rem;
  font-weight:700; }
.badge.pos { color: var(--green); background: var(--green-bg); }
.badge.neg { color: var(--red); background: var(--red-bg); }
.badge.neu { color: var(--muted); background: var(--bg-2); }
.badge.mix { color: var(--amber); background: var(--amber-bg); }

/* ---------- analysis sections ---------- */
.headline { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 1rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.insight { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem;
  background: var(--surface); border-left: 4px solid var(--muted); }
.insight h4 { text-transform: uppercase; font-size: .74rem; letter-spacing: .06em; color: var(--muted);
  margin-bottom: .55rem; }
.insight ul { margin: 0; padding-left: 1.1rem; } .insight li { margin-bottom: .35rem; }
.insight.pains { border-left-color: var(--red); }
.insight.objections { border-left-color: var(--amber); }
.insight.desires { border-left-color: var(--green); }
.insight.themes { border-left-color: var(--blue); }
.insight.opportunities { border-left-color: var(--accent); }
.insight.language { border-left-color: #0891b2; }

.gauge { display: flex; align-items: center; gap: 1rem; }
.gauge .ring { --p: 50; width: 84px; height: 84px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p)*1%), var(--bg-2) 0);
  display: grid; place-items: center; }
.gauge .ring::before { content: attr(data-v); width: 62px; height: 62px; border-radius: 50%;
  background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }

blockquote.quote { margin: 0 0 .8rem; padding: .8rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
blockquote.quote .orig { font-weight: 500; }
blockquote.quote .tr { color: var(--muted); font-size: .88rem; font-style: italic; margin-top: .3rem; }
blockquote.quote .qmeta { margin-top: .4rem; font-size: .75rem; color: var(--muted);
  display: flex; gap: .6rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; background: var(--surface); }
th, td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 700; white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- posts ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: .18s; display: flex; flex-direction: column; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.post-thumb { aspect-ratio: 4/5; background: var(--bg-2); overflow: hidden; }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-thumb .ph { width:100%; height:100%; display:grid; place-items:center; font-size:1.6rem; opacity:.4; }
.post-body { padding: .7rem .8rem; }
.post-body .stats { display: flex; gap: .8rem; font-size: .8rem; color: var(--muted); font-weight:600; }
.post-body .cap { font-size: .82rem; color: var(--text); margin-top: .4rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- misc ---------- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500;
  border: 1px solid transparent; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.err { background: var(--red-bg); color: var(--red); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.5rem; margin-bottom: .5rem; }
.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .3rem 0 1rem; }
.stat { }
.stat .v { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.stat .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing:.04em; }
.divider { height: 1px; background: var(--border); margin: 1.4rem 0; border: none; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; margin: 1.6rem 0 .7rem; }

/* ---------- multi-select ---------- */
.ms { position: relative; }
.ms-control { width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; min-height: 42px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); color: var(--text);
  font: inherit; cursor: pointer; text-align: left; }
.ms-control:focus, .ms-control:hover { border-color: var(--accent); }
.ms-summary { flex: 1; display: flex; flex-wrap: wrap; gap: .3rem; color: var(--muted);
  font-size: .9rem; }
.ms-summary.has { color: var(--text); }
.ms-chip { background: var(--grad-soft); color: var(--accent-ink); border-radius: 999px;
  padding: .1rem .55rem; font-size: .8rem; font-weight: 600; }
@media (prefers-color-scheme: dark){ .ms-chip { color: #c4b5fd; } }
.ms-caret { color: var(--muted); font-size: .8rem; }
.ms-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: .5rem; }
.ms-search { margin-bottom: .4rem; padding: .45rem .6rem; font-size: .88rem; }
.ms-options { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; }
.ms-opt { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem;
  border-radius: 7px; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--text);
  margin-bottom: 0; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { width: auto; }

/* auth */
.auth-wrap { min-height: 82vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; font-size: 1.4rem; margin-bottom: .3rem; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--muted); }

@media (max-width: 760px) {
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: .5rem; gap: .1rem; }
  .nav.open { display: flex; }
  .nav a { padding: .7rem .8rem; }
  .menu-btn { display: block; }
  .topbar { position: relative; }
  main { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.4rem; }
}
