/* ============================================================
   OSR AI — web app
   Same design tokens as odishaservicerules.in so the two feel
   like one product.
   ============================================================ */
:root{
  --navy:#1E2A4A; --navy-2:#121B33; --navy-3:#0E1730;
  --indigo:#4F46E5; --indigo-soft:#EEF0FF;
  --gold:#F5B82E; --gold-dark:#B8860B;
  --bg:#EDF1F9; --surface:#FFFFFF;
  --ink:#1A1D29; --grey:#6B7280; --line:#E3E8F2;
  --green:#1E9E6A; --red:#E24B4A;
  --radius:16px; --shadow:0 10px 28px rgba(30,42,74,.10);
  --topbar:60px; --composer:96px;
}
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%;overflow-x:clip}
body{
  font-family:'Inter',system-ui,sans-serif;color:var(--ink);
  background:var(--bg);line-height:1.6;font-size:16px;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3{font-family:'Poppins',sans-serif;line-height:1.25}
button,textarea,input{font-family:inherit}
.hidden{display:none !important}
:focus-visible{outline:3px solid var(--indigo);outline-offset:2px;border-radius:8px}

.brand{display:flex;align-items:center;gap:10px;text-decoration:none}
.logo-mark{width:38px;height:38px;border-radius:11px;background:var(--navy);
  color:var(--gold);display:grid;place-items:center;font-family:'Poppins';
  font-weight:800;font-size:13px;border:2px solid var(--gold);flex:none}
.logo-name{font-family:'Poppins';font-weight:700;color:var(--navy);font-size:16px;white-space:nowrap}
.logo-name .ai{background:var(--gold);color:var(--navy);border-radius:6px;
  padding:1px 6px;margin-left:5px;font-size:12px}
.brand.sm .logo-mark{width:32px;height:32px;font-size:11px}
.brand.sm .logo-name{font-size:14px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;
  font-weight:600;border-radius:12px;padding:13px 20px;font-size:15px;border:0;
  cursor:pointer;text-decoration:none;white-space:nowrap;width:100%}
.btn-gold{background:var(--gold);color:var(--navy)}
.btn-ghost{background:transparent;color:var(--grey);border:1px solid var(--line);margin-top:10px}

/* ---------------- sign-in ---------------- */
.auth{min-height:100dvh;display:grid;place-items:center;padding:24px;
  background:radial-gradient(900px 500px at 70% -10%,rgba(79,70,229,.30),transparent 60%),
             linear-gradient(160deg,var(--navy),var(--navy-2))}
.auth-card{background:var(--surface);border-radius:22px;padding:36px 30px 28px;
  max-width:420px;width:100%;box-shadow:0 24px 60px rgba(0,0,0,.34);text-align:center}
.auth-card .brand{justify-content:center;margin-bottom:22px}
.auth-card h1{font-size:24px;color:var(--navy);margin-bottom:10px}
.auth-sub{color:var(--grey);font-size:14.5px;margin-bottom:26px}
.gbtn{display:flex;align-items:center;justify-content:center;gap:11px;width:100%;
  background:#fff;border:1px solid #DADCE0;border-radius:12px;padding:14px;
  font-size:15px;font-weight:600;color:#3C4043;cursor:pointer;transition:box-shadow .15s}
.gbtn:hover{box-shadow:0 2px 8px rgba(0,0,0,.14)}
.gbtn:disabled{opacity:.6;cursor:default}
.auth-note{font-size:13.5px;margin-top:14px;min-height:20px;color:var(--red)}
.auth-legal{font-size:11.5px;color:#9AA4B8;margin-top:20px;line-height:1.55}
.auth-legal a{color:var(--indigo)}

/* ---------------- app shell ---------------- */
.app{display:flex;flex-direction:column;height:100dvh}
.topbar{height:var(--topbar);flex:none;display:flex;align-items:center;
  justify-content:space-between;gap:12px;padding:0 14px;background:rgba(255,255,255,.95);
  backdrop-filter:blur(10px);border-bottom:1px solid var(--line);
  padding-top:env(safe-area-inset-top)}
.top-right{display:flex;align-items:center;gap:10px}
.coins{display:inline-flex;align-items:center;gap:7px;background:#FFF7E4;
  border:1px solid rgba(245,184,46,.5);border-radius:999px;padding:6px 13px;
  font-weight:700;font-size:14px;color:var(--gold-dark)}
.coins .dot{width:9px;height:9px;border-radius:50%;background:var(--gold)}
.icon-btn{width:40px;height:40px;border:1px solid var(--line);background:#fff;
  border-radius:11px;cursor:pointer;display:flex;flex-direction:column;
  justify-content:center;align-items:center;gap:4.5px;flex:none}
.icon-btn span{display:block;width:17px;height:2px;background:var(--navy);border-radius:2px}

/* ---------------- thread ---------------- */
.thread{flex:1;overflow-y:auto;padding:22px 16px 8px;-webkit-overflow-scrolling:touch}
.welcome{max-width:620px;margin:6vh auto 0;text-align:center}
.welcome h2{font-size:23px;color:var(--navy);margin-bottom:10px}
.welcome p{color:var(--grey);font-size:14.5px;margin-bottom:22px}
.chips{display:flex;flex-direction:column;gap:10px;max-width:440px;margin:0 auto}
.chip{background:var(--surface);border:1px solid var(--line);border-radius:13px;
  padding:13px 16px;text-align:left;font-size:14.5px;color:var(--ink);cursor:pointer;
  box-shadow:0 2px 8px rgba(30,42,74,.05);transition:transform .12s,border-color .12s}
.chip:hover{transform:translateY(-1px);border-color:var(--indigo)}

.msgs{max-width:760px;margin:0 auto}
.msg{margin-bottom:20px}
.msg.you{display:flex;justify-content:flex-end}
.msg.you .bubble{background:var(--navy);color:#fff;border-radius:16px 16px 4px 16px;
  padding:13px 17px;max-width:82%;font-size:15px}
.msg.ai .bubble{background:var(--surface);border:1px solid var(--line);
  border-radius:16px 16px 16px 4px;padding:19px 21px;box-shadow:var(--shadow);font-size:15.4px}
.msg.ai .bubble p{margin:0 0 13px}
.msg.ai .bubble p:last-child{margin-bottom:0}
.msg.ai .bubble strong{color:var(--navy)}
.msg.ai .bubble ul,.msg.ai .bubble ol{margin:0 0 13px 20px}
.msg.ai .bubble li{margin-bottom:6px}
.msg.ai .bubble h4{font-family:'Poppins';font-size:15px;color:var(--navy);margin:18px 0 8px}
.msg.ai .bubble em{color:var(--grey)}

.refs{margin-top:15px;padding-top:14px;border-top:1px solid var(--line)}
.refs-t{font-size:11px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;
  color:var(--indigo);margin-bottom:9px}
.ref{display:flex;align-items:center;gap:9px;background:var(--indigo-soft);
  border:1px solid #DDE0FB;border-radius:11px;padding:11px 14px;margin-bottom:8px;
  text-decoration:none;color:var(--navy);font-size:14px;font-weight:600}
.ref:hover{border-color:var(--indigo)}
.ref .ic{flex:none}
.ref .lbl{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.typing{display:flex;gap:5px;padding:6px 2px}
.typing i{width:7px;height:7px;border-radius:50%;background:#C3CADB;
  animation:blink 1.3s infinite}
.typing i:nth-child(2){animation-delay:.18s}
.typing i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,80%,100%{opacity:.35}40%{opacity:1}}
.err{background:#FFF3F3;border:1px solid #F3C9C9;color:#9B2C2C;
  border-radius:13px;padding:14px 17px;font-size:14.5px}

/* ---------------- composer ---------------- */
.dock{flex:none;background:rgba(237,241,249,.96);border-top:1px solid var(--line);
  backdrop-filter:blur(8px)}
.composer{display:flex;align-items:flex-end;gap:10px;padding:12px 16px 6px}
.composer textarea{flex:1;min-width:0;resize:none;border:1px solid var(--line);
  border-radius:15px;padding:14px 16px;font-size:15.5px;background:#fff;
  outline:none;max-height:160px;line-height:1.5;
  box-shadow:0 0 0 2px rgba(245,184,46,.30),0 6px 18px rgba(30,42,74,.09)}
.composer textarea:focus{border-color:var(--gold);
  box-shadow:0 0 0 3px rgba(245,184,46,.45),0 6px 18px rgba(30,42,74,.12)}
.composer button{flex:none;width:50px;height:50px;border-radius:15px;border:0;
  background:var(--indigo);color:#fff;cursor:pointer;display:grid;place-items:center}
.composer button:disabled{background:#B9BDD6;cursor:default}
.composer-note{text-align:center;font-size:11.5px;color:#98A2B8;
  padding:0 16px calc(10px + env(safe-area-inset-bottom))}

/* ---------------- drawer ---------------- */
.menu-overlay{position:fixed;inset:0;background:rgba(14,23,48,.55);
  backdrop-filter:blur(2px);z-index:98;opacity:0;transition:opacity .25s}
.menu-overlay.show{opacity:1}
.menu-overlay[hidden]{display:none !important}
.menu-drawer{position:fixed;top:0;right:0;height:100dvh;width:min(320px,86vw);
  background:var(--surface);z-index:99;box-shadow:-18px 0 46px rgba(14,23,48,.28);
  display:flex;flex-direction:column;transform:translateX(100%);
  transition:transform .28s cubic-bezier(.4,0,.2,1);
  padding:calc(env(safe-area-inset-top) + 16px) 20px calc(env(safe-area-inset-bottom) + 20px)}
.menu-drawer.show{transform:translateX(0)}
.menu-drawer[hidden]{display:none !important}
.menu-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
.menu-title{font-size:13px;color:var(--grey);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.menu-close{width:38px;height:38px;border:1px solid var(--line);background:#fff;
  border-radius:11px;font-size:23px;line-height:1;color:var(--navy);cursor:pointer;
  display:grid;place-items:center;flex:none}
.menu-links{display:flex;flex-direction:column;margin-top:10px;flex:1;overflow-y:auto}
.menu-links a{display:flex;align-items:center;justify-content:space-between;
  padding:15px 4px;color:var(--ink);text-decoration:none;font-size:16px;
  font-weight:600;border-bottom:1px solid var(--line)}
.menu-links a .chev{color:#B6C0D6;font-weight:400}
.menu-foot{padding-top:16px;border-top:1px solid var(--line)}
body.menu-open{overflow:hidden}

/* ---------------- bottom sheet ---------------- */
.sheet-backdrop{position:fixed;inset:0;background:rgba(14,23,48,.55);z-index:100}
.sheet-backdrop[hidden]{display:none !important}
.sheet{position:fixed;left:50%;bottom:0;transform:translateX(-50%);
  width:min(460px,100%);background:var(--surface);z-index:101;
  border-radius:22px 22px 0 0;padding:26px 24px calc(24px + env(safe-area-inset-bottom));
  box-shadow:0 -14px 40px rgba(14,23,48,.28)}
.sheet[hidden]{display:none !important}
.sheet h3{font-size:19px;color:var(--navy);margin-bottom:9px}
.sheet p{font-size:14.5px;color:var(--grey);margin-bottom:18px}

@media (min-width:720px){
  .thread{padding:28px 24px 10px}
  .composer{padding:14px 24px 6px}
}


/* ============================================================
   FIX PACK — desktop "start" layout and download buttons
   ============================================================ */

/* --- The reference row is now a BUTTON, not a link -----------
   The stored pdf_url points at the public storage endpoint, but the
   rulebooks bucket is private, so that URL 404s. We now mint a short-lived
   signed URL on click instead. A <button> is the honest element for that:
   there is no href until the user asks for one. */
button.ref{width:100%;font-family:inherit;cursor:pointer;text-align:left}
button.ref:disabled{opacity:.55;cursor:default}
.ref .sp{width:14px;height:14px;border:2px solid #C3CADB;border-top-color:var(--indigo);
  border-radius:50%;animation:spin .7s linear infinite;flex:none}
@keyframes spin{to{transform:rotate(360deg)}}
.ref-err{font-size:12.5px;color:var(--red);margin-top:4px}

/* --- Wide screens: centre the composer until the first question ----
   On a 1600px monitor a full-width input at the very bottom edge reads as
   a footer, not as the thing you are meant to type into. Google's shape is
   familiar for a reason: centred and narrow to begin with, docked to the
   bottom once a conversation exists. Mobile is unchanged — a phone keyboard
   wants the field at the bottom. */
@media (min-width:900px){
  .composer,.composer-note{max-width:720px;margin-inline:auto}

  /* auto margins on the two flex children centre the pair vertically */
  .app.start .thread{flex:0 0 auto;margin-top:auto;overflow:visible}
  .app.start .dock{margin-bottom:auto;background:transparent;border-top:0}
  .app.start .welcome{margin-top:0}
  .app.start .composer{padding-bottom:4px}

  /* the field is the focal point in start mode, so give it the glow */
  .app.start .composer textarea{
    box-shadow:0 0 0 2px rgba(245,184,46,.45),0 10px 30px rgba(30,42,74,.14)}

  /* chips read better as a row once they sit above a centred field */
  .app.start .chips{flex-direction:row;flex-wrap:wrap;justify-content:center;
    max-width:660px}
  .app.start .chip{flex:0 1 auto;font-size:13.5px;padding:10px 14px}
}
