:root {
  color-scheme: light dark;
  --canvas: light-dark(#f5f3eb, #141819);
  --surface: light-dark(#fffdf8, #1e2223);
  --tint: light-dark(#eeebe0, #292e2d);
  --line: light-dark(#ded9ca, #3d4442);
  --text: light-dark(#202b25, #f1f0e6);
  --muted: light-dark(#586457, #b5bdb3);
  --green: light-dark(#274238, #bedbc9);
  --on-green: light-dark(#fffdf7, #172a21);
  --gold: light-dark(#775413, #eac872);
  --gold-bg: light-dark(#f0e4c5, #3d331e);
  --danger: light-dark(#85352a, #f7aba0);
  --danger-bg: light-dark(#f7e0da, #442823);
  font: 400 16px/1.5 "Avenir Next", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--canvas); }
h1,h2,p { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 3.15rem); line-height: 1.12; letter-spacing: -.045em; font-weight: 690; overflow-wrap:anywhere; }
h2 { font-size: 1.25rem; line-height: 1.25; }
p { overflow-wrap: anywhere; }
a { color: inherit; text-underline-offset: .18em; }
button,input,textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }
input:not([type=checkbox],[type=file],[type=hidden]),textarea { width: 100%; min-width: 0; padding: .58rem .72rem; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: .5rem; }
label { display: grid; gap: .3rem; font-weight: 570; }
.primary,.secondary,.quiet { min-height: 2.6rem; border: 1px solid transparent; border-radius: .55rem; padding: .5rem .86rem; font-weight: 650; line-height: 1.25; }
.primary { color: var(--on-green); background: var(--green); }
.primary:hover:not(:disabled) { filter: brightness(1.12); }
.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.quiet { color: var(--muted); background: transparent; }
.secondary:hover,.quiet:hover { background: var(--tint); }
.wide { width: 100%; }
.muted,small { color: var(--muted); }
.tag { background: var(--gold-bg); color: var(--gold); font-size: .8rem; border-radius: .35rem; padding: .2rem .45rem; width: fit-content; }
.error { color: var(--danger); background: var(--danger-bg); border-radius: .5rem; padding: .55rem .8rem; }
.head { min-height: 4.5rem; padding: .65rem max(1rem, calc((100% - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: .7rem; align-items: center; font-size: 1.2rem; text-decoration: none; line-height: 1.13; }
.brand b { display: block; letter-spacing: -.035em; }
.brand small { font-size: .76rem; }
.mark,.bot-symbol { background: var(--gold-bg); color: var(--gold); border-radius: .55rem; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; line-height: 1; font-size: 1.5rem; flex-shrink: 0; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem 1.05rem; }
.head-actions a { text-decoration: none; font-weight: 600; }
.head-actions a:hover { text-decoration: underline; }
.identity { color: var(--muted); font-size: .9rem; max-width: 24ch; overflow-wrap: anywhere; }
.main { margin: 0 auto; padding: 2.8rem 1rem; max-width: 1152px; }
.catalog { display: grid; gap: 1.4rem; }
.title { display: grid; gap: .5rem; }
.title p { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%,22rem), 1fr)); gap: .85rem; }
.bot-card { background: var(--surface); border: 1px solid var(--line); border-radius: .85rem; display: grid; grid-template-columns: auto minmax(0,1fr); text-decoration: none; gap: .35rem .9rem; padding: 1.1rem; min-height: 8.8rem; align-content: center; align-items: center; }
a.bot-card:hover { border-color: var(--gold); background: color-mix(in srgb,var(--surface) 92%, var(--gold-bg)); }
.bot-card strong,.bot-card small { display: block; overflow-wrap: anywhere; }
.bot-card small { font-size: .92rem; }
.card-action,.bot-card .tag { grid-column: 2; color: var(--gold); font-weight: 650; font-size: .86rem; }
.auth-layout { max-width: 1050px; padding: clamp(1rem,7vw,4rem) 1rem; margin: 0 auto; }
.auth { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); min-height: 28rem; border-radius: 1rem; overflow: hidden; }
.auth-cover { background: var(--green); color: var(--on-green); display: grid; align-content: center; gap: .85rem; padding: clamp(1rem,5vw,3rem); }
.auth-cover h1 { max-width: 15ch; }
.auth-form { background: var(--surface); display: grid; gap: .9rem; align-content: center; justify-items: start; padding: clamp(1rem,4vw,2.55rem); }
.fields { display: grid; justify-items: stretch; gap: .8rem; width: 100%; }
.fields button { justify-self: start; }
.setup-key { display: inline-block; word-break: break-all; }
.qr { background: white; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 1.05rem; border-radius: .75rem; display: grid; gap: .65rem; }
.add-employee { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; }
.employee-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,19rem),1fr)); gap: .85rem; }
.grant-form { display: grid; justify-items: start; gap: .6rem; }
.grant-form fieldset { margin: 0; border: 1px solid var(--line); border-radius: .45rem; padding: .6rem; width: 100%; }
.checkbox { display: flex; align-items: center; gap: .45rem; min-height: 2rem; }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--green); }
.invite-form { align-self: end; }
.invitation button { justify-self: start; }
.chat-layout { display: grid; grid-template-columns: minmax(13rem, 16rem) minmax(0,1fr); max-width: 1152px; margin: 0 auto; min-height: calc(100svh - 4.55rem); border-inline: 1px solid var(--line); }
.chat-side { min-width: 0; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-top { position: sticky; top: 0; background: var(--surface); z-index: 1; padding: .85rem; display: grid; gap: .7rem; border-bottom: 1px solid var(--line); }
.bot-ident { display: flex; gap: .6rem; align-items:center; font-weight: 650; }
.bot-ident .bot-symbol { width: 1.9rem; height: 1.9rem; font-size: 1.1rem; }
.side-tabs,.room-tabs { display: flex; flex-wrap: wrap; gap: .2rem .3rem; align-items: center; }
.side-tabs a,.room-tabs a { text-decoration: none; border-radius: .4rem; color: var(--muted); font-size: .86rem; padding: .32rem .45rem; }
.side-tabs a[aria-current],.room-tabs a[aria-current] { background: var(--gold-bg); color: var(--gold); font-weight: 650; }
.topic-list { padding: .5rem .8rem .85rem; max-height: 63svh; overflow: auto; }
.topic-list > a { display: block; text-decoration: none; border-radius: .4rem; padding: .45rem .4rem; overflow-wrap: anywhere; }
.topic-list small { display: block; font-size: .8rem; }
.topic-list > a[aria-current],.topic-list > a:hover { background: var(--tint); }
.pagination { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; font-size: .83rem; padding: .5rem .2rem; }
.chat-room { display: flex; flex-direction: column; min-width: 0; }
.room-landing { margin: auto; width: min(100% - 2rem, 34rem); display: grid; gap: .85rem; padding: 2rem .5rem; }
.room-landing p { color: var(--muted); }
.room-head { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: .95rem 1.1rem; border-bottom: 1px solid var(--line); }
.room-head h1 { font-size: clamp(1.4rem, 3vw, 2.2rem); margin: .14rem 0; }
.source-link { font-size: .83rem; color: var(--muted); }
.conversation { display: flex; flex: 1; flex-direction: column; align-items: start; gap: .8rem; padding: 1rem 1.1rem; min-height: 12rem; max-height: calc(100svh - 16rem); overflow: auto; }
.message { width: fit-content; min-width: 0; max-width: min(100%,46rem); padding: .65rem .85rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); }
.message.user { margin-left: min(8vw,4rem); align-self: end; background: var(--tint); }
.message header { display: flex; flex-wrap: wrap; gap: .4rem .7rem; margin-bottom: .22rem; font-size: .85rem; }
.message time { color: var(--muted); }
.message p { white-space: pre-wrap; }
.message a { display: inline-block; margin-top: .5rem; font-size: .85rem; color: var(--gold); }
.composer { padding: .85rem 1.1rem; background: var(--surface); border-top: 1px solid var(--line); display: grid; gap: .45rem; }
.composer textarea { resize: vertical; }
.compose-actions { display: flex; align-items: center; gap: .4rem .75rem; flex-wrap: wrap; }
.compose-actions button { margin-left: auto; }
.attachment { display: inline-grid; position: relative; color: var(--gold); padding: .5rem .2rem; cursor: pointer; }
.attachment:focus-within { outline: 3px solid var(--gold); border-radius: .3rem; }
.attachment input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-name { max-width: 38ch; font-size: .85rem; overflow-wrap:anywhere; }
.files { padding: 1rem 2.6rem; }
@media (max-width: 650px) {
  .head { padding: .65rem .85rem; }
  .main { padding-top: 1.5rem; }
  .identity { display: none; }
  .auth,.chat-layout { grid-template-columns: 1fr; }
  .auth-cover h1 { max-width: none; }
  .chat-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-top { position: static; }
  .topic-list { max-height: 9rem; }
  .conversation { max-height: 52svh; padding-inline: .8rem; }
}
