/* Supreme Energy AI Assistant - brand colours from supreme-energy.com:
   blue #0072CF, red #D3222A, slate #111827. Light + dark themes. */
:root {
  --blue: #0072cf; --blue-d: #005aa6; --blue-l: #e8f2fc; --red: #d3222a; --link: #0072cf;
  --ink: #111827; --ink2: #374151; --mute: #6b7280; --line: #e5e7eb;
  --bg: #ffffff; --card: #ffffff; --soft: #f3f4f6; --field: #ffffff; --qbg: #f1f4f8; --code: #f3f4f6;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 24px rgb(0 0 0 / .08);
  color-scheme: light;
  font-family: "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
}
[data-theme="dark"] {
  --blue: #1f86e0; --blue-d: #3b9cf0; --blue-l: #13263a; --link: #5aaef5;
  --ink: #e6e9ee; --ink2: #c4cad3; --mute: #8b95a3; --line: #27303b;
  --bg: #0f1419; --card: #161c23; --soft: #1b222b; --field: #161c23; --qbg: #1d2733; --code: #1f2731;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 28px rgb(0 0 0 / .45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--ink); background: var(--bg); }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.brandbar { height: 3px; background: linear-gradient(90deg, var(--blue) 0 62%, var(--red) 62% 100%); }
[data-theme="dark"] .login-card img, [data-theme="dark"] .topin .logo { filter: brightness(1.3) saturate(1.1); }

.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--mute); }
.iconbtn:hover, .iconbtn.on { background: var(--soft); color: var(--ink); }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

/* ---------- login ---------- */
.login { min-height: 100%; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(1200px 600px at 110% 120%, rgb(211 34 42 / .55), transparent 60%),
              linear-gradient(150deg, #004f93 0%, #0072cf 55%, #2b8ae0 100%);
}
[data-theme="dark"] .login-hero { background: radial-gradient(1200px 600px at 110% 120%, rgb(211 34 42 / .35), transparent 60%), linear-gradient(150deg, #06213d 0%, #0a4a86 60%, #0f5da3 100%); }
.login-hero::after {
  content: ""; position: absolute; right: -90px; bottom: -70px; width: 460px; height: 460px; opacity: .10;
  background: url(logo-small.png) center/contain no-repeat; filter: brightness(0) invert(1);
}
.hero-tag { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.login-hero h1 { font-size: 44px; line-height: 1.1; margin: 18px 0 0; font-weight: 700; }
.login-side { position: relative; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--card); }
.login-side .theme-btn { position: absolute; top: 14px; right: 14px; }
.login-card { width: 100%; max-width: 400px; }
.login-card img { height: 44px; display: block; margin-bottom: 40px; }
.login-card h2 { font-size: 26px; margin: 0 0 24px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 0 0 6px; }
.field { margin-bottom: 18px; }
.input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); outline: none; transition: border .15s, box-shadow .15s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(0 114 207 / .18); }
.input::-ms-reveal { display: none; }
.pw { position: relative; }
.pw .input { padding-right: 48px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--mute); display: grid; place-items: center; }
.eye:hover { color: var(--blue); }
.eye .off { display: none; } .eye.shown .on { display: none; } .eye.shown .off { display: block; color: var(--blue); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin: 4px 0 12px; }
.madeby { font-size: 12.5px; color: var(--mute); margin-top: 18px; }
.hint a, .madeby a { color: var(--link); font-weight: 600; text-decoration: none; }
.hint a:hover, .madeby a:hover { text-decoration: underline; }

/* ---------- chat (clean) ---------- */
.app { height: 100%; height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
header.top { background: var(--bg); border-bottom: 1px solid var(--line); }
.topin { display: flex; align-items: center; gap: 4px; padding: 8px 16px; max-width: 1100px; margin: 0 auto; }
.topin .logo { height: 28px; }
.hwrap { position: relative; }
.hpanel { position: absolute; right: 0; top: 46px; z-index: 40; width: min(340px, calc(100vw - 24px)); max-height: min(65vh, 520px); display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.hhead { padding: 12px 16px 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.hlist { overflow-y: auto; padding: 0 6px 6px; }
.hitem { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.hitem:hover { background: var(--soft); }
.hitem .ht { display: block; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hitem .hd { display: block; font-size: 12px; color: var(--mute); margin-top: 2px; }
.hnone { padding: 10px 12px 14px; color: var(--mute); font-size: 14px; }

main.chat { display: grid; grid-template-rows: 1fr auto; min-height: 0; }
.scroll { overflow-y: auto; padding: 24px 0 8px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 20px; }
.empty { display: grid; place-items: center; min-height: 50vh; }
.empty img { width: 64px; opacity: .12; }
[data-theme="dark"] .empty img { opacity: .2; }

.msg { display: flex; margin: 0 0 22px; scroll-margin-top: 16px; }
.msg.q { justify-content: flex-end; }
.bubble { min-width: 0; line-height: 1.65; font-size: 15px; border-radius: 12px; }
.msg.q .bubble { background: var(--qbg); padding: 10px 16px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; max-width: 78%; }
.msg.a .bubble { flex: 1; }
.msg.e .bubble { color: var(--red); }
.msg.flash .bubble { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--blue); } 100% { box-shadow: 0 0 0 3px transparent; } }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
.bubble h2, .bubble h3, .bubble h4, .bubble h5 { margin: 16px 0 8px; font-size: 16px; }
.bubble ul, .bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.bubble code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 13.5px; }
.bubble pre { background: #0b1220; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.bubble pre code { background: none; padding: 0; color: inherit; }
.bubble table { border-collapse: collapse; margin: 8px 0 12px; font-size: 13.5px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--soft); }
.meta { font-size: 12px; color: var(--mute); margin-top: 6px; }
.file { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); text-decoration: none; color: var(--ink); font-size: 14px; }
.file:hover { border-color: var(--blue); }
.file small { color: var(--mute); }
.file .ic { width: 28px; height: 28px; border-radius: 6px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.bubble > a > img { max-width: 100%; border-radius: 8px; display: block; margin-top: 8px; }
.working { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 14px; }
.dots span { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--blue); animation: b 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; background: #4f9be0; } .dots span:nth-child(3) { animation-delay: .3s; background: var(--red); }
@keyframes b { 0%, 80%, 100% { transform: scale(.5); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.steps { font-size: 12.5px; color: var(--mute); margin-top: 6px; font-family: ui-monospace, Consolas, monospace; }

.composer { padding: 8px 0 14px; background: var(--bg); }
.box { background: var(--field); border: 1px solid var(--line); border-radius: 18px; padding: 10px 10px 8px 16px; transition: border .15s, box-shadow .15s; }
.box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(0 114 207 / .14); }
.box textarea { width: 100%; border: 0; outline: none; resize: none; min-height: 26px; max-height: 200px; line-height: 1.5; font-size: 15px; background: transparent; padding: 4px 0; }
.box .row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.send { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--blue); color: #fff; cursor: pointer; display: grid; place-items: center; }
.send:hover { background: var(--blue-d); } .send:disabled { opacity: .45; cursor: default; }
.send.stop { background: var(--red); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips:not(:empty) { margin-bottom: 6px; }
.chip { font-size: 12.5px; background: var(--blue-l); color: var(--link); border-radius: 999px; padding: 4px 10px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0; }
.hint { font-size: 12px; color: var(--mute); text-align: center; margin-top: 8px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-hero { padding: 22px 22px 20px; }
  .login-hero::after { width: 200px; height: 200px; right: -50px; bottom: -60px; }
  .login-hero h1 { font-size: 26px; margin-top: 8px; }
  .hero-tag { font-size: 11px; }
  .login-side { align-items: flex-start; padding: 28px 22px calc(24px + env(safe-area-inset-bottom)); }
  .login-card img { height: 36px; margin-bottom: 22px; }
  .login-card h2 { font-size: 22px; margin-bottom: 18px; }
  .input, .box textarea { font-size: 16px; }          /* stops iOS zooming into fields */
  .btn-block { padding: 14px 18px; }

  .topin { padding: 6px 8px 6px 12px; }
  .hpanel { position: fixed; left: 10px; right: 10px; top: 56px; width: auto; max-height: 70vh; }
  .topin .logo { height: 24px; }
  .scroll { padding: 14px 0 6px; }
  .wrap { padding: 0 12px; }
  .msg { margin-bottom: 18px; }
  .msg.q .bubble { max-width: 88%; }
  .composer { padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); }
  .box { padding: 8px 8px 6px 12px; border-radius: 16px; }
  .hint { font-size: 11px; margin-top: 6px; }
}
