:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  --bg: #fbfaf8;
  --side: #f0efeb;
  --panel: #fff;
  --ink: #292925;
  --muted: #6b6a62;
  --line: #deddd5;
  --hover: #e7e6df;
  --accent: #365c49;
  --danger: #a7362d;
  color-scheme: light;
  scrollbar-color: #b7b6ae transparent;
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover {
  background: var(--hover);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection {
  background: #ceded3;
}
a {
  color: var(--accent);
  text-underline-offset: 3px;
}
svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 550;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 21px;
  font-weight: 550;
  letter-spacing: -0.02em;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}
.muted,
small {
  color: var(--muted);
}
small {
  font-size: 12px;
}
.primary {
  background: var(--ink);
  color: var(--bg);
}
.primary:hover {
  background: var(--accent);
  color: #fff;
}
.danger {
  color: var(--danger);
}
.icon {
  width: 34px;
  height: 34px;
  padding: 7px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.between {
  justify-content: space-between;
}
.stack {
  display: grid;
  gap: 16px;
}
.loading {
  padding: 40px;
  color: var(--muted);
}
.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}
.sidebar {
  background: var(--side);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.brand {
  padding: 0 10px 22px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.035em;
}
.brand svg {
  width: 25px;
  height: 25px;
}
.new-chat {
  justify-content: flex-start;
  width: 100%;
  margin-bottom: 26px;
}
.nav-label {
  font-size: 12px;
  color: var(--muted);
  padding-left: 10px;
}
.subjects {
  overflow: auto;
  flex: 1;
  padding-top: 8px;
}
.subject-head {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}
.subject-head > button:first-child {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
  font-weight: 550;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation {
  display: flex;
  align-items: center;
  border-radius: 7px;
  margin: 2px 0 2px 20px;
}
.conversation > button:first-child {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
  font-size: 13px;
  text-align: left;
}
.conversation.selected {
  background: var(--hover);
}
.more {
  opacity: 0;
}
.subject-head:hover .more,
.conversation:hover .more,
.more:focus-visible {
  opacity: 1;
}
.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.sidebar-footer button {
  justify-content: flex-start;
  width: 100%;
}
.avatar {
  height: 26px;
  width: 26px;
  display: grid;
  place-items: center;
  background: var(--hover);
  border-radius: 50%;
  font-size: 12px;
}
.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
}
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  min-height: 67px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 550;
}
.topbar small {
  display: block;
  margin-top: 3px;
}
.mobile-menu {
  display: none;
}
.messages {
  flex: 1;
  overflow: auto;
  scroll-behavior: smooth;
  padding: 36px max(28px, calc((100% - 760px) / 2));
  overscroll-behavior: contain;
}
.empty {
  height: 100%;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  max-width: 650px;
  margin: auto;
}
.empty h1 {
  margin-bottom: 14px;
}
.empty p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
  max-width: 470px;
}
.empty .empty-mark {
  color: var(--accent);
  margin-bottom: 28px;
}
.empty-mark svg {
  width: 35px;
  height: 35px;
}
.message {
  margin: 0 0 32px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.message.user {
  background: var(--side);
  border-radius: 14px;
  padding: 14px 18px;
  max-width: 88%;
  width: fit-content;
  margin-left: auto;
  white-space: pre-wrap;
}
.message .speaker {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
}
.message p:last-child {
  margin-bottom: 0;
}
.message pre {
  padding: 16px;
  background: var(--side);
  overflow: auto;
  border-radius: 9px;
  line-height: 1.5;
}
.message code {
  font-family: Consolas, monospace;
  font-size: 13px;
}
.message table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
  max-width: 100%;
}
.message td,
.message th {
  border: 1px solid var(--line);
  padding: 8px 12px;
}
.message img {
  max-width: 100%;
}
.message blockquote {
  margin-left: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}
.composer-wrap {
  padding: 12px max(28px, calc((100% - 760px) / 2)) 18px;
}
.composer {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 12px;
}
.composer textarea {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 180px;
  background: none;
  color: inherit;
  border: 0;
  padding: 4px 4px 8px;
  line-height: 1.6;
  outline: none;
}
.composer textarea:focus-visible {
  outline: none;
}
.composer:focus-within {
  border-color: var(--accent);
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.composer-tools {
  display: flex;
  gap: 3px;
  align-items: center;
}
.send {
  border-radius: 50%;
  width: 34px;
  height: 34px;
  padding: 8px;
}
.hint {
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  padding-top: 10px;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.chip button {
  padding: 0;
  width: 19px;
  height: 19px;
}
.status {
  font-size: 12px;
  color: var(--muted);
  min-height: 22px;
  padding: 0 3px 6px;
}
.voice-live {
  color: var(--accent);
  background: var(--side);
}
.artifact-panel {
  width: 48%;
  min-width: 320px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.artifact-panel .topbar {
  padding: 14px 18px;
}
.artifact-panel iframe {
  border: 0;
  flex: 1;
  width: 100%;
  background: white;
}
.artifact-empty {
  padding: 24px;
}
.artifact-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.artifact-list button {
  justify-content: flex-start;
  border: 1px solid var(--line);
}
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.auth-inner {
  max-width: 380px;
  width: 100%;
}
.auth .brand {
  padding: 0;
  margin-bottom: 64px;
}
.auth p {
  line-height: 1.7;
  color: var(--muted);
}
.auth .primary {
  width: 100%;
  padding: 13px;
}
.auth-footer {
  font-size: 12px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.auth-footer button {
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.admin {
  max-width: 920px;
  margin: 0 auto;
  padding: 44px 32px 70px;
}
.admin-header {
  margin-bottom: 40px;
}
.settings-section {
  border-top: 1px solid var(--line);
  padding: 28px 0;
}
.settings-section h2 {
  margin-bottom: 8px;
}
.settings-section > p {
  color: var(--muted);
  line-height: 1.6;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 20px 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 7px;
  padding: 10px;
  min-width: 0;
}
.wide {
  grid-column: 1/-1;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.check input {
  width: auto;
}
.guest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.guest-row p {
  margin: 0;
  overflow-wrap: anywhere;
}
.badge {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--side);
  border-radius: 5px;
  color: var(--accent);
}
dialog {
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
  max-width: 500px;
  width: calc(100% - 32px);
  max-height: 85dvh;
}
dialog::backdrop {
  background: #15171366;
}
dialog h2 {
  margin-bottom: 12px;
}
dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
dialog p {
  line-height: 1.6;
}
.dialog-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 9px;
  max-width: calc(100% - 32px);
  background: var(--ink);
  color: var(--bg);
  z-index: 100;
  box-shadow: 0 5px 20px #0002;
  font-size: 13px;
}
#toast:empty {
  display: none;
}
.hidden {
  display: none !important;
}
.error-box {
  padding: 12px;
  background: var(--side);
  color: var(--danger);
  line-height: 1.6;
  border-radius: 8px;
  margin: 14px 0;
}
.sidebar-overlay {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #20211f;
    --side: #191a18;
    --panel: #282926;
    --ink: #eeeee8;
    --muted: #aaa99f;
    --line: #3b3d36;
    --hover: #30322c;
    --accent: #accab5;
    --danger: #ffaaa0;
    scrollbar-color: #626458 transparent;
  }
  ::selection {
    background: #4e6757;
  }
  .primary:hover {
    background: #bdd5c4;
    color: #20211f;
  }
}
@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .artifact-panel {
    position: fixed;
    inset: 0 0 0 35%;
    width: auto;
    z-index: 15;
    box-shadow: -12px 0 40px #0002;
  }
  .messages {
    padding: 28px;
  }
  .composer-wrap {
    padding: 12px 24px 18px;
  }
}
@media (max-width: 700px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 275px;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }
  .shell.nav-open .sidebar {
    transform: none;
  }
  .shell.nav-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: #0005;
    z-index: 25;
  }
  .mobile-menu {
    display: inline-flex;
  }
  .topbar {
    padding: 12px 15px;
    min-height: 62px;
  }
  .messages {
    padding: 24px 18px;
  }
  .composer-wrap {
    padding: 10px 12px 13px;
  }
  .empty h1 {
    font-size: 27px;
  }
  .empty {
    min-height: 180px;
  }
  .empty p {
    font-size: 15px;
  }
  .more {
    opacity: 1;
  }
  .artifact-panel {
    inset: 0;
    width: 100%;
    min-width: 0;
  }
  .admin {
    padding: 28px 20px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  .message.user {
    max-width: 94%;
  }
  .hint {
    font-size: 10px;
  }
  .guest-row {
    align-items: flex-start;
  }
  .auth .brand {
    margin-bottom: 45px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
