:root {
  --bg: #1A1512;
  --surface: #241D18;
  --border: #3A2E26;
  --text: #EDE4DC;
  --muted: #A08D7D;
  --accent: #C4633A;
  --accent-dim: #8A4428;
  --display: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--body); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { color: var(--accent); font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.login-page { display: grid; place-items: center; overflow: auto; }
.login-page::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 49.8%, color-mix(in srgb, var(--border) 65%, transparent) 50%, transparent 50.2%); opacity: .7; }
.login-wrap { position: relative; width: min(1040px, calc(100% - 48px)); min-height: 620px; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(48px, 8vw, 112px); }
.login-intro h1, .error-page h1 { margin: 22px 0 24px; font-family: var(--display); font-size: clamp(3.2rem, 7vw, 6.7rem); font-weight: 400; line-height: .88; letter-spacing: -.055em; }
.login-intro p { max-width: 390px; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.login-card { padding: clamp(28px, 5vw, 52px); background: var(--surface); border: 1px solid var(--border); }
.field + .field { margin-top: 24px; }
.field label { display: block; margin-bottom: 9px; color: var(--muted); font-size: .72rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.field input { width: 100%; padding: 14px 0; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.field input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.field input:focus { outline: 0; border-color: var(--accent); }
.primary { width: 100%; margin-top: 34px; padding: 14px 18px; display: flex; justify-content: space-between; border: 0; background: var(--accent); color: var(--text); cursor: pointer; font-weight: 700; }
.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.form-error, .aviso { color: #E9A183; }
.form-error { margin: 20px 0 -14px; font-size: .85rem; }
.login-note { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: .7rem; }

.shell { height: 100vh; display: grid; grid-template-columns: 56px 260px minmax(0, 1fr); overflow: hidden; }
body.panel-fechado .shell { grid-template-columns: 56px minmax(0, 1fr); }
body.panel-fechado .panel { display: none; }
.rail { z-index: 2; display: flex; flex-direction: column; align-items: center; background: #15110F; border-right: 1px solid var(--border); }
.brand-mark { width: 56px; height: 58px; display: grid; place-items: center; border-bottom: 1px solid var(--border); font-family: var(--display); font-size: 1.1rem; letter-spacing: -.08em; }
.brand-mark span { color: var(--accent); }
.rail-item, .rail-foot button { width: 56px; height: 56px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; opacity: .58; position: relative; }
.rail-item svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linejoin: round; }
.rail-item.active { color: var(--accent); opacity: 1; }
.rail-item.active::before { content: ""; position: absolute; left: 0; width: 2px; height: 22px; background: var(--accent); }
.rail-item:hover:not(:disabled), .rail-foot button:hover { opacity: 1; background: var(--surface); }
.rail-item:disabled { cursor: not-allowed; opacity: .25; }
.rail-foot { margin-top: auto; margin-bottom: 6px; }
.avatar { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--accent-dim); border-radius: 50%; color: var(--accent); font-size: .72rem; font-weight: 700; }

.panel { min-width: 0; background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.panel-head { height: 112px; padding: 24px 18px 18px 22px; display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); }
.panel-head h1 { margin: 5px 0 0; font-family: var(--display); font-size: 1.45rem; font-weight: 400; }
.novo { width: 34px; height: 34px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 1.25rem; }
.novo:hover { border-color: var(--accent); color: var(--text); }
.convs { height: calc(100vh - 112px); margin: 0; padding: 10px; list-style: none; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.convs li { border-bottom: 1px solid color-mix(in srgb, var(--border) 68%, transparent); }
.convs a { display: block; padding: 14px 12px; text-decoration: none; }
.convs a span { display: block; overflow: hidden; color: var(--muted); font-size: .83rem; white-space: nowrap; text-overflow: ellipsis; }
.convs a small { display: block; margin-top: 7px; color: color-mix(in srgb, var(--muted) 64%, transparent); font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; }
.convs li:hover a span, .convs li.sel a span { color: var(--text); }
.convs li.sel { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.convs li.sel a { box-shadow: inset 2px 0 var(--accent); }

.content { min-width: 0; position: relative; display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; background: var(--bg); }
.content::before { content: ""; position: absolute; inset: 58px 0 0; pointer-events: none; opacity: .15; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 65%); }
.content-head { z-index: 1; display: flex; align-items: center; gap: 8px; padding: 0 clamp(22px, 5vw, 72px); border-bottom: 1px solid var(--border); color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.content-head small { margin-left: auto; color: color-mix(in srgb, var(--muted) 55%, transparent); font-size: .62rem; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msgs { z-index: 1; width: min(820px, 100%); margin: 0 auto; padding: clamp(36px, 6vh, 72px) clamp(22px, 5vw, 64px) 42px; overflow-y: auto; scroll-behavior: smooth; }
.empty-state { min-height: 65%; display: flex; flex-direction: column; justify-content: center; }
.empty-index { color: var(--accent); font-size: .68rem; letter-spacing: .16em; }
.empty-state h2 { margin: 18px 0; font-family: var(--display); font-size: clamp(2.8rem, 6vw, 5.6rem); font-weight: 400; line-height: .9; letter-spacing: -.05em; }
.empty-state p { max-width: 480px; color: var(--muted); line-height: 1.7; }
.msg { margin-bottom: 38px; animation: msg-in .34s cubic-bezier(.22,1,.36,1) both; }
.msg header { margin-bottom: 10px; color: var(--accent); font-size: .67rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.msg.user { max-width: 76%; margin-left: auto; padding-left: 28px; border-left: 1px solid var(--accent-dim); }
.msg.user header { color: var(--muted); }
.corpo { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--display); font-size: clamp(1.05rem, 1.5vw, 1.25rem); line-height: 1.62; }
.msg.user .corpo { font-family: var(--body); font-size: .93rem; color: var(--muted); }
.fontes { margin-top: 20px; padding-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--border); }
.fontes > span { flex-basis: 100%; color: var(--muted); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; }
.fontes a { padding: 5px 8px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: .68rem; }
.fontes a:hover { border-color: var(--accent-dim); color: var(--text); }
.aviso { font-size: .75rem; }

.composer { z-index: 2; width: min(740px, calc(100% - 44px)); margin: 0 auto clamp(18px, 4vh, 38px); position: relative; display: grid; grid-template-columns: 1fr 48px; align-items: center; background: var(--surface); border: 1px solid var(--border); }
.composer:focus-within { border-color: var(--accent-dim); }
.composer input { min-width: 0; padding: 19px 18px; border: 0; outline: 0; background: transparent; color: var(--text); }
.composer input::placeholder { color: var(--muted); }
.composer button { width: 36px; height: 36px; border: 0; background: var(--accent); cursor: pointer; font-size: 1.1rem; }
.composer button:disabled { opacity: .45; cursor: wait; }
.composer small { position: absolute; right: 0; bottom: -20px; color: color-mix(in srgb, var(--muted) 50%, transparent); font-size: .6rem; }

.error-page { display: grid; place-items: center; }
.error-page main { width: min(720px, calc(100% - 48px)); }
.error-page h1 { font-size: clamp(3rem, 8vw, 6rem); }
.error-page p { color: var(--muted); }
.link-button { width: fit-content; margin-top: 28px; text-decoration: none; }

@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
@media (max-width: 760px) {
  .login-page::before { display: none; }
  .login-wrap { min-height: auto; grid-template-columns: 1fr; gap: 36px; padding: 48px 0; }
  .login-intro h1 { font-size: clamp(3.1rem, 15vw, 5rem); }
  .shell, body.panel-fechado .shell { grid-template-columns: 50px minmax(0, 1fr); }
  .rail, .brand-mark, .rail-item, .rail-foot button { width: 50px; }
  .panel { position: fixed; z-index: 4; left: 50px; top: 0; bottom: 0; width: min(280px, calc(100vw - 50px)); box-shadow: 16px 0 40px rgba(10,7,5,.35); }
  body.panel-fechado .panel { display: none; }
  .content { grid-column: 2; }
  .content-head { padding: 0 18px; }
  .msgs { padding-inline: 20px; }
  .msg.user { max-width: 90%; }
}
