:root {
  color-scheme: light;
  --bg: #f6f6f6;
  --sidebar: #eeeeee;
  --surface: #ffffff;
  --surface-soft: #f3f3f3;
  --surface-hover: #e9e9e9;
  --surface-elevated: #ffffff;
  --ink: #171717;
  --muted: #686868;
  --subtle: #8a8a8a;
  --line: rgba(20, 20, 20, 0.07);
  --line-strong: rgba(20, 20, 20, 0.12);
  --accent: #526aef;
  --accent-dark: #3045c7;
  --accent-light: #4058df;
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.1);
  --error-border: rgba(220, 38, 38, 0.22);
  --input-bg: #ffffff;
  --input-border: rgba(20, 20, 20, 0.1);
  --user-bubble: #e4e4e4;
  --shadow: 0 18px 46px rgba(20, 20, 20, 0.12);
  --soft-shadow: 0 10px 26px rgba(20, 20, 20, 0.08);
  --control-bg: rgba(20, 20, 20, 0.055);
  --focus-ring: rgba(82, 106, 239, 0.2);
  --select-arrow: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23686868' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

html.is-public,
body.is-public {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color 180ms ease, color 180ms ease;
}

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

button,
select {
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.sidebar-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 921px) {
  .sidebar-overlay {
    display: none !important;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.toggle-sidebar-btn {
  display: inline-flex;
  color: var(--muted);
}

@media (min-width: 921px) {
  .toggle-sidebar-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    opacity: 0.75;
  }

  .toggle-sidebar-btn:hover {
    opacity: 1;
  }
}

.public-header-brand {
  display: none;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.public-header-brand img {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: cover;
  border-radius: 9px;
  box-shadow: var(--soft-shadow);
}

.public-header-brand strong {
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0;
}

body.is-public .public-header-brand {
  display: inline-flex;
}

body.is-public .toggle-sidebar-btn {
  display: none;
}

.chat-app {
  height: 100vh;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.chat-app.is-sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.chat-app.is-sidebar-collapsed .sidebar {
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  pointer-events: none;
}

body.is-public .chat-app {
  height: auto;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr);
}

html.is-public .chat-main,
body.is-public .chat-main {
  height: auto;
  min-height: 100vh;
  grid-column: 1 / -1;
  grid-template-rows: auto auto auto;
  overflow: visible;
}

body.is-public .chat-header .header-right {
  margin-left: auto;
  flex-wrap: wrap;
  row-gap: 8px;
}

html.is-public .chat-header .header-right {
  margin-left: auto;
}

body.is-public .sidebar {
  display: none;
  box-shadow: none;
}

.sidebar {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sidebar);
  padding: 14px 12px 8px;
  transition: padding 180ms ease, background-color 180ms ease;
  box-shadow: 14px 0 42px rgba(0, 0, 0, 0.08);
}

.brand {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.brand strong {
  font-size: 17px;
}

.new-chat-button,
.history-item,
.text-button,
.starter-button,
.send-button {
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.new-chat-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  font-weight: 700;
  text-align: left;
}

.new-chat-button:hover,
.history-item:hover,
.starter-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 8px 0 -8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-list {
  display: grid;
  align-content: start;
  flex: 1 1 auto;
  gap: 8px;
  grid-auto-rows: max-content;
  overflow: auto;
  min-height: 0;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.history-item-wrap {
  position: relative;
  display: grid;
  align-items: center;
}

.history-item {
  grid-area: 1 / 1;
  width: 100%;
  min-height: 68px;
  padding: 10px 38px 10px 10px;
  text-align: left;
}

.history-item strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-item span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-delete-btn {
  grid-area: 1 / 1;
  justify-self: end;
  align-self: center;
  position: relative;
  right: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--muted);
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, background-color 140ms ease, color 140ms ease;
}

.history-item-wrap:hover .history-delete-btn,
.history-delete-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.history-delete-btn:hover {
  background: var(--error-bg);
  color: var(--danger);
}

.promo-card {
  display: grid;
  gap: 8px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: none;
  padding: 10px;
}

.promo-section {
  display: grid;
  gap: 6px;
}

.promo-section + .promo-section {
  padding-top: 9px;
  box-shadow: inset 0 1px 0 rgba(177, 93, 28, 0.16);
}

.promo-label,
.promo-copy {
  margin: 0;
}

.promo-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.promo-copy {
  color: color-mix(in srgb, var(--muted) 88%, #b15d1c 12%);
  font-size: 12px;
  line-height: 1.45;
}

.promo-button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(177, 93, 28, 0.18);
  color: #d27a2c;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.promo-button:hover {
  background: rgba(177, 93, 28, 0.25);
}

.promo-button.secondary {
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: none;
}

.promo-button.secondary:hover {
  background: var(--surface-hover);
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar-footnote {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 4px 0;
  box-shadow: inset 0 1px 0 var(--line);
}

.sidebar-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--user-bubble);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-user-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name-text {
  max-width: 170px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-action-btn {
  width: 100%;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  transition: background-color 150ms ease, color 150ms ease;
}

.sidebar-action-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.sidebar-action-btn.danger {
  color: var(--danger);
}

.sidebar-action-btn.danger:hover {
  background: var(--error-bg);
  color: var(--danger);
}

.chat-main {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  overflow: hidden;
}

.chat-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 22px;
  background: var(--bg);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.04);
}

.chat-header .header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: min(100%, 560px);
}

.rewards-dropdown {
  position: relative;
}

.rewards-trigger {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  background: rgba(177, 93, 28, 0.14);
  color: #d27a2c;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  box-shadow: none;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.rewards-trigger:hover,
.rewards-dropdown.is-open .rewards-trigger {
  background: rgba(177, 93, 28, 0.22);
  color: #e08a3a;
}

.rewards-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 250px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 26;
}

.rewards-dropdown.is-open .rewards-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.credit-pill {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.credit-pill[hidden] {
  display: none;
}

.auth-only[hidden],
.composer-area[hidden],
.user-menu[hidden],
.header-login-btn[hidden] {
  display: none !important;
}

.credit-pill-balance {
  height: 32px;
  min-width: 52px;
  max-width: 86px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: none;
  padding: 0 10px;
}

.credit-pill-value {
  overflow: hidden;
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
}

.credit-pill-unit {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.header-login-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(82, 106, 239, 0.18);
  transition: background-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.header-login-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.header-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(82, 106, 239, 0.18), rgba(82, 106, 239, 0.06)), var(--surface-soft);
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 850;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 190px;
  display: grid;
  gap: 4px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 24;
}

.user-menu.is-open .user-menu-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.user-menu-name {
  overflow: hidden;
  padding: 8px 9px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--line);
}

.user-menu-item {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
}

.user-menu-item:hover {
  background: var(--surface-hover);
}

.user-menu-item.danger {
  color: var(--danger);
}

.language-dropdown {
  position: relative;
}

.language-trigger {
  min-width: 58px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px 0 12px;
  box-shadow: none;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.language-trigger:hover,
.language-dropdown.is-open .language-trigger {
  background: var(--surface-hover);
  color: var(--ink);
}

.language-trigger svg {
  transition: transform 160ms ease;
}

.language-dropdown.is-open .language-trigger svg {
  transform: rotate(180deg);
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 126px;
  display: grid;
  gap: 4px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 20;
}

.language-dropdown.is-open .language-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.language-option {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  padding: 0 10px;
  text-align: left;
}

.language-option:hover,
.language-option.is-active {
  background: var(--surface-hover);
  color: var(--ink);
}

.language-check {
  opacity: 0;
  color: var(--accent-light);
}

.language-option.is-active .language-check {
  opacity: 1;
}

.conversation {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 28px 22px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.is-public .conversation {
  width: min(1120px, 100%);
  padding: 18px 24px 34px;
  overflow: visible;
}

.welcome-panel {
  min-height: min(360px, 48vh);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.welcome-icon-frame {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface-soft);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.welcome-icon-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.welcome-panel h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(25px, 5vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.welcome-eyebrow,
.welcome-subtitle,
.welcome-cta {
  margin: 0;
}

.welcome-eyebrow {
  color: var(--accent-light);
  font-size: 13px;
  font-weight: 850;
}

.welcome-subtitle {
  width: min(540px, 100%);
  color: var(--muted);
  font-size: clamp(14px, 1.8vw, 16px);
  line-height: 1.5;
}

.welcome-feature-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.welcome-feature-row span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 750;
}

.welcome-cta {
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.45;
}

.starter-grid {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.starter-button {
  min-height: 46px;
  padding: 10px 13px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
}

.public-home {
  display: grid;
  gap: 24px;
}

.public-hero {
  min-height: min(410px, calc(100vh - 210px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  align-items: center;
  gap: 24px;
}

.public-hero-copy {
  display: grid;
  justify-items: start;
  gap: 12px;
}

.public-hero-copy h1 {
  max-width: 720px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 850;
  line-height: 1.04;
}

.public-hero-copy p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.6;
}

.public-start-btn {
  height: 42px;
  margin-top: 4px;
  padding: 0 18px;
}

.public-rule-panel {
  display: grid;
  gap: 14px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--soft-shadow);
  padding: 20px;
}

.public-rule-panel h2,
.public-section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
}

.public-rule-panel ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.public-rule-panel li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.public-rule-panel li::before {
  content: "";
  position: absolute;
  top: 0.68em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent-light);
}

.public-showcase {
  display: grid;
  gap: 14px;
}

.public-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.public-scene-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.public-scene-card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--soft-shadow);
}

.public-scene-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  background: var(--surface-soft);
}

.public-scene-card div {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.public-scene-card h3,
.public-scene-card p {
  margin: 0;
}

.public-scene-card h3 {
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.public-scene-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.public-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 2px;
  color: var(--muted);
  font-size: 13px;
}

.public-link-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 0 11px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.public-link-button:hover {
  background: var(--surface-hover);
}

.message {
  display: flex;
  margin: 0 0 22px;
}

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

.message.is-assistant {
  justify-content: flex-start;
}

.error-box {
  color: var(--danger);
  font-size: 14px;
  padding: 12px;
  border: 0;
  background: var(--error-bg);
  box-shadow: inset 0 0 0 1px var(--error-border);
  border-radius: 10px;
  line-height: 1.5;
}

.message-content {
  max-width: min(720px, 88%);
  min-width: 0;
}

.message.is-user .message-content {
  max-width: min(640px, 78%);
}

.message.is-assistant .message-content {
  max-width: min(760px, 92%);
}

.message-text {
  margin: 0;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: var(--user-bubble);
  color: var(--ink);
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: var(--soft-shadow);
}

.message.is-assistant .typing,
.message.is-assistant .error-box {
  border-bottom-left-radius: 6px;
  box-shadow: var(--soft-shadow);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.image-card {
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.image-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  background: var(--surface-soft);
}

.image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: inset 0 1px 0 var(--line);
  padding: 10px;
}

.image-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.image-action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.image-icon-link {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.image-icon-link:hover {
  background: var(--accent);
  color: var(--accent-contrast);
  transform: translateY(-1px);
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 42px;
  border-radius: 18px;
  background: var(--surface);
  padding: 0 14px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 900ms ease-in-out infinite;
}

.typing span:nth-child(2) {
  animation-delay: 120ms;
}

.typing span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer-area {
  background: var(--bg);
  padding: 12px 22px 18px;
}

.composer {
  position: relative;
  width: min(900px, 100%);
  margin: 0 auto;
  border: 0;
  border-radius: 20px;
  background: var(--input-bg);
  box-shadow: var(--soft-shadow);
  padding: 10px;
}

.composer textarea {
  width: 100%;
  min-height: 50px;
  max-height: 180px;
  border: 0;
  outline: none;
  padding: 8px 8px 10px;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}

.composer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  transition: all 150ms ease;
}

.control-btn:hover {
  background-color: var(--surface-hover);
  color: var(--ink);
}

.control-btn.icon-only {
  width: 38px;
  padding: 0;
  justify-content: center;
}

.control-btn svg {
  flex-shrink: 0;
}

.controls-left .control-btn {
  border: none;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
}

.controls-left .control-btn.icon-only {
  width: 32px;
  padding: 0;
}

.send-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 150ms ease;
  flex-shrink: 0;
}

.send-button:hover {
  opacity: 0.9;
}

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

/* Settings Popover */
.settings-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 10px;
  width: 320px;
  background: var(--surface);
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.settings-popover.is-visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.settings-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  box-shadow: inset 0 -1px 0 var(--line);
}

.settings-popover-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  color: var(--ink);
}

.settings-popover-header .close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.settings-popover-header .close-btn:hover {
  color: var(--ink);
}

.settings-popover-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 360px;
  overflow: visible;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-group.is-hidden {
  display: none;
}

.settings-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.settings-group select,
.settings-group input {
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--ink);
  outline: none;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  width: 100%;
  text-align: left;
  text-align-last: left;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.settings-group select {
  appearance: none;
  background-image: var(--select-arrow);
  background-position: right 12px center;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.settings-group select:focus,
.settings-group input:focus {
  background-color: var(--surface-elevated);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.settings-select {
  position: relative;
}

.settings-select-trigger {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-hover);
  color: var(--ink);
  outline: none;
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.settings-select-trigger:hover,
.settings-select.is-open .settings-select-trigger {
  background: var(--surface-elevated);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.settings-select-trigger svg {
  color: var(--subtle);
  transition: transform 150ms ease;
  flex-shrink: 0;
}

.settings-select.is-open .settings-select-trigger svg {
  transform: rotate(180deg);
}

.settings-select-value,
.settings-select-option-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
}

.settings-select-credit {
  color: var(--accent);
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 850;
}

.settings-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 140;
  display: none;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.settings-select.is-open .settings-select-menu {
  display: grid;
  gap: 2px;
}

.settings-select-option {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 0 9px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.settings-select-option:hover,
.settings-select-option.is-selected {
  background: var(--surface-hover);
}

.settings-select-check {
  opacity: 0;
  color: var(--accent);
  flex-shrink: 0;
}

.settings-select-option.is-selected .settings-select-check {
  opacity: 1;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  max-width: min(420px, calc(100% - 36px));
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 2400;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-success {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.06)), var(--surface);
}

.toast.is-warning {
  border-color: rgba(245, 158, 11, 0.38);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.06)), var(--surface);
}

.toast.is-error {
  border-color: var(--error-border);
  background: var(--error-bg);
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.confirm-dialog[open] {
  animation: dialog-show 220ms cubic-bezier(0.2, 0, 0, 1);
}

.confirm-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.confirm-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.confirm-credit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.confirm-credit-item {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.confirm-credit-item.is-cost {
  background: linear-gradient(135deg, rgba(82, 106, 239, 0.26), rgba(82, 106, 239, 0.07)), var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(82, 106, 239, 0.28);
}

.confirm-credit-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.confirm-credit-item strong {
  color: var(--ink);
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.confirm-credit-item span:last-child {
  margin-top: 4px;
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 800;
}

.confirm-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.confirm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

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

.confirm-actions .submit-btn {
  width: auto;
  min-width: 112px;
  margin: 0;
  padding: 0 18px;
}

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

  body.is-public .chat-app {
    grid-template-columns: 1fr;
  }

  body.is-public .sidebar {
    display: none;
    transform: translateX(-100%);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
    min-height: 100vh;
  }

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

  .toggle-sidebar-btn {
    display: inline-flex;
  }

  body.is-public .toggle-sidebar-btn {
    display: none;
  }

  .public-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .public-scene-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .chat-header {
    padding: 10px 12px;
  }

  .chat-header .header-right {
    gap: 6px;
  }

  .credit-pill {
    height: 32px;
  }

  .credit-pill-balance {
    min-width: 42px;
    padding: 0 5px;
  }

  .credit-pill-unit {
    display: none;
  }

  .rewards-trigger {
    width: 34px;
    height: 32px;
    padding: 0;
  }

  .rewards-trigger span {
    display: none;
  }

  .rewards-menu {
    left: auto;
    right: 0;
    width: min(250px, calc(100vw - 24px));
    transform-origin: top right;
  }

  .language-trigger {
    min-width: 62px;
    height: 32px;
    padding: 0 9px 0 11px;
  }

  .language-menu {
    width: 120px;
  }

  .conversation {
    padding: 32px 14px 18px;
  }

  body.is-public .conversation {
    padding: 22px 14px 28px;
  }

  .welcome-panel {
    min-height: 240px;
  }

  .public-hero-copy h1 {
    font-size: clamp(31px, 11vw, 42px);
  }

  .public-rule-panel {
    padding: 16px;
  }

  .starter-grid {
    grid-template-columns: 1fr;
  }

  .message-content,
  .message.is-user .message-content,
  .message.is-assistant .message-content {
    max-width: 92%;
  }

  .composer-area {
    padding: 10px;
  }

  .settings-popover {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    border: 0;
    transform: translateY(100%);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    transition: transform 200ms ease;
  }

  .settings-popover.is-visible {
    transform: translateY(0);
  }

  .confirm-credit-summary {
    grid-template-columns: 1fr;
  }
}

/* Login Dialog & Card Styles */
:root {
  --md-sys-color-primary: var(--accent);
  --md-sys-color-primary-hover: var(--accent-light);
  --md-sys-color-primary-active: var(--accent-dark);
  --md-sys-color-on-primary: var(--accent-contrast);
  --md-sys-color-outline: var(--line-strong);
  --md-sys-color-outline-variant: var(--line);
  --md-sys-color-surface: var(--surface);
  --md-sys-color-on-surface: var(--ink);
  --md-sys-color-on-surface-variant: var(--muted);
}

.login-dialog,
.password-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: min(440px, calc(100% - 32px));
  width: 100%;
  overflow: visible;
}

.login-dialog::backdrop,
.password-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.login-dialog[open],
.password-dialog[open] {
  animation: dialog-show 250ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes dialog-show {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-card {
  position: relative;
  background: var(--surface);
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-family: 'Outfit', Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.login-close-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-right: 32px;
  text-align: left;
}

.login-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--md-sys-color-on-surface);
  line-height: 1.25;
}

.login-header p {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

.auth-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-view[hidden] {
  display: none;
}

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oauth-btn {
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: var(--surface-soft);
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color 0.15s, box-shadow 0.15s;
}

.oauth-btn:hover {
  background-color: var(--surface-hover);
}

.oauth-btn:active {
  background-color: var(--surface-soft);
}

.google-btn svg {
  margin-right: 2px;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 400;
  margin: 4px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.login-divider:not(:empty)::before {
  margin-right: 12px;
}

.login-divider:not(:empty)::after {
  margin-left: 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.md-textfield {
  position: relative;
  width: 100%;
}

.md-textfield input {
  width: 100%;
  height: 56px;
  padding: 16px;
  padding-right: 48px;
  font-size: 16px;
  border: 0;
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--md-sys-color-on-surface);
  caret-color: var(--accent);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.15s;
}

.md-textfield label {
  position: absolute;
  left: 14px;
  top: 18px;
  background: var(--surface);
  padding: 0 6px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  transition: 0.15s ease all;
  font-size: 16px;
  line-height: 1;
}

/* Floating label focus states */
.md-textfield input:focus ~ label,
.md-textfield input:not(:placeholder-shown) ~ label {
  top: -6px;
  font-size: 12px;
  color: var(--md-sys-color-primary);
  font-weight: 500;
}

.md-textfield input:focus {
  box-shadow: 0 0 0 3px var(--focus-ring);
  padding: 15px;
  padding-right: 47px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.15s, color 0.15s;
}

.password-toggle:hover {
  background-color: var(--surface-hover);
  color: var(--md-sys-color-on-surface);
}

.password-toggle:active {
  background-color: var(--surface-soft);
}

.privacy-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.privacy-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--md-sys-color-primary);
  flex: 0 0 auto;
}

.privacy-row.has-error {
  color: var(--danger);
}

.privacy-row.has-error input {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.privacy-error {
  margin: -10px 0 0 26px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.privacy-link {
  border: none;
  background: transparent;
  color: var(--md-sys-color-primary);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0;
}

.privacy-link:hover,
.privacy-link:focus-visible {
  text-decoration: underline;
}

.submit-btn {
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.submit-btn:hover {
  background-color: var(--md-sys-color-primary-hover);
  box-shadow: 0 10px 22px rgba(82, 106, 239, 0.22);
}

.submit-btn:active {
  background-color: var(--md-sys-color-primary-active);
  box-shadow: none;
}

.submit-btn:disabled {
  background-color: var(--surface-hover);
  color: var(--subtle);
  cursor: not-allowed;
  box-shadow: none;
}

.login-footer {
  text-align: center;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

.login-footer .text-link {
  background: transparent;
  border: none;
  color: var(--md-sys-color-primary);
  font-weight: 500;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 2px;
}

.login-footer .text-link:hover {
  text-decoration: underline;
}

.privacy-dialog {
  border: none;
  background: transparent;
  padding: 0;
  width: min(520px, calc(100% - 32px));
  max-width: 100%;
}

.privacy-dialog::backdrop {
  background: rgba(15, 20, 25, 0.44);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.privacy-card {
  background: var(--surface);
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow);
  color: var(--md-sys-color-on-surface);
  display: flex;
  flex-direction: column;
  max-height: min(680px, calc(100vh - 48px));
  padding: 22px;
}

.privacy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.privacy-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.privacy-body {
  overflow: auto;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  line-height: 1.65;
  padding-right: 4px;
}

.privacy-body p {
  margin: 0 0 12px;
}

.privacy-accept-btn {
  margin-top: 12px;
}
