:root {
  --bg: #ffffff;
  --panel: #f9f9f9;
  --sidebar: #f7f7f8;
  --sidebar-border: #e5e5e5;
  --text: #171717;
  --muted: #6b7280;
  --button: #ececec;
  --button-hover: #e4e4e7;
  --accent: #111827;
  --bubble: #f4f4f5;
  --shadow: 0 16px 50px rgba(15, 23, 42, 0.18);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

body:not(.ready) .app-shell {
  visibility: hidden;
}

.app-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #18181b;
  z-index: 100;
}

.app-loading .ios-snowflake {
  width: 24px;
  height: 24px;
}

body.ready .app-loading {
  display: none;
}

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

button {
  border: 0;
  cursor: pointer;
}

button svg,
label svg {
  display: block;
  flex: none;
  margin: 0;
  pointer-events: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}

.sidebar {
  position: relative;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 38px;
}

.sidebar-brand {
  color: #0f0f0f;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
  stroke: #8a8a8a;
}

.sidebar-actions {
  display: flex;
}

.app-shell.sidebar-collapsed .sidebar {
  align-items: center;
  gap: 12px;
}

.app-shell.sidebar-collapsed .sidebar-top {
  justify-content: center;
}

.app-shell.sidebar-collapsed .sidebar-brand,
.app-shell.sidebar-collapsed .history-block,
.app-shell.sidebar-collapsed .profile-button span,
.app-shell.sidebar-collapsed .profile-button > svg,
.app-shell.sidebar-collapsed .merged-compose span {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-actions,
.app-shell.sidebar-collapsed .compose-button,
.app-shell.sidebar-collapsed .profile-button {
  width: 38px;
}

.app-shell.sidebar-collapsed .compose-button {
  flex: none;
  padding: 0;
  justify-content: center;
}

.app-shell.sidebar-collapsed .profile-button {
  grid-template-columns: 1fr;
  padding: 2px;
}

.app-shell.sidebar-collapsed .sidebar-toggle svg {
  transform: scaleX(-1);
}

.sidebar-scrim {
  display: none;
}

.icon-button,
.menu-button,
.tool-button,
.send-button,
.close-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  line-height: 1;
}

.icon-button:hover,
.menu-button:hover,
.tool-button:hover,
.close-button:hover,
.nav-item:hover,
.history-item:hover,
.compose-button:hover,
.profile-button:hover {
  background: var(--button-hover);
}

.plus-icon {
  font-size: 24px;
  line-height: 1;
}

.compose-button,
.nav-item,
.history-item {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--text);
}

.compose-button {
  flex: 1;
  background: var(--button);
}

.merged-compose {
  display: flex;
  align-items: center;
  gap: 10px;
}

.merged-compose svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.nav-stack {
  display: grid;
  gap: 4px;
}

.nav-item.active,
.history-item.active {
  background: var(--button);
}

.history-block {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.history-block h2 {
  margin: 0 0 6px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.history-list {
  display: grid;
  gap: 3px;
  max-height: 100%;
  overflow-y: auto;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr 30px;
  align-items: center;
  border-radius: 8px;
}

.history-row.active,
.history-row:hover {
  background: var(--button);
}

.history-row .history-item {
  background: transparent;
}

.history-delete {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}

.history-row:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  background: #fee2e2;
  color: #991b1b;
}

.history-delete svg {
  width: 18px;
  height: 18px;
}

.profile-button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.avatar,
.welcome-avatar,
.settings-avatar {
  object-fit: cover;
  background: #eadfcc;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.profile-more {
  color: var(--muted);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-button svg {
  width: 18px;
  height: 18px;
  stroke: var(--muted);
}

.chat-main {
  position: relative;
  display: grid;
  grid-template-rows: 56px 1fr auto;
  min-width: 0;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

.menu-button {
  display: none;
}

.model-button {
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  color: #404040;
  font-weight: 600;
}

.top-balance {
  margin-left: 6px;
  color: #52525b;
  font-size: .6em;
  font-weight: 500;
}

.top-balance b {
  color: #16a34a;
  font-weight: 700;
}

.top-balance em {
  margin-left: 6px;
  color: #f87171;
  font-style: normal;
  font-size: 11px;
  font-weight: 650;
}

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

.messages {
  overflow-y: auto;
  padding: 24px 18px 150px;
}

.welcome {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 55vh;
  gap: 18px;
}

.welcome-avatar {
  width: 72px;
  height: 72px;
  border-radius: 20px;
}

.welcome h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0;
}

.message {
  width: min(780px, 100%);
  margin: 0 auto 22px;
  line-height: 1.65;
}

.message.user {
  display: flex;
  justify-content: flex-end;
}

.bubble {
  max-width: min(620px, 85%);
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--bubble);
  white-space: pre-wrap;
}

.assistant-content {
  padding: 0 8px;
}

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

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

.assistant-content p,
.assistant-content ul,
.assistant-content ol,
.assistant-content .md-table-wrap,
.assistant-content pre {
  margin: 0 0 12px;
}

.assistant-content h1,
.assistant-content h2,
.assistant-content h3 {
  margin: 18px 0 8px;
  line-height: 1.25;
  letter-spacing: 0;
}

.assistant-content h1 {
  font-size: 24px;
}

.assistant-content h2 {
  font-size: 20px;
}

.assistant-content h3 {
  font-size: 17px;
}

.assistant-content ul,
.assistant-content ol {
  padding-left: 22px;
}

.assistant-content li {
  margin: 4px 0;
}

.assistant-content a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.assistant-content img {
  display: block;
  max-width: min(100%, 560px);
  max-height: 420px;
  margin: 10px 0 14px;
  border-radius: 10px;
  object-fit: contain;
}

.assistant-content pre {
  overflow-x: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: #18181b;
  color: #f4f4f5;
  line-height: 1.55;
  white-space: pre;
}

.assistant-content code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #f4f4f5;
  color: #18181b;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}

.assistant-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.assistant-content .md-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.assistant-content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.assistant-content th,
.assistant-content td {
  padding: 8px 10px;
  border: 1px solid #e4e4e7;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.assistant-content th {
  background: #f4f4f5;
  color: #27272a;
  font-weight: 650;
}

.message-spend {
  margin-top: 10px;
  color: #ef4444;
  font-size: 12px;
  line-height: 1.4;
}

.interrupted-note {
  margin-top: 6px;
  color: #8a8a8a;
  font-size: 12px;
  line-height: 1.4;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  max-width: 220px;
  padding: 5px 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e8ea;
  color: #52525b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  position: absolute;
  right: 24px;
  bottom: 24px;
  left: 24px;
  width: min(780px, calc(100% - 48px));
  margin: 0 auto;
  padding: 8px;
  border: 1px solid #dedede;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.attachment-list {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 6px 8px;
}

.attachment-list.visible {
  display: flex;
}

.queued-list {
  display: none;
  gap: 8px;
  padding: 4px 6px 8px;
}

.queued-list.visible {
  display: grid;
}

.queued-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f4f5;
  color: #3f3f46;
  font-size: 13px;
}

.queued-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queued-item button {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  background: #ffffff;
  color: #18181b;
}

.queued-item button svg {
  width: 14px;
  height: 14px;
}

.queued-item .queued-remove {
  width: 28px;
  min-width: 28px;
  padding: 0;
  line-height: 1;
}

.queued-item button:hover {
  background: #e4e4e7;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.composer-meta {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  max-width: 122px;
  min-height: 38px;
  margin-right: 8px;
}

.model-select {
  position: relative;
  width: 122px;
}

.model-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 122px;
  height: 30px;
  padding: 0 30px 0 14px;
  border: 0;
  border-radius: 8px;
  background: #f4f4f5;
  color: #52525b;
  font-size: 13px;
  font-weight: 560;
  outline: 0;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.model-select-trigger:hover,
.model-select.open .model-select-trigger,
.model-select:focus-within .model-select-trigger {
  background: #e4e4e7;
  color: #27272a;
}

.model-select-trigger:focus-visible {
  box-shadow: 0 0 0 3px rgba(82, 82, 91, .14);
}

.model-select-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-select-trigger svg {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-50%);
  transition: transform .16s ease;
}

.model-select.open .model-select-trigger svg,
.model-select:focus-within .model-select-trigger svg {
  transform: translateY(-50%) rotate(180deg);
}

.model-select-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 20px);
  display: none;
  width: min(220px, calc(100vw - 32px));
  min-width: 142px;
  max-height: 300px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 6px;
  border: 1px solid rgba(24, 24, 27, .08);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 18px 45px rgba(24, 24, 27, .16), 0 4px 14px rgba(24, 24, 27, .08);
  backdrop-filter: blur(18px);
  z-index: 30;
  scrollbar-width: none;
}

.model-select.has-more::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: calc(100% + 20px);
  display: block;
  width: min(220px, calc(100vw - 32px));
  min-width: 142px;
  height: 44px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, .72) 58%, rgba(255, 255, 255, .98));
  pointer-events: none;
  z-index: 31;
}

.model-select.has-more::before {
  content: "";
  position: absolute;
  left: min(110px, calc((100vw - 32px) / 2));
  bottom: calc(100% + 31px);
  display: block;
  width: 9px;
  height: 9px;
  border-right: 2px solid #71717a;
  border-bottom: 2px solid #71717a;
  pointer-events: none;
  transform: translateX(-50%) translateY(-3px) rotate(45deg);
  animation: model-more-bounce 1.05s ease-in-out infinite;
  z-index: 32;
}

.model-select-menu::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.model-select-menu::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.model-select-menu::-webkit-scrollbar-track {
  background: transparent;
}

.model-select-menu::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, .94);
  border-radius: 999px;
  background: #c4c4cc;
}

.model-select-menu::-webkit-scrollbar-thumb:hover {
  background: #a1a1aa;
}

.model-select.open .model-select-menu,
.model-select:focus-within .model-select-menu {
  display: grid;
  gap: 2px;
}

.model-select-option {
  width: 100%;
  min-height: 32px;
  padding: 0 28px 0 10px;
  border-radius: 7px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 540;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-select-option:hover {
  background: #f4f4f5;
  color: #18181b;
}

.model-select-option.selected {
  background: #18181b;
  color: #ffffff;
}

@keyframes model-more-bounce {
  0%, 100% {
    opacity: .35;
    transform: translateX(-50%) translateY(-4px) rotate(45deg);
  }
  50% {
    opacity: .9;
    transform: translateX(-50%) translateY(1px) rotate(45deg);
  }
}

.composer.disabled {
  pointer-events: none;
  opacity: .5;
}

.onboarding {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: #ffffff;
  z-index: 40;
}

.onboarding.open {
  display: grid;
}

.onboarding-panel {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 420px;
  text-align: center;
}

.onboarding-panel h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.onboarding-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.tool-button input,
.secondary-button input {
  display: none;
}

.image-tool {
  display: none;
}

#promptInput {
  flex: 1;
  max-height: 160px;
  min-height: 38px;
  padding: 9px 6px;
  resize: none;
  border: 0;
  outline: 0;
  line-height: 1.5;
}

.send-button {
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 20px;
}

.send-button:disabled {
  cursor: not-allowed;
  background: #d4d4d8;
}

.send-button.streaming {
  background: #18181b;
}

.send-button.streaming svg {
  color: #ffffff;
  fill: #ffffff;
  stroke: #ffffff;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0, 0, 0, 0.18);
}

.drawer-backdrop.open {
  display: block;
  z-index: 41;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .28);
  z-index: 30;
}

.confirm-backdrop.open {
  display: grid;
}

.confirm-dialog {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid rgba(24, 24, 27, .12);
  border-radius: 18px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255,255,255,.92);
  backdrop-filter: blur(24px) saturate(180%);
}

.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(420px, 100vw);
  height: 100vh;
  padding: 22px;
  border-left: 1px solid rgba(24, 24, 27, .08);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .9)),
    rgba(255, 255, 255, .74);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, .82);
  backdrop-filter: blur(28px) saturate(180%);
  transform: translateX(105%);
  transition: transform 0.18s ease;
  z-index: 42;
  overflow-y: auto;
}

.settings-drawer.open {
  transform: translateX(0);
  box-shadow: -28px 0 90px rgba(0, 0, 0, .2), inset 1px 0 0 rgba(255, 255, 255, .82);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.drawer-header h2 {
  margin: 0 0 4px;
}

.drawer-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-preview {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-section h3,
.section-title h3 {
  margin: 0;
  font-size: 15px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-list {
  display: grid;
  gap: 8px;
}

.api-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(24, 24, 27, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .56);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255, 255, 255, .95);
  backdrop-filter: blur(16px);
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.api-item:hover {
  transform: translateY(-1px);
  border-color: rgba(24, 24, 27, .22);
}

.api-item.active {
  border-color: #18181b;
  background: rgba(250, 250, 250, .96);
}

.api-item small {
  color: var(--muted);
}

.api-item small b {
  color: #16a34a;
  font-weight: 750;
}

.api-item small em {
  color: #ef4444;
  font-size: 11px;
  font-style: normal;
}

.settings-avatar {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

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

.field span {
  color: #3f3f46;
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(24, 24, 27, .11);
  border-radius: 12px;
  background: rgba(255, 255, 255, .48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .92), 0 10px 24px rgba(0, 0, 0, .045);
  backdrop-filter: blur(14px);
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.field input:focus,
.field select:focus {
  border-color: #52525b;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 0 0 4px rgba(24, 24, 27, .06), 0 14px 30px rgba(0, 0, 0, .07);
}

.drawer-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: #ff5252;
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(255, 82, 82, .28);
  font-weight: 650;
}

.danger-button.armed {
  background: #ff1744;
  box-shadow: 0 0 0 4px rgba(255, 23, 68, .14), 0 14px 34px rgba(255, 23, 68, .34);
}

.ios-snowflake {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  vertical-align: -2px;
}

.ios-snowflake i {
  position: absolute;
  left: 48%;
  top: 4%;
  width: 9%;
  height: 28%;
  border-radius: 999px;
  background: #8e8e93;
  opacity: .18;
  transform-origin: 50% 164%;
  animation: ios-snowflake-fade 1s linear infinite;
}

.ios-snowflake i:nth-child(1) { transform: rotate(0deg); animation-delay: -0.9167s; }
.ios-snowflake i:nth-child(2) { transform: rotate(30deg); animation-delay: -0.8333s; }
.ios-snowflake i:nth-child(3) { transform: rotate(60deg); animation-delay: -0.75s; }
.ios-snowflake i:nth-child(4) { transform: rotate(90deg); animation-delay: -0.6667s; }
.ios-snowflake i:nth-child(5) { transform: rotate(120deg); animation-delay: -0.5833s; }
.ios-snowflake i:nth-child(6) { transform: rotate(150deg); animation-delay: -0.5s; }
.ios-snowflake i:nth-child(7) { transform: rotate(180deg); animation-delay: -0.4167s; }
.ios-snowflake i:nth-child(8) { transform: rotate(210deg); animation-delay: -0.3333s; }
.ios-snowflake i:nth-child(9) { transform: rotate(240deg); animation-delay: -0.25s; }
.ios-snowflake i:nth-child(10) { transform: rotate(270deg); animation-delay: -0.1667s; }
.ios-snowflake i:nth-child(11) { transform: rotate(300deg); animation-delay: -0.0833s; }
.ios-snowflake i:nth-child(12) { transform: rotate(330deg); animation-delay: 0s; }

@keyframes ios-snowflake-fade {
  0% {
    opacity: .95;
  }
  100% {
    opacity: .18;
  }
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}

.secondary-button {
  display: inline-grid;
  place-items: center;
  background: var(--button);
  color: var(--text);
}

.api-detected {
  display: grid;
  gap: 14px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: max-height .24s ease, opacity .2s ease, transform .2s ease;
}

.api-detected.visible {
  max-height: 430px;
  opacity: 1;
  transform: translateY(0);
}

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid rgba(24, 24, 27, .1);
  border-radius: 14px;
  background: rgba(255, 255, 255, .5);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255,255,255,.92);
  backdrop-filter: blur(18px);
}

.result-card span {
  color: var(--muted);
  font-size: 13px;
}

.result-card strong {
  color: #111827;
  font-size: 20px;
  letter-spacing: 0;
}

  .field-hint {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (min-width: 761px) and (max-width: 1024px) {
  .model-select-menu,
  .model-select.has-more::after {
    right: 0;
    left: auto;
  }

  .model-select.has-more::before {
    left: auto;
    right: min(104px, calc((100vw - 32px) / 2));
  }
}

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

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    z-index: 24;
  }

  .app-shell.sidebar-collapsed .sidebar {
    align-items: stretch;
    gap: 18px;
  }

  .app-shell.sidebar-collapsed .sidebar-brand,
  .app-shell.sidebar-collapsed .history-block,
  .app-shell.sidebar-collapsed .profile-button span,
  .app-shell.sidebar-collapsed .profile-button > svg,
  .app-shell.sidebar-collapsed .merged-compose span {
    display: initial;
  }

  .app-shell.sidebar-collapsed .history-block {
    display: block;
  }

  .app-shell.sidebar-collapsed .sidebar-actions,
  .app-shell.sidebar-collapsed .compose-button,
  .app-shell.sidebar-collapsed .profile-button {
    width: 100%;
  }

  .app-shell.sidebar-collapsed .compose-button {
    padding: 8px 12px;
    justify-content: flex-start;
  }

  .app-shell.sidebar-collapsed .profile-button {
    grid-template-columns: 34px 1fr auto;
    padding: 8px;
  }

  .sidebar-scrim.open {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(0, 0, 0, .18);
    z-index: 23;
  }

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

  .history-row {
    grid-template-columns: 1fr 38px;
  }

  .history-delete {
    justify-self: center;
    align-self: center;
    width: 34px;
    height: 34px;
    opacity: 1;
  }

  .menu-button {
    display: grid;
  }

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

  .composer {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: calc(100% - 24px);
    max-height: calc(100dvh - 96px);
  }

  .input-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 6px;
    align-items: center;
  }

  .composer-meta {
    position: absolute;
    top: -42px;
    right: 10px;
    width: auto;
    max-width: none;
    margin-right: 0;
  }

  .file-tool {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    justify-self: center;
  }

  .model-select {
    margin-left: auto;
  }

  #promptInput {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    align-self: center;
  }

  .send-button {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    justify-self: center;
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
  }

  .send-button svg {
    width: 20px;
    height: 20px;
  }

  .model-select-menu,
  .model-select.has-more::after {
    right: 0;
    left: auto;
    width: min(220px, calc(100vw - 24px));
  }

  .model-select.has-more::before {
    left: auto;
    right: min(104px, calc((100vw - 24px) / 2));
  }
}
