/* Prothom Alo archive assistant — black and red.

   Both colours come out of the masthead SVG itself rather than being picked by
   eye: #ee4023 is the sun, #231f20 the wordmark. Night is the default; the
   day theme keeps the same two-colour identity on the paper's own white.

   Their Shurjo typeface is proprietary, so Noto Serif Bengali stands in for
   headlines and Noto Sans Bengali for the interface. */

:root {
  --pa-red: #ee4023;
  --pa-red-bright: #ff5b40;
  --pa-red-deep: #c22f16;

  --chrome: #0a0a0b;          /* masthead + reader bar */
  --ground: #101012;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --ink: #f2f2f3;
  --ink-soft: #b6b6bd;
  --ink-faint: #83838c;
  --line: #2b2b31;
  --line-soft: #212126;
  --tint: rgba(238, 64, 35, .13);
  --prose: #dcdce1;
  --accent-text: #ff5b40;     /* red that reads on this ground */

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-lg: -10px 0 40px rgba(0, 0, 0, .6);
  --serif: "Noto Serif Bengali", "Shurjo", Georgia, serif;
  --sans: "Noto Sans Bengali", "Shurjo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  --chrome: #ffffff;
  --ground: #f6f6f6;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-faint: #7b7b7b;
  --line: #e2e5ea;
  --line-soft: #eef0f3;
  --tint: rgba(238, 64, 35, .08);
  --prose: #23262b;
  --accent-text: #c22f16;     /* the bright red washes out on white */

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: -8px 0 32px rgba(16, 24, 40, .16);
}

* { box-sizing: border-box; }

/* The `hidden` attribute sets `display: none`, but any explicit `display` in a
   rule below beats it on specificity — which would leave the reading panel and
   its scrim visible on load. Restore the attribute's meaning first. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--pa-red); color: #fff; }

/* ---------- app shell ---------- */

.app { display: flex; min-height: 100vh; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- sidebar ---------- */

.sidebar {
  width: 264px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 25;
}

.sidebar-top { padding: 14px 14px 10px; }

.new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.new-chat:hover { border-color: var(--pa-red); color: var(--accent-text); background: var(--tint); }

.sessions-head {
  padding: 12px 18px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sessions { flex: 1; overflow-y: auto; padding: 0 8px 8px; }

.session {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 2px;
  cursor: pointer;
  font: inherit;
  color: var(--ink-soft);
  text-align: start;
  transition: background .12s, color .12s;
}

.session:hover { background: var(--surface-2); color: var(--ink); }

.session.active { background: var(--tint); color: var(--ink); }

.session-main { flex: 1; min-width: 0; }

.session-title {
  font-size: 13.5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-date { font-size: 11.5px; color: var(--ink-faint); }

.session-del {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: none;
  flex: none;
}

.session:hover .session-del { display: grid; place-items: center; }
.session-del:hover { color: var(--pa-red); background: var(--surface); }

.sessions-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-faint);
}

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.foot-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.foot-btn:hover { background: var(--surface-2); color: var(--ink); }

/* In the dark theme the button offers daylight; in the light theme, night. */
.icon-moon { display: none; }
:root[data-theme="light"] .icon-moon { display: inline; }
:root[data-theme="light"] .icon-sun { display: none; }

.sidebar-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 24;
}

/* ---------- masthead ---------- */

.masthead {
  background: var(--chrome);
  position: sticky;
  top: 0;
  z-index: 20;
}

.masthead-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

.brand { display: flex; align-items: center; gap: 13px; }

/* Doubled class beats the generic .icon-btn display further down. */
.menu-btn.menu-btn { display: none; }

/* The asset is 230×55; height drives it so the wordmark keeps its proportions. */
.logo { height: 34px; width: auto; display: block; }

.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.brand-sub {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: .2px;
}

.masthead-meta {
  font-size: 13px;
  color: var(--ink-faint);
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.meta-chip { display: inline-flex; align-items: center; gap: 6px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pa-red); }
.dot.off { background: var(--line); }

/* The red rule under the masthead is the paper's own signature. */
.masthead-rule { height: 3px; background: var(--pa-red); }

/* ---------- chat shell ---------- */

.shell { max-width: 880px; margin: 0 auto; padding: 0 20px; width: 100%; }

.chat {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 76px);
}

.thread { flex: 1; padding: 28px 0 12px; }

.welcome { padding: 26px 0 8px; }

.welcome h1 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.35;
}

.welcome p {
  margin: 0 0 22px;
  color: var(--ink-soft);
  max-width: 62ch;
}

.suggestions { display: flex; flex-wrap: wrap; gap: 9px; }

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 15px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.chip:hover { border-color: var(--pa-red); color: var(--accent-text); background: var(--tint); }

/* ---------- messages ---------- */

.msg { margin-bottom: 26px; animation: rise .22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg.user { display: flex; justify-content: flex-end; }

.msg.user .bubble {
  background: var(--pa-red);
  color: #fff;
  padding: 11px 17px;
  border-radius: 18px 18px 4px 18px;
  max-width: 78%;
  font-size: 15.5px;
}

.msg.bot .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 18px 18px 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.answer { white-space: pre-wrap; font-size: 16px; line-height: 1.75; }

/* Inline [1] markers the model writes are made tappable. */
.cite {
  display: inline-block;
  min-width: 19px;
  height: 19px;
  line-height: 19px;
  text-align: center;
  background: var(--tint);
  color: var(--accent-text);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
  margin: 0 1px;
  cursor: pointer;
  vertical-align: 1px;
}

.cite:hover { background: var(--pa-red); color: #fff; }

.ungrounded {
  border-inline-start: 3px solid var(--pa-red);
  background: var(--tint);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  color: var(--ink-soft);
}

.answer-foot {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- source cards ---------- */

.sources { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 16px; }

.sources-head {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.card {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  margin-bottom: 9px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  text-align: start;
  width: 100%;
  font: inherit;
  color: inherit;
}

.card:hover {
  border-color: var(--pa-red);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.card-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--tint);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.card-head {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16.5px;
  line-height: 1.45;
  margin: 1px 0 5px;
  color: var(--ink);
}

.card-meta {
  font-size: 12.5px;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.card-meta .sep { color: var(--line); }

.card-section { color: var(--accent-text); font-weight: 600; }

.card-snip {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- composer ---------- */

.composer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--ground) 22%);
  padding: 14px 0 16px;
}

.composer-row { display: flex; gap: 10px; }

.composer input {
  flex: 1;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 15.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.composer input::placeholder { color: var(--ink-faint); }

.composer input:focus {
  border-color: var(--pa-red);
  box-shadow: 0 0 0 3px rgba(238, 64, 35, .18);
}

.composer button[type="submit"] {
  width: 46px;
  height: 46px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: var(--pa-red);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s;
}

.composer button[type="submit"]:hover:not(:disabled) { background: var(--pa-red-bright); }
.composer button[type="submit"]:disabled { background: var(--line); color: var(--ink-faint); cursor: default; }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px 0;
  min-height: 20px;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.provider { display: inline-flex; align-items: center; gap: 7px; }

.provider-label { letter-spacing: .3px; }

.provider select {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  outline: none;
}

.provider select:focus { border-color: var(--pa-red); }

.provider-model {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- thinking indicator ---------- */

.thinking { display: flex; align-items: center; gap: 11px; padding: 4px 2px; }

.thinking-dots { display: flex; gap: 5px; }

.thinking-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pa-red);
  opacity: .35;
  animation: pulse 1.3s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .18s; }
.thinking-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes pulse { 0%,100% { opacity:.28; transform:scale(.85);} 50% { opacity:1; transform:scale(1);} }

.thinking-label {
  font-size: 14.5px;
  color: var(--ink-faint);
  transition: opacity .18s ease;
}

.thinking-label.swap { opacity: 0; }

/* ---------- login ---------- */

.login {
  position: fixed;
  inset: 0;
  background: var(--ground);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  border-top: 3px solid var(--pa-red);
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.login-logo { height: 36px; width: auto; margin: 0 auto 6px; }

.login-card h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.login-card p { margin: 0 0 12px; font-size: 14px; color: var(--ink-faint); }

.login-card input {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ground);
  font: inherit;
  color: var(--ink);
  text-align: center;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-card input:focus {
  border-color: var(--pa-red);
  box-shadow: 0 0 0 3px rgba(238, 64, 35, .18);
}

.login-card button {
  margin-top: 6px;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  background: var(--pa-red);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.login-card button:hover { background: var(--pa-red-bright); }

.login-error { font-size: 13px; color: var(--accent-text); padding-top: 4px; }

.login-card.shake { animation: shake .4s; }

@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* ---------- reading panel ---------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 30;
  animation: fade .2s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.reader {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(680px, 100vw);
  background: var(--surface);
  z-index: 31;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border-inline-start: 1px solid var(--line);
  animation: slide .26s cubic-bezier(.16,.8,.3,1);
}

@keyframes slide { from { transform: translateX(100%); } to { transform: none; } }

.reader-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  flex: none;
}

.reader-bar-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.reader-open {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-text);
  text-decoration: none;
  white-space: nowrap;
}

.reader-open:hover { text-decoration: underline; }

.reader-body { overflow-y: auto; padding: 26px 30px 60px; }

.reader-kicker {
  color: var(--accent-text);
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 7px;
}

.reader-body h2 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 12px;
}

.reader-meta {
  font-size: 13px;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
}

.reader-byline { color: var(--ink-soft); font-weight: 600; }

.reader-text p {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
  margin: 0 0 18px;
  color: var(--prose);
}

.reader-figure { margin: 0 0 20px; }
/* Scanned newsprint carries a paper-white ground; at night it reads as a
   glare, so it is toned down until the theme itself is light. */
.reader-figure img {
  width: 100%;
  border-radius: 8px;
  display: block;
  filter: brightness(.92);
}
:root[data-theme="light"] .reader-figure img { filter: none; }
.reader-figure figcaption {
  font-size: 12.5px;
  color: var(--ink-faint);
  padding-top: 7px;
}

.reader-note {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-faint);
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: none;
  }

  .app.sidebar-open .sidebar { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.4); }

  .menu-btn.menu-btn { display: grid; }
}

@media (max-width: 640px) {
  .logo { height: 26px; }
  .brand-divider, .brand-sub { display: none; }
  .welcome h1 { font-size: 22px; }
  .reader-body { padding: 20px 18px 48px; }
  .reader-body h2 { font-size: 22px; }
  .provider-model { display: none; }
}
