* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, Arial, sans-serif;
  background: #ffffff;
  color: #1d1d1b;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.screen {
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: #ffffff;
}

.auth-screen {
  align-items: center;
  justify-content: center;
}

.auth-view {
  width: min(100vw, 430px);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 22px;
  background: #ffffff;
}

.auth-card {
  width: 100%;
  border: 1px solid #eceff3;
  border-radius: 24px;
  padding: 32px 26px;
  box-shadow: 0 18px 55px rgba(17, 24, 39, 0.08);
}

.auth-brand {
  color: #1d1d1b;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

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

.login-form[hidden] {
  display: none;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #374151;
  font-size: 13px;
  font-weight: 650;
}

.auth-field input {
  width: 100%;
  height: 46px;
  border: 1px solid #d9dee7;
  border-radius: 12px;
  padding: 0 13px;
  color: #1d1d1b;
  background: #ffffff;
  outline: none;
}

.auth-field input:focus {
  border-color: #f5b731;
  box-shadow: 0 0 0 3px rgba(245, 183, 49, 0.16);
}

.remember-option {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #4b5563;
  font-size: 13px;
  cursor: pointer;
}

.remember-option input {
  width: 16px;
  height: 16px;
  accent-color: #d99b13;
}

.login-feedback {
  border-radius: 10px;
  padding: 10px 12px;
  background: #fef2f2;
  color: #b42318;
  font-size: 13px;
  line-height: 1.4;
}

.login-button {
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: #f5b731;
  color: #1d1d1b;
  font-weight: 750;
}

.login-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background: #ffffff;
}

.conversation-sidebar {
  width: 280px;
  flex: 0 0 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px 12px;
  border-right: 1px solid #e7e8ea;
  background: #f7f7f5;
  transition: width 180ms ease, flex-basis 180ms ease;
  overflow: hidden;
  z-index: 12;
}

.sidebar-brand {
  flex: 0 0 auto;
  padding: 8px 9px 10px;
  color: #1d1d1b;
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
}

.sidebar-icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  padding: 9px;
  background: transparent;
  color: #4b5563;
}

.sidebar-icon-button:hover:not(:disabled),
.sidebar-icon-button:focus-visible {
  background: #e9e9e5;
  color: #1d1d1b;
}

.sidebar-icon-button:focus-visible,
.conversation-item:focus-visible {
  outline: 2px solid #d99b13;
  outline-offset: 1px;
}

.sidebar-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sidebar-icon-button svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.8;
}

.conversation-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section-label {
  padding: 18px 10px 8px;
  color: #8a8f98;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c9cac5 transparent;
}

.conversation-item {
  width: 100%;
  min-height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  background: transparent;
  color: #3f4145;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item:hover:not(:disabled) {
  background: #edede9;
  color: #1d1d1b;
}

.conversation-item.active {
  background: #e5e5df;
  color: #1d1d1b;
  font-weight: 650;
}

.conversation-item:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.conversation-list-status {
  min-height: 24px;
  padding: 7px 10px 3px;
  color: #8a8f98;
  font-size: 11px;
  line-height: 1.35;
}

.conversation-list-status:empty {
  min-height: 0;
  padding: 0;
}

.sidebar-account {
  min-height: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid #dedfdc;
}

.sidebar-user {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 5px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f5b731;
  color: #1d1d1b;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.current-username {
  min-width: 0;
  overflow: hidden;
  color: #393b3f;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-backdrop {
  display: none;
}

.chat-frame {
  min-width: 0;
  height: 100dvh;
  flex: 1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-content {
  width: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-inline: auto;
}

.top-logo {
  height: 88px;
  flex: 0 0 88px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 20px 8px;
  gap: 12px;
}

.logo {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logout-button {
  color: #6b7280;
}

.mobile-sidebar-open {
  display: none;
}

.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-view.empty {
  justify-content: center;
}

.chat-frame.conversation-empty .chat-content {
  justify-content: center;
  gap: 28px;
  padding-bottom: min(9vh, 76px);
}

.chat-frame.conversation-empty .chat-view {
  flex: 0 0 auto;
  overflow: visible;
}

.chat-frame.conversation-empty .composer-wrap {
  width: min(100%, 960px);
  margin-inline: auto;
  padding-top: 0;
  border-top: 0;
  background: transparent;
}

.empty-body {
  width: min(100%, 960px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 0 32px 24px;
  margin-inline: auto;
  text-align: center;
}

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

.mark {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: #fef5e0;
  color: #f5b731;
  display: grid;
  place-items: center;
  padding: 0;
}

.mark svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.7;
  display: block;
  overflow: visible;
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome-copy h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.welcome-copy p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.45;
  max-width: 620px;
}

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 16px 18px;
}

.message-row {
  width: min(100%, 832px);
  display: flex;
  margin-inline: auto;
}

.message-row.right {
  justify-content: flex-end;
}

.bubble,
.processing {
  width: min(304px, calc(100vw - 48px));
  border-radius: 20px;
  font-size: 16px;
  line-height: 1.5;
}

.bubble p,
.processing p {
  margin: 0;
}

.user p {
  white-space: pre-wrap;
}

.model {
  width: 100%;
  max-width: none;
  border: 0;
  border-radius: 0;
  padding: 6px 0;
  background: transparent;
  color: #1d1d1b;
}

.model > :first-child,
.user > :first-child {
  margin-top: 0;
}

.model > :last-child,
.user > :last-child {
  margin-bottom: 0;
}

.model ul,
.model ol {
  margin: 10px 0;
  padding-left: 20px;
}

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

.model strong {
  font-weight: 700;
}

.user {
  width: fit-content;
  max-width: min(82%, 720px);
  background: #1d1d1b;
  color: #ffffff;
  padding: 12px 12px 14px;
}

.message-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.message-image {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(229, 231, 235, 0.35);
  cursor: pointer;
}

.message-image-fallback {
  width: 120px;
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9f9f9;
  color: #374151;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  text-decoration: none;
}

.message-image-fallback-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.message-image-fallback-name {
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.processing {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 12px 14px;
}

.stage-current {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-current strong {
  font-size: 13px;
  font-weight: 550;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #f5b73144;
  border-top-color: #f5b731;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.composer-wrap {
  width: min(100%, 960px);
  flex: 0 0 auto;
  background: #ffffffee;
  border-top: 1px solid #f3f4f6;
  padding: 12px 16px 20px;
  margin-inline: auto;
}

.composer {
  min-height: 56px;
  width: 100%;
  background: #f9f9f9;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 20px;
  height: 20px;
  color: #6b7280;
  flex: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.upload {
  cursor: pointer;
}

.composer-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.composer-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-feedback {
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
}

.composer-preview-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.composer-preview {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}

.composer-preview-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: #1d1d1b;
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

.message-input {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #1d1d1b;
  font-size: 17px;
  line-height: 1.4;
  min-height: 24px;
  max-height: 132px;
  padding: 0 0 2px;
  display: block;
}

.message-input::placeholder {
  color: #9ca3af;
}

.send {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 8px;
  flex: 0 0 36px;
  align-self: center;
}

.send svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.send .stop-icon {
  display: none;
  fill: currentColor;
  stroke: none;
}

.send.active {
  background: #f5b731;
  color: #1d1d1b;
}

.send.stop {
  background: #1d1d1b;
  color: #ffffff;
}

.send.stop:hover:not(:disabled) {
  background: #3f4145;
}

.send.stop:focus-visible {
  outline: 2px solid #d99b13;
  outline-offset: 2px;
}

.send.stop .send-icon {
  display: none;
}

.send.stop .stop-icon {
  display: block;
}

.send.stop:disabled {
  cursor: wait;
  opacity: 0.65;
}

.upload svg {
  width: 100%;
  height: 100%;
}

.send.disabled {
  background: #d1d5db;
  color: #ffffff;
  cursor: not-allowed;
}

.overlay {
  position: fixed;
  inset: 0;
  background: #00000066;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(100%, 620px);
  border-radius: 20px;
  background: #ffffff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 32px #00000033;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.modal-head button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  background: #f9f9f9;
  color: #6b7280;
  padding: 8px;
}

.modal-head button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.modal-image {
  width: 100%;
  max-height: min(70vh, 430px);
  border-radius: 16px;
  object-fit: cover;
  display: block;
}

.mobile-modal {
  width: min(100%, 354px);
}

.hidden {
  display: none;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 700px) {
  .screen {
    align-items: flex-start;
  }

  .app-shell.sidebar-collapsed .conversation-sidebar {
    width: 64px;
    flex-basis: 64px;
  }

  .app-shell.sidebar-collapsed .sidebar-actions {
    flex-direction: column;
  }

  .app-shell.sidebar-collapsed .sidebar-brand,
  .app-shell.sidebar-collapsed .conversation-history,
  .app-shell.sidebar-collapsed .current-username {
    display: none;
  }

  .app-shell.sidebar-collapsed .sidebar-account {
    flex-direction: column;
    border-top: 0;
    margin-top: auto;
  }

  .app-shell.sidebar-collapsed .sidebar-user {
    flex: 0 0 auto;
    padding-left: 0;
  }

  .app-shell.sidebar-collapsed .sidebar-toggle-arrow {
    transform: rotate(180deg);
    transform-origin: center;
  }

  .top-logo {
    width: min(100%, 960px);
    margin-inline: auto;
  }

  .conversation {
    gap: 20px;
    padding: 10px 64px 24px;
  }

  .bubble,
  .processing {
    font-size: 17px;
  }

  .processing {
    width: min(720px, 100%);
  }

  .model {
    width: 100%;
  }

  .user {
    padding: 14px 14px 16px;
  }

  .empty-body {
    padding: 0 64px;
    gap: 20px;
  }

  .composer-wrap {
    padding: 14px 64px 24px;
  }

  .mark {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    padding: 0;
  }

  .mark svg {
    width: 32px;
    height: 32px;
    stroke-width: 1.7;
    display: block;
    overflow: visible;
  }

  .welcome-copy p {
    font-size: 15px;
  }
}

@media (min-width: 900px) {
  .top-logo {
    height: 0;
    flex-basis: 0;
    padding: 0;
  }
}

@media (max-width: 899px) {
  .conversation-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    flex-basis: auto;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 10px 0 30px rgba(17, 24, 39, 0.14);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .app-shell.sidebar-mobile-open .conversation-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 11;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(17, 24, 39, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-sidebar-open {
    display: grid;
    margin-left: -8px;
  }

  .top-logo {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }

  .composer-wrap {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .model a,
  .model p,
  .model li,
  .model code {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
