/* Asistent: a calm ChatGPT-like workspace. Dark sidebar, white thread, one electric-blue accent for the things that
   need Samuel (send, approve). Built mobile-first: on the phone the sidebar slides in over the thread. */
:root {
  --bg: #ffffff; --soft: #f4f5f7; --line: #e6e8ec; --ink: #0f1115; --ink-2: #5b616e; --ink-3: #8a909c;
  --side: #0b0c0e; --side-2: #17191d; --side-ink: #e9eaee; --side-ink-2: #9aa0ab;
  --accent: #2f6bff; --accent-ink: #fff; --ok: #12a150; --warn: #c27b00; --bad: #d23c2f;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "Geist Mono", ui-monospace, Consolas, monospace;
  --r: 16px; --side-w: 280px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: inherit; }
.iconbtn:hover { background: rgba(127, 127, 127, .12); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100dvh; }
/* sidebar */
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 12px 10px; padding-top: max(12px, env(safe-area-inset-top)); min-height: 0; }
.side__top { display: flex; gap: 6px; }
.newchat { flex: 1; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid #2a2d33; background: var(--side-2); color: var(--side-ink); cursor: pointer; font-weight: 550; }
.newchat:hover { border-color: #3a3e46; }
.side__close { display: none; color: var(--side-ink-2); }
.side__nav { margin: 12px 0 6px; display: grid; gap: 2px; }
.navitem { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--side-ink); text-decoration: none; cursor: pointer; text-align: left; font-size: .94rem; }
.navitem:hover, .navitem.is-on { background: var(--side-2); }
.navitem svg { width: 18px; height: 18px; color: var(--side-ink-2); }
.badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff; font: 600 .76rem/22px var(--sans); text-align: center; }
.side__list { flex: 1; overflow-y: auto; margin: 6px -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: #2a2d33 transparent; }
.grp { margin: 14px 12px 6px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--side-ink-2); }
.conv { position: relative; display: flex; align-items: center; width: 100%; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--side-ink); cursor: pointer; text-align: left; font-size: .92rem; }
.conv span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv:hover, .conv.is-on { background: var(--side-2); }
.conv__del { opacity: 0; width: 28px; height: 28px; border-radius: 8px; color: var(--side-ink-2); }
.conv:hover .conv__del, .conv.is-on .conv__del { opacity: 1; }
.side__foot { border-top: 1px solid #1f2227; padding-top: 8px; display: grid; gap: 2px; padding-bottom: env(safe-area-inset-bottom); }
.scrim { display: none; }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.top { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 10px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid transparent; }
.top__title { flex: 1; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menubtn { display: none; }
.thread { flex: 1; overflow-y: auto; padding: 8px 16px 24px; scroll-behavior: smooth; }
.msgs { max-width: 780px; margin: 0 auto; display: grid; gap: 22px; }
.empty { max-width: 780px; margin: 12vh auto 0; text-align: center; }
.empty__h { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 650; letter-spacing: -.02em; margin: 18px 0 24px; }
.orb { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #9bb8ff, var(--accent) 45%, #0b1d66 100%); box-shadow: 0 10px 40px -8px rgba(47, 107, 255, .6); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 14px 50px -6px rgba(47, 107, 255, .75); } }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip { text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; color: var(--ink-2); font-size: .93rem; transition: border-color .2s, background .2s; }
.chip:hover { border-color: #c9cdd5; background: var(--soft); color: var(--ink); }

.msg { display: flex; gap: 12px; }
.msg--user { justify-content: flex-end; }
.msg--user .bubble { background: var(--soft); border-radius: 20px 20px 6px 20px; padding: 10px 16px; max-width: 82%; white-space: pre-wrap; }
.msg--assistant .bubble { max-width: 100%; min-width: 0; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #9bb8ff, var(--accent) 45%, #0b1d66 100%); margin-top: 2px; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; } .md ul, .md ol { margin: 0 0 12px; padding-left: 22px; } .md li { margin: 3px 0; }
.md h1, .md h2, .md h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.md code { font: .88em var(--mono); background: var(--soft); padding: 2px 5px; border-radius: 5px; }
.md pre { background: #0f1115; color: #e9eaee; padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; color: inherit; }
.md a { color: var(--accent); }
.md table { border-collapse: collapse; margin: 0 0 12px; font-size: .92rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.thumbs img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: .9rem; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.cursor::after { content: "▍"; color: var(--accent); animation: pulse .9s infinite; }

/* action cards */
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: #fff; box-shadow: 0 1px 2px rgba(15, 17, 21, .04); margin-top: 10px; }
.card__head { display: flex; align-items: center; gap: 10px; }
.card__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #eef3ff; color: var(--accent); }
.card__title { flex: 1; font-weight: 600; font-size: .95rem; }
.pill { font-size: .76rem; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.pill--pending { background: #fff4dc; color: var(--warn); } .pill--done { background: #e6f6ec; color: var(--ok); } .pill--failed, .pill--rejected { background: #fdeceb; color: var(--bad); }
.pill--waiting, .pill--queued, .pill--running { background: #eef3ff; color: var(--accent); }
.card__edit { width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; min-height: 120px; line-height: 1.55; background: var(--soft); }
.card__edit:focus { outline: none; border-color: var(--accent); background: #fff; }
.card__meta { margin-top: 8px; color: var(--ink-2); font-size: .88rem; white-space: pre-wrap; }
.card__img { margin-top: 10px; max-width: 220px; border-radius: 12px; }
.card__btns { display: flex; gap: 8px; margin-top: 12px; }
.btn { height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 550; }
.btn--go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--go:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: progress; }
.card__result { margin-top: 10px; font-size: .9rem; color: var(--ink-2); }

/* composer */
.composer { padding: 8px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer__box { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 26px; background: #fff; box-shadow: 0 6px 24px -12px rgba(15, 17, 21, .25); }
.composer__box:focus-within { border-color: #c9cdd5; }
.composer textarea { flex: 1; min-height: 40px; max-height: 40vh; border: 0; outline: 0; resize: none; padding: 9px 6px; background: transparent; line-height: 1.45; }
.attach, .mic { color: var(--ink-2); flex: none; }
.mic.is-rec { color: #fff; background: var(--bad); animation: pulse 1.2s infinite; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send:disabled { background: #d5d8de; cursor: default; }
.composer__note { max-width: 780px; margin: 6px auto 0; text-align: center; font-size: .74rem; color: var(--ink-3); }
.files { max-width: 780px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.files:empty { display: none; }
.fileprev { position: relative; }
.fileprev img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; display: block; }
.fileprev button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 13px; line-height: 22px; cursor: pointer; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30; transform: translateX(-102%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  .app.is-side .side { transform: none; }
  .app.is-side .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .side__close, .menubtn { display: grid; }
  .chips { grid-template-columns: 1fr; }
  .empty { margin-top: 6vh; }
  .composer__note { display: none; }
}

/* login */
body.login { display: grid; place-items: center; background: var(--side); color: var(--side-ink); overflow: auto; min-height: 100dvh; }
.loginbox { width: min(360px, 90vw); text-align: center; display: grid; gap: 12px; }
.loginbox h1 { margin: 14px 0 0; font-size: 1.6rem; letter-spacing: -.02em; }
.loginbox p { margin: 0 0 10px; color: var(--side-ink-2); }
.loginbox input { height: 48px; border-radius: 14px; border: 1px solid #2a2d33; background: var(--side-2); color: var(--side-ink); padding: 0 16px; }
.loginbox button { height: 48px; border-radius: 14px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.loginerr { color: #ff8a80 !important; }
.md blockquote { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--soft); border-radius: 0 10px 10px 0; }
