* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --vh: 1vh;
  --chrome: #1e293b;
  --chat-bg: #f1f5f9de;
}
html {
  overscroll-behavior: none;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--chrome);
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

/* Allow text selection in input areas */
input,
textarea,
.message {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.container {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
  background: white;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* Portrait narrow screens */
@media (max-width: 800px) {
  .container {
    box-shadow: none;
  }
}

.login-section {
  width: 100%;
  display: none;
  height: 100vh;
  position: absolute;
  top: 0;
  bottom: 0;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #334155 0%, var(--chrome) 100%);
}

.login-alert-graphic {
  max-height: 80px;
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.login-card h1 {
  color: var(--chrome);
  margin-bottom: 16px;
  font-size: 28px;
}

.login-card p {
  color: #666;
  margin-bottom: 32px;
  line-height: 1.5;
}

.login-button {
  background: var(--chrome);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
}

.login-button:hover {
  background: #334155;
}

.midway-button {
  background: var(--chrome);
}

.midway-button:hover {
  background: #334155;
}

.login-divider {
  color: #888;
  font-size: 14px;
  margin: 12px 0;
  text-align: center;
}

.login-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.login-spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
  border-color: rgba(30, 41, 59, 0.3);
  border-top-color: var(--chrome);
}

.callback-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}

.callback-spinner p {
  color: #666;
  margin: 0;
}

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

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

.chat-section.visible {
  display: flex;
}

/* Model sidebar — in portrait mode, sits below header as a horizontal bar */
.model-sidebar {
  background: var(--chrome);
  padding: 0 9px 9px 9px;
  flex-shrink: 0;
}

header {
  padding: 10px 16px;
  background: var(--chrome);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  min-height: auto;
}

.header-image {
  height: 45px;
}

.account-section {
  position: absolute;
  top: 12px;
  right: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.account-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.account-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

/* Backdrop for mobile */
.account-dropdown::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: transparent;
  display: none;
}

@media (max-width: 768px) {
  .account-dropdown.show::before {
    display: block;
  }
}

.account-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.account-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.user-info {
  font-size: 14px;
  color: var(--chrome);
  font-weight: 500;
  word-break: break-word;
}

.account-dropdown-divider {
  height: 1px;
  background: #eee;
  margin: 0;
}

.logout-button {
  background: none;
  color: #555;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
  text-align: left;
  border-radius: 0 0 8px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-button:hover {
  background: #f8f9fa;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  flex-shrink: 0;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  color: white;
}

.selector-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 160px;
}

.selector-group:first-child {
  flex: 0.8;
}

.selector-group label {
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  margin-bottom: 3px;
}

#directModelSelect,
#inferenceProfileSelect,
#regionSelect {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: white;
  color: var(--chrome);
  font-size: 13px;
  width: 100%;
  min-width: 0;
}

.title-bar {
  height: 45px;
}

/* Mobile header adjustments */
@media (max-width: 768px) {
  header {
    padding: 9px;
    position: relative;
  }

  .header-image {
    height: 35px;
  }

  h1 {
    font-size: 22px;
    order: 1;
    padding: 4px 3px;
  }
  .title-bar {
    height: 35px;
  }

  .account-section {
    order: 2;
    position: absolute;
    top: 9px;
    right: 9px;
  }

  .account-dropdown {
    right: -8px;
    min-width: 180px;
  }

  .model-sidebar {
    padding: 0 9px 9px 9px;
  }

  .model-selector {
    width: 100%;
    gap: 8px;
  }

  .selector-group {
    min-width: 0;
  }

  #directModelSelect,
  #inferenceProfileSelect,
  #regionSelect {
    font-size: 14px;
    padding: 8px 12px;
  }
}

/* Desktop layout — sidebar for model selectors */
@media (min-width: 769px) {
  .chat-section.visible {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "header  header"
      "sidebar chat"
      "sidebar input";
    overflow: hidden;
  }

  header {
    grid-area: header;
    padding: 8px 16px;
  }

  .header-image {
    height: 40px;
    margin: 5px 0;
  }

  .title-bar {
    height: 50px;
  }

  .account-section {
    top: 12px;
    right: 12px;
  }

  .account-button {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .model-sidebar {
    grid-area: sidebar;
    padding: 16px 12px;
    overflow-y: hidden;
    background: var(--chrome);
  }

  .model-sidebar .model-selector {
    color: #cbd5e1;
  }

  .model-sidebar .selector-group label {
    color: #94a3b8;
    font-size: 10px;
  }

  .model-sidebar #directModelSelect,
  .model-sidebar #inferenceProfileSelect,
  .model-sidebar #regionSelect {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    font-size: 13px;
    padding: 6px 8px;
  }

  .model-selector {
    flex-direction: column;
    gap: 12px;
  }

  .selector-group {
    min-width: 0;
    width: 100%;
    flex: none;
  }

  .selector-group:first-child {
    flex: none;
  }

  .chat-container {
    grid-area: chat;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .chat-messages {
    border-radius: 12px 0 0 12px;
  }

  .input-container {
    grid-area: input;
    align-self: end;
    width: 100%;
    background: var(--chrome);
  }
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
  background: var(--chrome);
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background: var(--chat-bg);
}

/* Mobile chat messages adjustments */
@media (max-width: 768px) {
  .chat-messages {
    padding: 12px;
    gap: 10px;
  }
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.4;
  word-wrap: break-word;
  font-size: 14px;
  position: relative;
}

.message.user {
  align-self: flex-end;
  background: #334155;
  color: white;
  border-bottom-right-radius: 6px;
}

.reload-prompt-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 30px;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: all 0.2s ease;
  z-index: 1;
  touch-action: manipulation;
  padding-bottom: 8px;
  padding-right: 3px;
  padding-top: 3px;
  padding-left: 3px;
}

.message.user:hover .reload-prompt-btn,
.message.user:focus-within .reload-prompt-btn {
  opacity: 1;
}

.reload-prompt-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.reload-prompt-btn:active {
  transform: scale(0.95);
}

.message.assistant {
  align-self: flex-start;
  background: #334156;
  color: #ffffff;
  border-bottom-left-radius: 6px;
}

.message.loading {
  align-self: flex-start;
  background: #334156;
  color: #cccccc;
  font-style: italic;
  border-bottom-left-radius: 6px;
}

.history-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--chat-bg, #f1f5f9de);
  transition: opacity 0.3s ease;
}

.history-loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.history-loading-overlay .login-spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
  border-color: rgba(30, 41, 59, 0.2);
  border-top-color: var(--chrome, #1e293b);
}

.history-loading-overlay span {
  color: #475569;
  font-size: 14px;
  font-weight: 500;
}

.model-name {
  font-size: 11px;
  color: #c8c8c8;
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-label {
  color: #c6c6c6;
  margin-right: 25px;
}

.message-content-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.media-download-icon {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.media-download-icon svg {
  width: 100%;
  height: 100%;
}

.media-download-icon[data-pending="true"] {
  display: none;
}

.media-download-icon:hover {
  color: #fff;
}

.message-content {
  word-break: break-word;
  margin-right: 20px;
}

/* Markdown content in assistant messages */
.markdown-content p {
  margin: 0 0 0.5em 0;
}
.markdown-content p:last-child {
  margin-bottom: 0;
}
.markdown-content ul,
.markdown-content ol {
  margin: 0.3em 0;
  padding-left: 1.5em;
}
.markdown-content li {
  margin: 0.15em 0;
}
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 0.6em 0 0.3em 0;
  line-height: 1.3;
}
.markdown-content h1 {
  font-size: 1.3em;
}
.markdown-content h2 {
  font-size: 1.15em;
}
.markdown-content h3 {
  font-size: 1.05em;
}
.markdown-content code {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: "Courier New", Courier, monospace;
}
.markdown-content pre {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.markdown-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}
.markdown-content blockquote {
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  margin: 0.5em 0;
  padding: 0.25em 0.75em;
  opacity: 0.85;
}
.markdown-content table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.9em;
}
.markdown-content th,
.markdown-content td {
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.35em 0.6em;
}
.markdown-content th {
  background: rgba(0, 0, 0, 0.15);
}
.markdown-content a {
  color: #8ab4f8;
  text-decoration: underline;
}

/* Mobile message adjustments */
@media (max-width: 768px) {
  .message {
    max-width: 85%;
    padding: 10px 14px;
    font-size: 15px;
    border-radius: 16px;
  }
  .message.user {
    border-bottom-right-radius: 4px;
  }

  .message.assistant,
  .message.loading {
    border-bottom-left-radius: 4px;
  }

  .model-name {
    font-size: 10px;
    margin-bottom: 5px;
  }

  .reload-prompt-btn {
    opacity: 0.7;
    width: 26px;
    height: 26px;
    top: 4px;
    right: 4px;
  }

  .reload-prompt-btn:active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.4);
  }
}

.input-container {
  padding: 12px;
  display: flex;
  gap: 12px;
  background: var(--chrome);
  flex-shrink: 0;
  align-items: center;
}

.image-upload-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.history-button-container {
  position: relative;
  display: inline-block;
}

.image-button,
.history-button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 20%;
  width: 55px;
  height: 55px;
  cursor: pointer;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  touch-action: manipulation;
}

.button-icon {
  width: 35px;
}
.history-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.image-button:hover,
.history-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-button:active,
.history-button:active {
  transform: scale(0.95);
}

.history-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.history-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  margin-bottom: 5px;
}

.history-tooltip.show {
  opacity: 1;
}

.history-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.8);
}

.image-preview {
  max-width: 55px;
  max-height: 55px;
  position: relative;
}

.image-preview img {
  max-height: 55px;
  max-width: 55px;
  border-radius: 4px;
  border: 1px solid #595656;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.image-preview .remove-image {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

/* Mobile input container adjustments */
@media (max-width: 768px) {
  .input-container {
    padding: 7px;
    gap: 7px;
  }

  .image-button,
  .history-button {
    width: 50px;
    height: 50px;
  }

  .image-preview {
    max-width: 60px;
    max-height: 60px;
  }
}

.message.user .image-content,
.message.assistant .image-content {
  margin-bottom: 8px;
}

.message.user .image-content img,
.message.assistant .image-content img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
}

#messageInput {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  min-height: 55px;
  max-height: 120px;
  line-height: 1.4;
  background: var(--chat-bg);
  border: none;
  color: #1e293b;
}

#messageInput:focus {
  border-color: #475569;
}

#sendButton {
  touch-action: manipulation;
  flex-shrink: 0;
  font-size: 18px;
}

#sendButton:hover:not(:disabled) {
  color: rgba(255, 255, 255, 0.3);
}

#sendButton:active:not(:disabled) {
  transform: scale(0.95);
}

#sendButton:disabled {
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
}

/* Mobile input adjustments */
@media (max-width: 768px) {
  .selector-group label {
    font-size: 7px;
  }

  #messageInput {
    font-size: 16px;
    padding: 6px;
    border-radius: 7px;
  }

  #sendButton {
    padding: 14px;
    border-radius: 16px;
  }
}

/* Toast error notification */
.toast-error {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(60, 60, 60, 0.95);
  color: #f0f0f0;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 90vw;
  text-align: center;
  z-index: 20000;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.toast-error.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Additional mobile-specific styles */
@media (max-width: 480px) {
  .login-card {
    margin: 16px;
    padding: 24px 16px;
  }

  .login-card h1 {
    font-size: 24px;
  }

  .login-button {
    padding: 14px 24px;
    font-size: 16px;
  }
}

/* Landscape mobile adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 6px 16px;
  }

  .model-selector {
    gap: 8px;
  }

  .selector-group label {
    font-size: 10px;
  }

  #directModelSelect,
  #inferenceProfileSelect {
    padding: 6px 10px;
    font-size: 12px;
  }

  .chat-messages {
    padding: 8px 12px;
  }

  .input-container {
    padding: 7px;
    gap: 10px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .image-preview img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Media modal overlay */
.media-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: pointer;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.media-modal-overlay img,
.media-modal-overlay video {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
}

.media-modal-close {
  position: absolute;
  top: 16px;
  right: 24px;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  opacity: 0.8;
  z-index: 10001;
}

.media-modal-close:hover {
  opacity: 1;
}

/* Make chat images/videos clickable */
.image-content img,
.video-content video,
.generated-image img {
  cursor: pointer;
}

/* Image source popup menu — matches account dropdown style */
.image-source-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.image-source-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.image-source-menu button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: #555;
  transition: background 0.2s;
}

.image-source-menu button:hover {
  background: #f8f9fa;
}

.image-source-menu button:last-child {
  border-radius: 0 0 8px 8px;
}

.image-source-menu button:first-child {
  border-radius: 8px 8px 0 0;
}

.image-source-menu button + button {
  border-top: 1px solid #eee;
}

/* Camera modal */
.camera-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: modalFadeIn 0.2s ease;
}

.camera-modal-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 95vw;
}

.camera-preview {
  max-width: 90vw;
  max-height: 70vh;
  border-radius: 8px;
  background: #000;
}

.camera-btn-row {
  display: flex;
  gap: 16px;
}

.camera-capture-btn,
.camera-cancel-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.camera-capture-btn {
  background: #475569;
  color: #fff;
}

.camera-capture-btn:hover {
  background: #334155;
}

.camera-cancel-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.camera-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Download buttons for media */
.media-download-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #4fc3f7;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.media-download-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.media-modal-download {
  position: absolute;
  bottom: 16px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 10001;
}

.media-modal-download:hover {
  color: #fff;
}

.media-modal-download svg {
  width: 36px;
  height: 36px;
}

/* Message metrics (cost, tokens, latency) */
.message-metrics {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.3px;
}

/* Pricing source link in metrics */
.pricing-source-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.pricing-source-link:hover {
  color: #fff;
  text-decoration-style: solid;
}

/* Header username — hidden on mobile, shown on desktop */
.header-username {
  color: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  font-weight: 600;
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

@media (min-width: 769px) {
  .header-username {
    display: inline;
  }
}

/* Sidebar section labels — only visible on desktop */
.sidebar-section-label {
  display: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 4px;
}

@media (min-width: 769px) {
  .sidebar-section-label {
    display: block;
  }
}

/* Sidebar help block — only visible on desktop */
.sidebar-help {
  display: none;
  color: #d6dfec;
  font-size: 12px;
  line-height: 1.5;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid #334155;
}

.sidebar-help .help-title {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}

.sidebar-help p {
  margin: 0 0 6px 0;
}

.sidebar-help p:last-child {
  margin-bottom: 0;
}

@media (min-width: 769px) {
  .sidebar-help {
    display: block;
  }
}

/* Help button — visible on mobile only (desktop has sidebar help) */
.help-button {
  display: flex;
}

@media (min-width: 769px) {
  .help-button {
    display: none;
  }
}

/* Help popup — portrait mode popup triggered by help icon */
.help-popup {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 240px;
  max-width: 300px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.help-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.help-popup .help-content {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #555;
}

.help-popup .help-title {
  font-weight: 600;
  color: var(--chrome);
  font-size: 14px;
  margin-bottom: 8px;
}

.help-popup .help-content p {
  margin: 0 0 6px 0;
}

.help-popup .help-content p:last-child {
  margin-bottom: 0;
}

/* Sidebar "then chat!" arrow — desktop only */
.sidebar-chat-arrow {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  padding: 12px 0 8px 0;
}

.sidebar-chat-arrow-label {
  color: #94a3b8;
  font-size: 22px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 1px;
}

.sidebar-chat-arrow-svg {
  width: 165px;
  height: auto;
  margin-bottom: -25px;
}

@media (min-width: 769px) {
  .sidebar-chat-arrow {
    display: flex;
  }

  .model-sidebar {
    display: flex;
    flex-direction: column;
  }
}

/* Language selector in account dropdown */
.language-selector {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.language-label {
  font-size: 13px;
  color: #555;
}

.language-select {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: white;
  color: #333;
  cursor: pointer;
}

/* Language dropdown in header */
.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 140px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  overflow: hidden;
}

.lang-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: block;
  width: 100%;
  padding: 3px 16px;
  border: none;
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: #555;
  transition: background 0.2s;
}

.lang-option:hover {
  background: #f8f9fa;
}

.lang-option.active {
  color: var(--chrome);
  font-weight: 600;
}

.lang-option + .lang-option {
  border-top: 1px solid #eee;
}

.lang-group-label {
  padding: 8px 16px 4px;
  font-size: 13px;
  font-weight: 600;
  color: #999;
  border-top: 1px solid #eee;
}

.lang-group-label:first-child {
  border-top: none;
}

.lang-option.lang-sub {
  padding-left: 28px;
  font-size: 13px;
  border-top: 1px solid #eee;
}
