:root {
  color-scheme: light;
  --page: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #eff1f6;
  --surface-hover: #e8ebf2;
  --sidebar: #f7f8fb;
  --border: #e1e4ed;
  --border-strong: #c9cedc;
  --text: #12102b;
  --muted: #4c5470;
  --quiet: #6e7691;
  --accent: #2f5d8c;
  --accent-hover: #264c73;
  --accent-soft: #e3ebf5;
  --focus: #5b8fd0;
  --shadow: 0 18px 48px rgba(30, 31, 45, 0.1);
  --composer-shadow: 0 8px 30px rgba(24, 26, 34, 0.09);
  --scroll-thumb: rgba(24, 26, 34, 0.22);
  --sidebar-width: 278px;
}

:root[data-sidebar="wide"] {
  --sidebar-width: 360px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111111;
  --surface: #1c1c1c;
  --surface-soft: #292929;
  --surface-hover: #343434;
  --sidebar: #181818;
  --border: #303030;
  --border-strong: #454545;
  --text: #f2f2f2;
  --muted: #b6b6b6;
  --quiet: #888888;
  --accent: #2f5d8c;
  --accent-hover: #264c73;
  --accent-soft: #1d2f45;
  --focus: #5b8fd0;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
  --composer-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  --scroll-thumb: rgba(241, 243, 248, 0.26);
}

.powered-by {
  align-items: center;
  color: var(--quiet);
  display: flex;
  font-size: 10px;
  gap: 6px;
  margin: 10px 8px 0;
  justify-content: center;
  text-decoration: none;
}

/* Product name over "powered by", beside the logo. */
.powered-by-text {
  line-height: 1.3;
  text-align: right;
}

.powered-by img { height: 30px; max-width: 145px; width: auto; }
.powered-by-dark { display: none; }
:root[data-theme="dark"] .powered-by-light { display: none; }
:root[data-theme="dark"] .powered-by-dark { display: block; }

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 48%, transparent);
  outline-offset: 2px;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.scroll-area {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.scroll-area:hover,
.scroll-area:focus-within {
  scrollbar-color: var(--scroll-thumb) transparent;
}

.scroll-area::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.scroll-area::-webkit-scrollbar-track,
.scroll-area::-webkit-scrollbar-corner {
  background: transparent;
}

.scroll-area::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 8px;
  background-color: transparent;
  background-clip: content-box;
}

.scroll-area:hover::-webkit-scrollbar-thumb,
.scroll-area:focus-within::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--text);
  color: var(--surface);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
}

/* The preview of a generated file takes a third column next to the chat. */
.app-shell.previewing {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) min(46vw, 46rem);
}

.preview-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.preview-panel[hidden] {
  display: none;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.preview-head h2 {
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.preview-actions > button:not(.icon-button) {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.preview-body {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface-soft);
  align-content: start;
}

.preview-body img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--composer-shadow);
}

.preview-body p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 0;
  min-height: 0;
  /* Menus opened from the footer intentionally extend into the chat area. */
  overflow: visible;
  flex-direction: column;
  padding: 18px 14px 14px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 5px 18px;
}

.sidebar-head .brand {
  margin-right: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #3020b8, #2090f8);
  box-shadow: 0 5px 14px rgba(48, 32, 184, 0.24);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.brand-logo {
  object-fit: contain;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

/* The whole logo in place of the name: as wide as the head allows. */
.brand.logo-only .brand-logo {
  width: auto;
  max-width: 190px;
  height: 48px;
  border-radius: 0;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.icon-button:not(:disabled):hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-button:disabled {
  opacity: 0.42;
}

.icon-button svg,
.icon-button .lucide-icon {
  width: 20px;
  height: 20px;
}

.sidebar-close,
.menu-button {
  display: none;
}

.chat-actions {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(42px, 1fr);
  gap: 8px;
}

.new-chat,
.temporary-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.new-chat {
  min-height: 42px;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 590;
}

.new-chat:hover {
  background: var(--surface-hover);
}

.new-chat:disabled,
.temporary-chat:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.new-chat:disabled:hover,
.temporary-chat:disabled:hover { background: var(--surface-soft); }

.new-chat svg,
.new-chat .lucide-icon,
.temporary-chat svg,
.temporary-chat .lucide-icon {
  width: 20px;
  height: 20px;
}

.new-chat kbd {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.82);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
}

.temporary-chat {
  position: relative;
  min-height: 42px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--muted);
}

.temporary-chat:hover,
.temporary-chat[aria-pressed="true"] {
  background: var(--surface-hover);
  color: var(--text);
}

.temporary-chat::after {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 210px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 560;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.temporary-chat:hover::after,
.temporary-chat:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.temporary-chat[aria-pressed="true"] {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 48%, transparent);
}

.search-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--quiet);
}

.search-field svg,
.search-field .lucide-icon {
  width: 18px;
  height: 18px;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.search-field input::placeholder {
  color: var(--quiet);
}

.sidebar-content {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.nav-section {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 13px 4px;
}

.nav-section.conversations {
  min-height: 0;
  flex: 1;
}

.nav-section.assistants {
  flex: none;
}

.nav-section + .nav-section {
  border-top: 1px solid var(--border);
}

.section-heading {
  display: flex;
  width: 100%;
  flex: none;
  align-items: center;
  margin: 0;
  gap: 6px;
  padding: 0 5px 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.section-search-button {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--quiet);
}

.section-search-button:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--text);
}

.section-search-button .lucide-icon { width: 16px; height: 16px; }

.section-toggle:hover {
  color: var(--text);
}

.section-heading svg,
.section-heading .lucide-icon {
  width: 16px;
  height: 16px;
  transition: transform 140ms ease;
}

.section-toggle[aria-expanded="false"] svg,
.section-toggle[aria-expanded="false"] .lucide-icon {
  transform: rotate(-90deg);
}

.section-body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.section-body[hidden] {
  display: none;
}

/* A closed section takes only its heading, so the open one gets the room. */
.nav-section.conversations:has(.section-toggle[aria-expanded="false"]) {
  flex: none;
}

.empty-list {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  padding: 12px 8px;
  color: var(--quiet);
}

.empty-list p {
  margin: 0;
  font-size: 12px;
}

.empty-list-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
}

.empty-list-icon svg,
.empty-list-icon .lucide-icon {
  width: 16px;
  height: 16px;
}

.conversation-list {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 2px;
  padding: 4px 0;
  /* Only the vertical direction scrolls; a horizontal bar here is never wanted. */
  overflow-x: hidden;
}
.conversation-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 2px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13.5px;
}
.conversation-item:nth-child(even) {
  background: color-mix(in srgb, var(--surface-hover) 40%, transparent);
}
.conversation-item:hover,
.conversation-item:focus-within {
  background: var(--surface-hover);
}
.conversation-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.conversation-open {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex: 1;
  align-items: baseline;
  gap: 6px;
  padding: 7px 8px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.conversation-open .conversation-label {
  overflow: hidden;
  flex: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-open.answering::after {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: none;
  align-self: center;
  border-radius: 50%;
  background: var(--accent);
  content: "";
  vertical-align: middle;
}
.conversation-action {
  display: grid;
  width: 27px;
  height: 27px;
  flex: none;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--quiet);
  cursor: pointer;
  place-items: center;
}
/* Out of the layout until wanted, so the title has the row's full width. */
.conversation-item:not(:hover, :focus-within) .conversation-action {
  display: none;
}
.conversation-action:hover {
  background: var(--surface);
  color: var(--text);
}
.conversation-action svg {
  width: 16px;
  height: 16px;
}

.rename-field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.dialog-status:empty {
  display: none;
}
.dialog-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.assistant-list {
  display: grid;
  max-height: 208px;
  align-content: start;
  gap: 2px;
  padding: 4px 0;
  overflow-x: hidden;
}
.assistant-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.assistant-info {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.assistant-info:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.assistant-info .lucide-icon {
  width: 15px;
  height: 15px;
}
.assistant-info-dialog {
  width: min(560px, calc(100vw - 32px));
}
.assistant-instructions {
  max-height: 52vh;
  overflow-y: auto;
  white-space: pre-wrap;
}
.assistant-option {
  flex: 1;
  min-width: 0;
  display: grid;
  overflow: hidden;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.assistant-option:hover {
  background: var(--surface-hover);
}
.assistant-option.active {
  background: var(--accent-soft);
}
.assistant-option strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 640;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assistant-option span {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  padding-bottom: 8px;
}
.attachment-chip {
  display: flex;
  max-width: 260px;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .lucide-icon {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--muted);
}
.attachment-size,
.attachment-progress {
  flex: none;
  color: var(--quiet);
  font-size: 12px;
}
.attachment-chip.pending {
  padding-right: 11px;
  border-style: dashed;
}
.attachment-chip.pending .attachment-progress {
  animation: pulse 1.3s ease-in-out infinite;
}
.attachment-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
  cursor: pointer;
  place-items: center;
}
.attachment-chip button:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.attachment-chip button svg {
  width: 13px;
  height: 13px;
}

.file-list {
  display: grid;
  gap: 8px;
}
.file-row {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}
.file-row strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row span {
  color: var(--muted);
  font-size: 12px;
}
.file-row button {
  padding: 6px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.file-row button:hover {
  background: var(--surface-hover);
}
.file-dropzone {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.file-dropzone .primary-button {
  min-height: 38px;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.file-dropzone .primary-button:hover {
  filter: brightness(1.08);
}
.file-dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-dropzone .lucide-icon {
  width: 22px;
  height: 22px;
}
.file-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.drop-overlay {
  position: fixed;
  z-index: 60;
  display: grid;
  padding: 24px;
  inset: 0;
  background: rgb(8 12 20 / 46%);
  place-items: center;
  backdrop-filter: blur(2px);
}
.drop-overlay-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 34px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}
.drop-overlay-card .lucide-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}
.drop-overlay-card span:last-child {
  color: var(--muted);
}

/* The active assistant sits in the composer toolbar, like a selected tool. */
.assistant-chip {
  display: flex;
  min-width: 0;
  max-width: 260px;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.assistant-chip > .lucide-icon,
.assistant-chip > svg {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--accent);
}
.assistant-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assistant-chip button {
  display: grid;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
  cursor: pointer;
  place-items: center;
}
.assistant-chip button:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.assistant-chip button svg {
  width: 14px;
  height: 14px;
}

.assistant-form {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns: 150px minmax(0, 1fr);
}
.assistant-form label {
  color: var(--muted);
  font-size: 13px;
}
.assistant-form input,
.assistant-form select,
.assistant-form textarea {
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.assistant-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.assistant-card {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.assistant-card h4 {
  margin: 0;
}
.assistant-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.assistant-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.assistant-card-actions button {
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.assistant-card-actions button:hover {
  background: var(--surface-hover);
}

@media (width <= 720px) {
  .assistant-form {
    grid-template-columns: minmax(0, 1fr);
  }
  .assistant-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.assistant-placeholder {
  padding: 10px 8px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.profile-row div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.profile-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 640;
}

.profile-row span {
  font-size: 11px;
}

body.authenticated .profile-detail { display: none; }

.sidebar-footer {
  position: relative;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.footer-action {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 9px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.footer-action:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.logout-action {
  margin-top: 4px;
}

.logout-action:hover {
  color: #c93c5a;
}

.profile-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.preferences { position: relative; flex: 0 0 auto; }

.preferences-open {
  width: 38px;
  justify-content: center;
  padding: 0;
}

.preferences-open span:last-child { display: none; }

.preferences-menu {
  position: absolute;
  z-index: 30;
  bottom: 0;
  left: calc(100% + 8px);
  width: 170px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preferences-item,
.theme-options button {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
}

.preferences-item:hover,
.theme-options button:hover { background: var(--surface-soft); }
.preferences-item .lucide-chevron-right { width: 16px; height: 16px; margin-left: auto; }
.preferences-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}
.theme-options {
  position: absolute;
  z-index: 31;
  bottom: 0;
  left: calc(100% + 8px);
  width: 140px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.theme-options button { padding: 0 9px; }
.theme-options button[aria-checked="true"]::after {
  margin-left: auto;
  color: var(--accent);
  content: "✓";
  font-weight: 800;
}

.footer-action svg,
.footer-action .lucide-icon {
  width: 18px;
  height: 18px;
}

.lucide-icon {
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background: currentColor;
  mask-image: var(--lucide-icon);
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-image: var(--lucide-icon);
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
}

.lucide-arrow-down { --lucide-icon: url("/assets/icons/arrow-down.svg"); }
.lucide-arrow-up { --lucide-icon: url("/assets/icons/arrow-up.svg"); }
.lucide-chart { --lucide-icon: url("/assets/icons/chart-no-axes-column-increasing.svg"); }
.lucide-chevron-down { --lucide-icon: url("/assets/icons/chevron-down.svg"); }
.lucide-chevron-right { --lucide-icon: url("/assets/icons/chevron-right.svg"); }
.lucide-circle-alert { --lucide-icon: url("/assets/icons/circle-alert.svg"); }
.lucide-clock { --lucide-icon: url("/assets/icons/clock.svg"); }
.lucide-file-text { --lucide-icon: url("/assets/icons/file-text.svg"); }
.lucide-info { --lucide-icon: url("/assets/icons/info.svg"); }
.lucide-lightbulb { --lucide-icon: url("/assets/icons/lightbulb.svg"); }
.lucide-list { --lucide-icon: url("/assets/icons/list.svg"); }
.lucide-log-out { --lucide-icon: url("/assets/icons/log-out.svg"); }
.lucide-menu { --lucide-icon: url("/assets/icons/menu.svg"); }
.lucide-message-square { --lucide-icon: url("/assets/icons/message-square.svg"); }
.lucide-moon { --lucide-icon: url("/assets/icons/moon.svg"); }
.lucide-panel-left { --lucide-icon: url("/assets/icons/panel-left.svg"); }
.lucide-paperclip { --lucide-icon: url("/assets/icons/paperclip.svg"); }
.lucide-pencil { --lucide-icon: url("/assets/icons/pencil.svg"); }
.lucide-plus { --lucide-icon: url("/assets/icons/plus.svg"); }
.lucide-search { --lucide-icon: url("/assets/icons/search.svg"); }
.lucide-settings { --lucide-icon: url("/assets/icons/settings.svg"); }
.lucide-square { --lucide-icon: url("/assets/icons/square.svg"); }
.lucide-sliders-horizontal { --lucide-icon: url("/assets/icons/sliders-horizontal.svg"); }
.lucide-star { --lucide-icon: url("/assets/icons/star.svg"); }
.lucide-sun { --lucide-icon: url("/assets/icons/sun.svg"); }
.lucide-trash { --lucide-icon: url("/assets/icons/trash.svg"); }
.lucide-x { --lucide-icon: url("/assets/icons/x.svg"); }

.moon-icon,
:root[data-theme="dark"] .sun-icon {
  display: none;
}

:root[data-theme="dark"] .moon-icon {
  display: block;
}

.profile-row {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
}

body:not(.authenticated) .profile-row {
  justify-content: flex-start;
  min-height: 38px;
  padding: 0;
  background: transparent;
}

body:not(.authenticated) .profile-row > :not(.profile-login) { display: none; }

/* The same button as the one above the composer: one action, one look. */
body:not(.authenticated) .profile-login {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

body:not(.authenticated) .profile-login:hover { background: var(--accent-hover); }

.profile-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
}

.profile-row .icon-button {
  margin-left: auto;
}

.conversation {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--accent) 4%, transparent), transparent 35%),
    var(--page);
}

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 68px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 24px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(14px);
}

.topbar-start,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.conversation-name {
  display: flex;
  flex-direction: column;
}

.conversation-name span {
  font-size: 14px;
  font-weight: 680;
}

.conversation-name small {
  color: var(--quiet);
  font-size: 11px;
}

.model-switcher {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.model-label {
  padding: 0 6px 0 7px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 650;
}

.model-option {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.model-option:hover {
  color: var(--text);
}

.model-option.active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(20, 22, 30, 0.1);
  color: var(--text);
}

.service-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d29b28;
}

.service-status[data-state="ready"] .status-dot {
  background: #30a66a;
}

.service-status[data-state="offline"] .status-dot {
  background: #d55757;
}

.welcome {
  display: flex;
  width: 100%;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 18px;
  text-align: center;
}

.welcome > * {
  max-width: 740px;
}

.welcome-mark {
  position: relative;
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 35px color-mix(in srgb, var(--accent) 14%, transparent);
}

.welcome-mark span {
  position: absolute;
  top: 17px;
  width: 8px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--focus));
  transform: rotate(28deg);
}

.welcome-mark span:nth-child(1) {
  left: 16px;
  height: 18px;
}

.welcome-mark span:nth-child(2) {
  left: 25px;
  top: 15px;
}

.welcome-mark span:nth-child(3) {
  left: 35px;
  top: 21px;
  height: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.welcome h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 45px);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.welcome-copy {
  max-width: 530px;
  margin: 13px auto 28px;
  color: var(--muted);
  font-size: 16px;
}

.suggestions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.suggestions button {
  display: grid;
  min-width: 0;
  min-height: 76px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 2px 7px rgba(30, 31, 45, 0.025);
  text-align: left;
}

.suggestions button:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.suggestion-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.suggestion-icon svg,
.suggestion-icon .lucide-icon {
  width: 21px;
  height: 21px;
}

:root[data-theme="dark"] .suggestion-icon {
  background: var(--surface-soft);
}

.suggestions button > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.suggestions strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions .arrow {
  width: 17px;
  height: 17px;
  color: var(--quiet);
}

.composer-area {
  position: relative;
  z-index: 4;
  width: min(790px, calc(100% - 38px));
  flex: none;
  align-self: center;
  padding: 8px 0 18px;
}

.scroll-bottom {
  position: absolute;
  z-index: 6;
  top: -46px;
  left: 50%;
  display: grid;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--composer-shadow);
  transform: translateX(-50%);
}

.scroll-bottom[hidden] {
  display: none;
}

.scroll-bottom:hover {
  background: var(--surface-hover);
}

.scroll-bottom svg,
.scroll-bottom .lucide-icon {
  width: 17px;
  height: 17px;
}

/* Suggestions take one row and scroll sideways, so the answer keeps the space. */
.follow-ups {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 2px 8px;
  scrollbar-width: thin;
}
.follow-ups.more {
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}
.follow-up {
  flex: none;
  max-width: min(320px, 80%);
  overflow: hidden;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.follow-up:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.availability-note {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.availability-login {
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}

.availability-login:hover { background: var(--accent-hover); }

.availability-note svg {
  width: 16px;
  height: 16px;
  color: #b27a15;
}

.composer {
  padding: 13px 13px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--composer-shadow);
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  box-shadow: var(--composer-shadow), 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 150px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--quiet);
}

.composer-tools,
.composer-start {
  display: flex;
  align-items: center;
}

.composer-tools {
  justify-content: space-between;
  margin-top: 9px;
}

.composer-start {
  gap: 7px;
}

.route-readout {
  padding-left: 7px;
  border-left: 1px solid var(--border);
  color: var(--quiet);
  font-size: 11px;
}

.route-readout strong {
  color: var(--muted);
}

.route-select {
  display: none;
  max-width: 150px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
}

.send-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
}

.send-button:disabled {
  background: var(--surface-hover);
  color: var(--quiet);
}

.send-button svg,
.send-button .lucide-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.stop-button {
  margin-right: 6px;
  background: var(--surface-hover);
  color: var(--muted);
  border: 1px solid var(--border);
}

.stop-button svg {
  fill: currentColor;
  stroke: none;
}

.composer-hint {
  margin: 8px 0 0;
  color: var(--quiet);
  font-size: 10px;
  text-align: center;
}
.attachment-note {
  font-size: 12px;
}
.attachment-note[data-error="true"] {
  color: #c93c5a;
}

.sidebar-backdrop {
  display: none;
}

@media (max-height: 720px) and (min-width: 821px) {
  .welcome {
    padding-top: 18px;
  }

  .welcome-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
  }

  .welcome-mark span {
    top: 13px;
  }

  .welcome-mark span:nth-child(2) {
    top: 11px;
  }

  .welcome-mark span:nth-child(3) {
    top: 17px;
  }

  .welcome-copy {
    margin-bottom: 18px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  /* On a narrow screen the preview covers the chat, which stays underneath. */
  .preview-panel {
    position: fixed;
    z-index: 50;
    inset: 0;
    border-left: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(90vw, 320px);
    border-right: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close,
  .menu-button {
    display: inline-grid;
  }

  /* The drawer has one width here, so there is nothing to widen. */
  .sidebar-width {
    display: none;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 15;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 10, 15, 0.46);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .conversation {
    height: 100dvh;
  }

  .topbar {
    min-height: 62px;
    padding: 8px 13px;
  }

  .topbar-start {
    gap: 6px;
  }

  .conversation-name small,
  .model-label,
  .status-label {
    display: none;
  }

  .service-status {
    padding: 9px;
  }

  .welcome {
    width: min(680px, calc(100% - 28px));
  }

  .composer-area {
    width: calc(100% - 24px);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .topbar-actions {
    gap: 7px;
  }

  /* No room beside the title: the choice moves into the composer. */
  .model-switcher,
  .route-readout {
    display: none;
  }

  .route-select:not([hidden]) {
    display: block;
  }

  .welcome {
    justify-content: center;
    padding: 20px 0 8px;
  }

  .welcome-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
  }

  .welcome-mark span {
    top: 13px;
  }

  .welcome-mark span:nth-child(2) {
    top: 11px;
  }

  .welcome-mark span:nth-child(3) {
    top: 17px;
  }

  .eyebrow {
    font-size: 10px;
  }

  .welcome h1 {
    font-size: 29px;
  }

  .welcome-copy {
    margin: 9px auto 18px;
    font-size: 14px;
  }

  .suggestions {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .suggestions button {
    min-height: 59px;
    padding: 8px 10px;
  }

  .suggestion-icon {
    width: 34px;
    height: 34px;
  }

  .availability-note {
    justify-content: flex-start;
    padding: 0 4px;
    font-size: 11px;
  }

  .composer {
    border-radius: 15px;
  }
}

@media (max-width: 380px) {
  .conversation-name {
    display: none;
  }

  .welcome-copy,
  .suggestions small {
    display: none;
  }

  .welcome h1 {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

[hidden] {
  display: none !important;
}

.profile-login {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.message-feed {
  width: 100%;
  min-height: 0;
  flex: 1;
  padding: 42px 0 24px;
}

.message {
  display: flex;
  width: min(820px, calc(100% - 40px));
  margin: 0 auto;
  flex-direction: column;
  padding: 14px 0;
}

/* The question sits in a bubble on the right; the answer reads as the page. */
.message.user .message-content {
  max-width: min(85%, 640px);
  align-self: flex-end;
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--accent-soft);
}

/* A rule before each question closes the exchange above it. */
.message.user:not(:first-child) {
  margin-top: 14px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.message-content {
  color: var(--text);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Rendered Markdown: the answer's own blank lines become paragraphs. */
.message.assistant .message-content {
  white-space: normal;
}

.message.assistant .message-content > :first-child {
  margin-top: 0;
}

.message.assistant .message-content > :last-child {
  margin-bottom: 0;
}

.message-content :is(p, ul, ol, blockquote, pre, table, h1, h2, h3, h4) {
  margin: 0 0 12px;
}

.message-content :is(h1, h2, h3, h4) {
  font-size: 1.05em;
  line-height: 1.4;
}

.message-content :is(ul, ol) {
  padding-left: 22px;
}

.message-content li + li {
  margin-top: 4px;
}

.message-content a {
  color: var(--accent);
  text-decoration: underline;
}

.message-content blockquote {
  padding-left: 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}

.message-content code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-soft);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.message-content pre {
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  white-space: pre;
}

.message-content pre code {
  padding: 0;
  background: none;
}

/* A wide table scrolls inside the answer instead of widening the page. */
.message-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  overflow-wrap: normal;
}

.message-content :is(th, td) {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.message-content th {
  background: var(--surface-soft);
  font-weight: 600;
}

.message-content hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.message-content[data-truncated]::after {
  display: block;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--quiet);
  content: "La risposta si è fermata qui: ha raggiunto il limite di lunghezza previsto.";
  font-size: 12px;
}

.message-content[data-failure]::after {
  display: block;
  margin-top: 6px;
  color: var(--quiet);
  content: "Codice: " attr(data-failure);
  font-size: 12px;
}

.message.assistant.pending .message-content:empty::after {
  content: "Elaborazione…";
  color: var(--muted);
  animation: pulse 1.3s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

.admin-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgb(0 0 0 / 28%);
}

.admin-dialog[open] {
  display: flex;
  flex-direction: column;
}

.admin-dialog .admin-dialog-body {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.system-assistant-list {
  display: grid;
  gap: 8px;
}
.system-assistant-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}
.system-assistant-row input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.system-assistant-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.system-assistant-row strong {
  font-size: 14px;
}
.system-assistant-row span {
  color: var(--muted);
  font-size: 12px;
}
.system-assistant-row.off strong,
.system-assistant-row.off span {
  opacity: 0.6;
}

.admin-dialog::backdrop {
  background: rgb(8 12 20 / 68%);
  backdrop-filter: blur(4px);
}

.branding-fields {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(2, minmax(150px, 0.45fr));
  gap: 14px;
}

.branding-fields .admin-field {
  max-width: none;
  align-items: stretch;
  flex-direction: column;
  gap: 6px;
}

.branding-fields .admin-field input {
  width: 100%;
  text-align: left;
}

.branding-fields .admin-field:last-child {
  grid-column: 1 / -1;
  max-width: 500px;
}

.color-field input { min-height: 42px; padding: 4px; }

.admin-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.admin-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.branding-contrast {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.branding-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.branding-preview img {
  max-width: 180px;
  max-height: 48px;
  object-fit: contain;
}

@media (max-width: 620px) {
  .branding-fields { grid-template-columns: 1fr 1fr; }
  .branding-fields .admin-field:first-child,
  .branding-fields .admin-field:last-child { grid-column: 1 / -1; }
}

.confirmation-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgb(0 0 0 / 28%);
}

.confirmation-dialog::backdrop {
  background: rgb(8 12 20 / 68%);
  backdrop-filter: blur(4px);
}

.confirmation-dialog form {
  display: grid;
  gap: 14px;
  padding: 26px;
}

.confirmation-dialog h2,
.confirmation-dialog p {
  margin: 0;
}

.confirmation-dialog p {
  color: var(--muted);
}

.confirmation-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #c93c5a;
  background: color-mix(in srgb, #c93c5a 12%, transparent);
  border-radius: 12px;
}

.confirmation-icon svg,
.confirmation-icon .lucide-icon {
  width: 22px;
  height: 22px;
}

.confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.confirmation-actions button {
  min-height: 40px;
  padding: 8px 16px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.confirmation-actions .danger-button {
  color: #fff;
  background: #b52f4b;
  border-color: #b52f4b;
}

.confirmation-actions .danger-button:hover {
  background: #94243d;
}

.admin-head,
.admin-section,
.admin-status {
  padding: 20px 24px;
}

.admin-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-head h2,
.admin-section h3,
.provider-family-card h4,
.provider-card h5 {
  margin: 0;
}

.admin-section-head,
.admin-global-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-field {
  display: flex;
  max-width: 320px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-field input {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  text-align: right;
}

/* A long text takes the whole row, label above. */
.admin-field:has(textarea) {
  max-width: none;
  flex-direction: column;
  align-items: stretch;
}

.admin-field textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.provider-models p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-status {
  min-height: 20px;
  padding-block: 10px;
  color: var(--muted);
  background: var(--surface-soft);
}

.admin-status[data-error="true"] {
  color: #c93c5a;
}

.admin-section {
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.admin-section-head {
  justify-content: space-between;
}

.admin-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.provider-family-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.provider-family-explanation,
.provider-family-empty,
.provider-access {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.provider-origin-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-origin-options label {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
}

.provider-origin-options label:has(input:checked) {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 700;
}

.provider-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.provider-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.provider-card label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.provider-status {
  width: fit-content;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 999px;
  font-size: 11px;
}

.admin-global-actions button,
.admin-section-head button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  cursor: pointer;
}

.admin-global-actions {
  position: sticky;
  bottom: 0;
  justify-content: flex-end;
  padding: 14px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.admin-global-actions .primary-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.admin-global-actions button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.provider-models {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.provider-models legend {
  padding-inline: 5px;
  color: var(--muted);
  font-size: 12px;
}

.provider-models label {
  color: var(--text);
}

@media (max-width: 760px) {
  .provider-grid {
    grid-template-columns: 1fr;
  }

  .provider-models {
    grid-template-columns: 1fr;
  }

}
