:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-muted: #f1f2ee;
  --panel-strong: #e7e9e3;
  --text: #1f2421;
  --text-soft: #69716c;
  --text-faint: #949b96;
  --line: #e2e5df;
  --line-strong: #d5d9d2;
  --accent: #156b52;
  --accent-hover: #105b45;
  --accent-soft: #e4f2ec;
  --coral: #d16b4c;
  --gold: #b4862e;
  --blue: #3e6f91;
  --danger: #b94747;
  --shadow-sm: 0 1px 2px rgba(32, 39, 34, 0.05);
  --shadow-md: 0 14px 40px rgba(32, 39, 34, 0.11);
  --sidebar-width: 280px;
  --topbar-height: 66px;
  --radius: 8px;
  --font: "DM Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

html.dark {
  color-scheme: dark;
  --bg: #171a18;
  --panel: #202421;
  --panel-muted: #282d29;
  --panel-strong: #313732;
  --text: #eef1ed;
  --text-soft: #acb4ae;
  --text-faint: #7f8881;
  --line: #343a35;
  --line-strong: #414942;
  --accent: #65b991;
  --accent-hover: #7bc8a3;
  --accent-soft: #263f34;
  --coral: #df896d;
  --gold: #d0a955;
  --blue: #75a2c0;
  --danger: #dc7777;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

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

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  padding: 18px 14px 14px;
  background: var(--panel-muted);
  border-right: 1px solid var(--line);
}

.brand-row,
.brand,
.topbar,
.topbar-left,
.topbar-actions,
.account-row,
.composer-toolbar,
.composer-left,
.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
}

.brand-row {
  justify-content: space-between;
  height: 36px;
  padding: 0 4px;
}

.brand {
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 72%, #000);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.18);
}

.brand-mark svg {
  width: 16px;
  height: 16px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border-radius: 7px;
}

.icon-button:hover {
  color: var(--text);
  background: var(--panel-strong);
}

.sidebar-close,
.sidebar-toggle {
  display: none;
}

.new-chat-button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 42px;
  margin-top: 22px;
  padding: 0 12px;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

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

.new-chat-button span {
  margin-left: 9px;
}

.new-chat-button kbd {
  margin-left: auto;
  padding: 2px 6px;
  color: rgba(255, 255, 255, 0.74);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  margin-top: 12px;
}

.search-box svg {
  position: absolute;
  left: 11px;
  z-index: 1;
  width: 16px;
  color: var(--text-faint);
}

.search-box input {
  width: 100%;
  height: 100%;
  padding: 0 12px 0 35px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-box input::placeholder,
.composer textarea::placeholder {
  color: var(--text-faint);
}

.conversation-section {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin-top: 22px;
}

.section-label {
  padding: 0 8px 8px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.conversation-list {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}

.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  margin-bottom: 3px;
  padding: 0 38px 0 0;
  color: var(--text-soft);
  background: transparent;
  border-radius: 7px;
}

.conversation-select {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  color: inherit;
  background: transparent;
  border-radius: 7px;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  color: var(--text);
  background: var(--panel-strong);
}

.conversation-item svg {
  width: 15px;
}

.conversation-item .conversation-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-delete {
  position: absolute;
  right: 5px;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--text-faint);
  background: transparent;
  border-radius: 6px;
}

.conversation-item:hover .conversation-delete,
.conversation-item.active .conversation-delete {
  display: grid;
}

.conversation-delete:hover {
  color: var(--danger);
  background: var(--panel);
}

.sidebar-empty {
  padding: 20px 10px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

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

.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--text-soft);
  background: transparent;
  border-radius: 7px;
  text-align: left;
}

.sidebar-action:hover {
  color: var(--text);
  background: var(--panel-strong);
}

.account-row {
  gap: 10px;
  margin-top: 8px;
  padding: 11px 8px 2px;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}

.avatar-user {
  color: #fff;
  background: #39443e;
}

.avatar-ai {
  color: #fff;
  background: var(--accent);
}

.avatar-ai svg {
  width: 15px;
  height: 15px;
}

.account-row > div {
  display: grid;
  min-width: 0;
}

.account-row strong {
  font-size: 12px;
  font-weight: 600;
}

.account-row div span {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-left: auto;
  background: #35a36f;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, #35a36f 15%, transparent);
}

.main-panel {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--panel);
}

.topbar {
  position: relative;
  z-index: 10;
  flex: 0 0 var(--topbar-height);
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 22px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-left {
  min-width: 0;
}

.conversation-heading {
  display: grid;
  min-width: 0;
}

.conversation-heading h1 {
  max-width: 48vw;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-heading span {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 10px;
}

.topbar-actions {
  gap: 4px;
}

.model-button {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  margin-right: 4px;
  padding: 0 10px;
  color: var(--text-soft);
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
}

.model-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.model-button svg {
  width: 14px;
}

.preference-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.preference-status-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 7px;
}

.preference-status > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.preference-status strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preference-status small {
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.45;
}

.model-indicator {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

.chat-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}

.announcement-bar {
  flex: 0 0 auto;
  padding: 8px 18px;
  color: #805126;
  background: #fff4e7;
  border-bottom: 1px solid #efdcc6;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

html.dark .announcement-bar {
  color: #e3b88e;
  background: #352a20;
  border-color: #504032;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(760px, calc(100% - 40px));
  min-height: 100%;
  margin: auto;
  padding: 48px 0 80px;
  text-align: center;
}

.empty-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 18%, transparent);
}

.empty-mark svg {
  width: 23px;
  height: 23px;
}

.empty-state h2 {
  margin: 20px 0 8px;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.3;
}

.empty-state > p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

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

.suggestion {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.suggestion:hover {
  border-color: var(--line-strong);
  background: var(--panel-muted);
  transform: translateY(-1px);
}

.suggestion > svg {
  width: 15px;
  color: var(--text-faint);
}

.suggestion-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
}

.suggestion-icon svg {
  width: 17px;
}

.suggestion-icon.sage {
  color: var(--accent);
  background: var(--accent-soft);
}

.suggestion-icon.coral {
  color: var(--coral);
  background: color-mix(in srgb, var(--coral) 13%, transparent);
}

.suggestion-icon.gold {
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 13%, transparent);
}

.suggestion-icon.blue {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 13%, transparent);
}

.suggestion span:nth-child(2) {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.suggestion strong {
  font-size: 13px;
  font-weight: 600;
}

.suggestion small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-list {
  width: min(900px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 44px;
}

.message {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 13px;
  margin-bottom: 30px;
}

.message-main {
  min-width: 0;
}

.message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.message-head strong {
  font-size: 12px;
  font-weight: 650;
}

.message-head time {
  color: var(--text-faint);
  font-size: 10px;
}

.message-content {
  margin-top: 7px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.message.user .message-content {
  display: inline-block;
  max-width: min(680px, 100%);
  padding: 10px 13px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 3px 8px 8px 8px;
  white-space: pre-wrap;
}

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

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

.message-content p,
.message-content ul,
.message-content ol,
.message-content blockquote,
.message-content pre,
.message-content table {
  margin: 0 0 13px;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 20px 0 9px;
  line-height: 1.4;
}

.message-content h1 {
  font-size: 20px;
}

.message-content h2 {
  font-size: 18px;
}

.message-content h3,
.message-content h4 {
  font-size: 15px;
}

.message-content ul,
.message-content ol {
  padding-left: 23px;
}

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

.message-content blockquote {
  padding: 6px 0 6px 13px;
  color: var(--text-soft);
  border-left: 3px solid var(--line-strong);
}

.message-content code {
  padding: 2px 5px;
  color: var(--coral);
  background: var(--panel-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.message-content pre {
  position: relative;
  max-width: 100%;
  padding: 15px;
  overflow: auto;
  color: #dce5df;
  background: #1d2420;
  border: 1px solid #313a35;
  border-radius: 7px;
}

.message-content pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font-size: 12px;
  line-height: 1.65;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.message-content th,
.message-content td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.message-content th {
  background: var(--panel-muted);
}

.message-content a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  margin-top: 7px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.message:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}

.message-action {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--text-faint);
  background: transparent;
  border-radius: 6px;
}

.message-action:hover {
  color: var(--text);
  background: var(--panel-muted);
}

.message-action svg {
  width: 15px;
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
}

.thinking i {
  width: 5px;
  height: 5px;
  background: var(--text-faint);
  border-radius: 50%;
  animation: thinking 1.1s infinite ease-in-out;
}

.thinking i:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking i:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinking {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.error-message {
  padding: 10px 12px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  border-radius: 7px;
}

.scroll-bottom {
  position: sticky;
  bottom: 18px;
  left: calc(50% - 18px);
  display: none;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--text-soft);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

.scroll-bottom.visible {
  display: grid;
}

.composer-wrap {
  position: relative;
  z-index: 9;
  flex: 0 0 auto;
  padding: 12px 24px 14px;
  background: var(--panel);
}

.composer {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 10px 10px 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(32, 39, 34, 0.08);
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  box-shadow: 0 8px 28px rgba(32, 39, 34, 0.08), 0 0 0 3px color-mix(in srgb, var(--accent) 9%, transparent);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  padding: 2px 3px 9px;
  resize: none;
  overflow-y: auto;
  background: transparent;
  border: 0;
  line-height: 1.55;
}

.composer textarea:focus {
  outline: none;
}

.composer-toolbar {
  justify-content: space-between;
  min-height: 34px;
}

.composer-left {
  gap: 8px;
}

.tool-button {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  color: var(--text-soft);
  background: transparent;
  border-radius: 6px;
  font-size: 11px;
}

.tool-button:hover {
  color: var(--text);
  background: var(--panel-muted);
}

.tool-button svg {
  width: 15px;
}

.char-count {
  color: var(--text-faint);
  font-size: 10px;
}

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

.send-button:hover {
  background: var(--accent-hover);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.send-button svg {
  width: 17px;
}

.stop-button {
  background: var(--danger);
}

.composer-note {
  margin: 7px 0 0;
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
}

.settings-dialog {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}

.settings-dialog::backdrop {
  background: rgba(12, 16, 13, 0.48);
  backdrop-filter: blur(4px);
}

.settings-card {
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.dialog-header {
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.dialog-header h2 {
  margin: 3px 0 0;
  font-size: 20px;
}

.settings-body {
  display: grid;
  gap: 17px;
  padding: 20px 22px;
}

.form-row.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-label {
  display: grid;
  gap: 7px;
}

.field-label > span:first-child,
.range-label > span:first-child {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
}

.field-label input,
.field-label select,
.field-label textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-muted);
}

.field-label input,
.field-label select {
  height: 40px;
  padding: 0 11px;
}

.field-label textarea {
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.55;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 46px;
}

.password-field .icon-button {
  position: absolute;
  top: 2px;
  right: 2px;
}

.range-label > span:first-child {
  display: flex;
  justify-content: space-between;
}

.range-label output {
  color: var(--accent);
}

.range-label input {
  height: 6px;
  padding: 0;
  accent-color: var(--accent);
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 50px;
  cursor: pointer;
}

.switch-row > span:first-child {
  display: grid;
  gap: 3px;
}

.switch-row strong {
  font-size: 12px;
}

.switch-row small {
  color: var(--text-faint);
  font-size: 10px;
}

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch-control {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition: background 0.16s ease;
}

.switch-control::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--panel);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  content: "";
  transition: transform 0.16s ease;
}

.switch-row input:checked + .switch-control {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-row input:checked + .switch-control::after {
  transform: translateX(18px);
}

.connection-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  color: var(--text-soft);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.5;
}

.connection-note svg {
  width: 16px;
  color: var(--accent);
}

.dialog-footer {
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 20px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
}

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

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  color: var(--text-soft);
  background: var(--panel-muted);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.primary-button svg {
  width: 15px;
}

.prompt-popover {
  position: fixed;
  z-index: 50;
  display: grid;
  width: 210px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.prompt-popover button {
  height: 36px;
  padding: 0 10px;
  color: var(--text-soft);
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  text-align: left;
}

.prompt-popover button:hover {
  color: var(--text);
  background: var(--panel-muted);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 11px 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  animation: toast-in 0.18s ease both;
}

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: var(--shadow-md);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }

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

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

  .sidebar-toggle {
    margin-right: 8px;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(12, 16, 13, 0.38);
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  .suggestion-grid {
    width: min(620px, 100%);
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 58px;
  }

  .topbar {
    padding: 0 10px;
  }

  .topbar-actions {
    gap: 0;
  }

  .topbar-actions > .icon-button {
    display: inline-grid;
  }

  .conversation-heading h1 {
    max-width: 34vw;
  }

  .conversation-heading span {
    display: none;
  }

  .model-button {
    max-width: 116px;
    margin: 0;
  }

  .model-button span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .empty-state {
    width: calc(100% - 28px);
    justify-content: flex-start;
    padding: 76px 0 40px;
  }

  .empty-state h2 {
    font-size: 22px;
  }

  .empty-state > p {
    max-width: 290px;
    line-height: 1.6;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
    margin-top: 28px;
  }

  .suggestion {
    min-height: 64px;
  }

  .message-list {
    width: calc(100% - 26px);
    padding-top: 24px;
  }

  .message {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 24px;
  }

  .avatar {
    width: 28px;
    height: 28px;
  }

  .message-actions {
    opacity: 1;
  }

  .composer-wrap {
    padding: 9px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer-note {
    display: none;
  }

  .composer textarea {
    max-height: 130px;
  }

  .char-count,
  .new-chat-button kbd {
    display: none;
  }

  .form-row.two-columns {
    grid-template-columns: 1fr;
  }

  .settings-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .settings-card {
    max-height: calc(100dvh - 16px);
  }
}

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

  .topbar {
    padding: 0 8px;
  }

  .model-button {
    max-width: 108px;
  }
}

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

/* Brand refresh: light technology, navy typography, cyan interaction. */
:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-muted: #f0f5fa;
  --panel-strong: #e5edf6;
  --text: #172347;
  --text-soft: #63708e;
  --text-faint: #97a4bc;
  --line: #dbe4ef;
  --line-strong: #c8d5e4;
  --accent: #13a6c4;
  --accent-hover: #0d8eaa;
  --accent-soft: #def6fa;
  --coral: #e86470;
  --gold: #d89b31;
  --blue: #4776b4;
  --danger: #c84955;
  --shadow-sm: 0 2px 8px rgba(27, 51, 91, 0.06);
  --shadow-md: 0 18px 50px rgba(27, 51, 91, 0.13);
  --sidebar-width: 292px;
}

html.dark {
  --bg: #121722;
  --panel: #191f2c;
  --panel-muted: #202838;
  --panel-strong: #293348;
  --text: #f3f7ff;
  --text-soft: #afbdd3;
  --text-faint: #7f8ca3;
  --line: #303b50;
  --line-strong: #3d4a64;
  --accent: #55cee3;
  --accent-hover: #7bdced;
  --accent-soft: #173846;
  --coral: #f1848d;
  --gold: #e6b85c;
  --blue: #82a8da;
  --danger: #ef828b;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sidebar {
  padding: 16px 14px 14px;
  background: var(--panel);
  box-shadow: 6px 0 24px rgba(27, 51, 91, 0.035);
}

.brand-row { height: 48px; }
.brand { gap: 10px; }
.brand-symbol {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #ffffff;
  background: #1b2a57;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(27, 42, 87, 0.14);
}
.brand-symbol svg { width: 16px; height: 16px; color: #67d8e9; }
.brand-name { color: #172347; font-size: 17px; font-weight: 700; }
html.dark .brand-name { color: var(--text); }

.new-chat-button {
  height: 44px;
  margin-top: 18px;
  background: #1b2a57;
  box-shadow: 0 8px 20px rgba(27, 42, 87, 0.15);
}

.new-chat-button:hover { background: #24366d; }
.new-chat-button svg { color: #67d8e9; }

.search-box input {
  background: var(--panel-muted);
  border-color: transparent;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--accent-soft);
}

.conversation-item.active { color: #117f99; }

.account-row {
  margin-top: 10px;
  padding: 12px 8px 4px;
}

.avatar-user { background: #1b2a57; }
.avatar-ai { color: #138eaa; background: #e2f6fa; border: 1px solid #bfe7ef; }
.avatar-ai svg { width: 15px; height: 15px; }
.status-dot { background: #22b8cf; box-shadow: 0 0 0 3px rgba(34, 184, 207, 0.15); }

.main-panel { background: var(--bg); }
.topbar { background: color-mix(in srgb, var(--panel) 92%, transparent); }

.model-button {
  color: #21315f;
  background: #eef7fa;
  border-color: #cce9ef;
}

html.dark .model-button {
  color: var(--text);
  background: var(--panel-strong);
  border-color: var(--line-strong);
}
.model-indicator { background: #20b8d3; box-shadow: 0 0 0 3px rgba(32, 184, 211, 0.12); }

.empty-state { padding-top: 52px; }
.empty-mark {
  width: 68px;
  height: 68px;
  color: #148faa;
  background: #e2f7fa;
  border: 1px solid #bfe9ef;
  border-radius: 18px;
  box-shadow: 0 14px 30px rgba(32, 83, 123, 0.1);
}
.empty-mark svg { width: 30px; height: 30px; }
.empty-state h2 { color: #172347; font-size: 27px; }
html.dark .empty-state h2 { color: var(--text); }

.suggestion {
  background: color-mix(in srgb, var(--panel) 97%, transparent);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.suggestion:hover {
  border-color: #9fdbe5;
  box-shadow: 0 10px 26px rgba(32, 83, 123, 0.1);
  transform: translateY(-2px);
}

.message.assistant .message-main {
  padding: 14px 16px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.composer {
  background: var(--panel);
  border-color: #cbd9e8;
  box-shadow: 0 16px 42px rgba(27, 51, 91, 0.13);
}
.composer:focus-within { border-color: #72cddd; box-shadow: 0 16px 42px rgba(27, 51, 91, 0.13), 0 0 0 3px rgba(19, 166, 196, 0.09); }
.send-button { background: var(--accent); }
.send-button:hover { background: var(--accent-hover); }

.preference-status-icon { color: #167f99; background: var(--accent-soft); }
.connection-note { color: #176f85; background: #e7f7fa; border-color: #c8eaf0; }

@media (max-width: 640px) {
  .empty-state { padding-top: 48px; }
  .empty-mark { width: 60px; height: 60px; border-radius: 16px; }
  .empty-state h2 { font-size: 23px; }
  .message.assistant .message-main { padding: 12px; }
}
