:root {
  --background: #121922;
  --foreground: #f3f6fa;
  --muted: #a6afbb;
  --line: rgba(119, 135, 153, 0.34);
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --sidebar: #111820;
  --sidebar-hover: rgba(255, 255, 255, 0.065);
  --composer: #222a35;
  --accent: #90e4bd;
  --accent-strong: #a6efcc;
  --danger: #ff8b8b;
  --glass-shadow: none;
  --inner-glow: none;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--background);
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

body::before {
  background: none;
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

[hidden] {
  display: none !important;
}

.app-shell {
  background: #111922;
  border: 1px solid rgba(116, 132, 150, 0.38);
  border-radius: 10px;
  display: grid;
  flex: 1;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  padding: 0;
}

.sidebar {
  background: var(--sidebar);
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 9px 0 0 9px;
  box-shadow: none;
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 24px 28px;
  min-height: 0;
}

.brand {
  align-items: center;
  display: flex;
  gap: 16px;
}

.brand-mark,
.avatar {
  align-items: center;
  background: #f6f6f1;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  box-shadow: none;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  overflow: hidden;
  width: 44px;
}

.brand-mark img,
.avatar img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 15px;
  margin-top: 2px;
}

.new-chat-button {
  align-items: center;
  background: rgba(144, 228, 189, 0.035);
  border: 1px solid rgba(144, 228, 189, 0.72);
  border-radius: 8px;
  box-shadow: none;
  color: var(--accent);
  display: grid;
  font-size: 17px;
  gap: 12px;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 52px;
  padding: 14px 16px;
  text-align: left;
  touch-action: manipulation;
}

.new-chat-button:hover {
  background: rgba(144, 228, 189, 0.09);
  border-color: var(--accent-strong);
}

.new-chat-button:disabled {
  color: #8f8f8f;
  cursor: default;
  opacity: 0.68;
}

.new-chat-button:disabled:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line);
  transform: none;
}

.sidebar-label {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.06em;
  margin: 10px 0 -12px;
  text-transform: uppercase;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-tool,
.admin-nav button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 9px;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  min-height: 44px;
  padding: 10px 8px;
  text-align: left;
}

.sidebar-tool:hover,
.sidebar-tool.active,
.admin-nav button:hover,
.admin-nav button.active {
  background: var(--sidebar-hover);
  border-color: var(--line);
  color: var(--foreground);
}

.user-profile {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 9px;
  min-height: 38px;
  padding: 8px 10px;
}

.profile-dot {
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(77, 216, 181, 0.12);
  height: 18px;
  width: 18px;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.nav-icon {
  align-items: center;
  border: 1px solid rgba(144, 228, 189, 0.76);
  border-radius: 6px;
  color: var(--accent);
  display: inline-flex;
  height: 18px;
  justify-content: center;
  opacity: 0.9;
  position: relative;
  width: 18px;
}

.nav-icon::before,
.nav-icon::after,
.composer-icon::before,
.composer-icon::after,
.chat-icon::before,
.chat-icon::after {
  content: "";
  position: absolute;
}

.icon-plus::before {
  background: currentColor;
  height: 10px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
}

.icon-plus::after {
  background: currentColor;
  height: 1px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
}

.icon-image::before {
  border: 1px solid currentColor;
  border-radius: 2px;
  height: 10px;
  left: 3px;
  top: 3px;
  width: 10px;
}

.icon-image::after {
  border-bottom: 1px solid currentColor;
  border-left: 1px solid currentColor;
  height: 5px;
  left: 6px;
  top: 8px;
  transform: rotate(-45deg);
  width: 8px;
}

.icon-settings::before {
  border: 1px solid currentColor;
  border-radius: 999px;
  height: 8px;
  left: 4px;
  top: 4px;
  width: 8px;
}

.icon-settings::after {
  background: currentColor;
  box-shadow:
    0 -6px 0 currentColor,
    0 6px 0 currentColor,
    -6px 0 0 currentColor,
    6px 0 0 currentColor;
  height: 2px;
  left: 8px;
  top: 8px;
  width: 2px;
}

.icon-home::before {
  border-left: 1px solid currentColor;
  border-top: 1px solid currentColor;
  height: 8px;
  left: 4px;
  top: 5px;
  transform: rotate(45deg);
  width: 8px;
}

.icon-home::after {
  border: 1px solid currentColor;
  border-top: 0;
  height: 6px;
  left: 5px;
  top: 8px;
  width: 7px;
}

.icon-block::before {
  border: 1px solid currentColor;
  border-radius: 999px;
  height: 10px;
  left: 3px;
  top: 3px;
  width: 10px;
}

.icon-block::after {
  background: currentColor;
  height: 1px;
  left: 4px;
  top: 8px;
  transform: rotate(-35deg);
  width: 10px;
}

.icon-check::before {
  border-bottom: 1px solid currentColor;
  border-left: 1px solid currentColor;
  height: 5px;
  left: 5px;
  top: 5px;
  transform: rotate(-45deg);
  width: 8px;
}

.icon-alert::before {
  background: currentColor;
  height: 8px;
  left: 8px;
  top: 3px;
  width: 1px;
}

.icon-alert::after {
  background: currentColor;
  border-radius: 999px;
  height: 2px;
  left: 7.5px;
  top: 13px;
  width: 2px;
}

.composer-icon.icon-image::before {
  height: 18px;
  left: 10px;
  top: 10px;
  width: 18px;
}

.composer-icon.icon-image::after {
  height: 8px;
  left: 15px;
  top: 22px;
  width: 13px;
}

.chat-icon.icon-image::before {
  height: 11px;
  left: 3px;
  top: 3px;
  width: 11px;
}

.chat-icon.icon-image::after {
  height: 5px;
  left: 6px;
  top: 9px;
  width: 8px;
}

.nav-badge {
  align-items: center;
  background: rgba(77, 216, 181, 0.16);
  border: 1px solid rgba(77, 216, 181, 0.32);
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 11px;
  height: 20px;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  place-items: center;
}

.login-panel {
  background: var(--sidebar);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--glass-shadow), var(--inner-glow);
  display: grid;
  gap: 18px;
  max-width: 380px;
  padding: 22px;
  width: min(100%, 380px);
}

.login-panel p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 4px;
}

.login-panel h1 {
  font-size: 22px;
  margin: 0;
}

.login-panel label {
  display: grid;
  gap: 8px;
}

.login-panel label span {
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--foreground);
  min-height: 44px;
  outline: none;
  padding: 10px 12px;
}

.login-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(77, 216, 181, 0.16);
}

.login-panel button {
  background: linear-gradient(135deg, #f8fffd, #bff8e9);
  border: 0;
  border-radius: 8px;
  color: #06121e;
  font-weight: 700;
  min-height: 44px;
  padding: 10px 14px;
}

.chat-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
}

.chat-row {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) 30px;
  min-height: 50px;
}

.chat-row:hover,
.chat-row.active {
  background: #222933;
  border-color: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.chat-tab {
  background: transparent;
  border: 0;
  color: #f3f3f3;
  display: grid;
  font-size: 16px;
  font-weight: 700;
  gap: 12px;
  grid-template-columns: 24px minmax(0, 1fr);
  justify-content: start;
  min-width: 0;
  padding: 12px 12px;
  text-align: left;
  touch-action: manipulation;
  width: 100%;
}

.chat-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-icon {
  align-items: center;
  border: 1px solid rgba(144, 228, 189, 0.76);
  border-radius: 4px;
  color: var(--accent);
  display: inline-flex;
  height: 20px;
  justify-content: center;
  position: relative;
  width: 20px;
}

.delete-chat-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  display: inline-flex;
  font-size: 24px;
  height: 28px;
  justify-content: center;
  margin-right: 4px;
  touch-action: manipulation;
  width: 28px;
}

.delete-chat-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--foreground);
  transform: none;
}

.admin-side-note {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #f3f3f3;
  font-size: 14px;
  line-height: 1.4;
  padding: 12px;
}

.admin-side-note span {
  color: #a3a3a3;
}

.chat-view,
.admin-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
  position: relative;
  border-radius: 0 9px 9px 0;
}

.topbar {
  align-items: center;
  background: #121b25;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 110px;
  padding: 30px 32px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar p {
  color: var(--muted);
  font-size: 18px;
  margin: 0 0 8px;
}

.topbar h1 {
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}

.topbar button,
.empty-state button,
.image-result-actions a,
.admin-actions button,
.example-image-button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--foreground);
  padding: 10px 13px;
  box-shadow: var(--inner-glow);
}

.message-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  margin: 0 auto;
  max-width: 1100px;
  min-height: 0;
  overflow-y: auto;
  padding: 58px 32px calc(160px + env(safe-area-inset-bottom));
  width: 100%;
}

.message {
  align-items: flex-start;
  display: flex;
  gap: 16px;
}

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

.bubble {
  border-radius: 18px;
  line-height: 1.55;
  max-width: min(720px, 100%);
  padding: 10px 0;
  overflow-wrap: anywhere;
}

.intro-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  box-shadow: var(--inner-glow);
  color: #eef6ff;
  padding: 12px 16px;
}

.bubble p {
  margin: 0;
}

.bubble span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 8px;
}

.message-attachments {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(74px, 96px));
  margin-top: 10px;
}

.message-attachments a {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: block;
  overflow: hidden;
}

.message-attachments img {
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  width: 100%;
}

.user-message .bubble {
  background: rgba(144, 228, 189, 0.11);
  border: 1px solid rgba(144, 228, 189, 0.2);
  border-radius: 12px;
  box-shadow: none;
  padding: 12px 16px;
}

.bubble.open {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 12px 16px;
}

.bubble.declined {
  background: rgba(255, 139, 139, 0.1);
  border: 1px solid rgba(255, 139, 139, 0.26);
  color: var(--danger);
  padding: 12px 16px;
}

.bubble img {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  display: block;
  margin-bottom: 12px;
  max-height: 520px;
  max-width: 100%;
  object-fit: contain;
}

.message-attachments img {
  border-radius: 8px;
  box-shadow: none;
  margin-bottom: 0;
  max-height: none;
  object-fit: cover;
}

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

.answer-image-grid a {
  display: block;
  min-width: 0;
}

.answer-image-grid img {
  aspect-ratio: 1;
  width: 100%;
}

.image-result-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-result-actions a {
  color: #f3f3f3;
  display: inline-flex;
  font-size: 14px;
  padding: 9px 12px;
  text-decoration: none;
}

.image-result-actions a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.empty-state {
  align-self: center;
  display: grid;
  gap: 14px;
  justify-items: center;
  margin: 9vh 0 auto;
  max-width: 760px;
  text-align: center;
}

.empty-logo {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  display: inline-flex;
  height: 64px;
  padding: 8px;
  overflow: hidden;
  width: 64px;
}

.empty-logo img {
  border-radius: 999px;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.empty-state h2 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0;
}

.empty-state p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
  margin: 0;
}

.example-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 4px;
}

.empty-state button {
  align-items: center;
  background: #151d27;
  border-color: var(--line);
  border-radius: 10px;
  box-shadow: none;
  color: #cfd6df;
  display: inline-flex;
  font-size: 16px;
  min-height: 42px;
  padding: 8px 18px;
  text-align: center;
  touch-action: manipulation;
}

.empty-state button span {
  display: block;
}

.empty-state button:hover,
.topbar button:hover,
.admin-actions button:hover,
.example-image-button:hover,
.example-image-button.active {
  background: #202834;
  border-color: rgba(144, 228, 189, 0.34);
  transform: translateY(-1px);
}

.composer {
  align-items: stretch;
  background: linear-gradient(180deg, rgba(16, 24, 32, 0), rgba(16, 24, 32, 0.9) 42%);
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  left: 50%;
  margin: 0 auto;
  max-width: 1090px;
  padding: 24px 32px calc(28px + env(safe-area-inset-bottom));
  position: absolute;
  transform: translateX(-50%);
  width: 100%;
  z-index: 3;
}

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

.composer-attachments:empty {
  display: none;
}

.composer-attachment {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px minmax(0, 150px) 28px;
  margin: 0;
  min-height: 54px;
  padding: 5px;
}

.composer-attachment img {
  aspect-ratio: 1;
  border-radius: 7px;
  display: block;
  object-fit: cover;
  width: 42px;
}

.composer-attachment figcaption {
  color: var(--foreground);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment button {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  display: inline-flex;
  font-size: 18px;
  height: 28px;
  justify-content: center;
  padding: 0;
  width: 28px;
}

.composer-attachment button:hover {
  background: rgba(255, 139, 139, 0.14);
  border-color: rgba(255, 139, 139, 0.38);
  color: #ffd6d6;
}

.composer-inner {
  align-items: center;
  background: var(--composer);
  border: 1px solid rgba(119, 135, 153, 0.42);
  border-radius: 10px;
  box-shadow: none;
  display: grid;
  gap: 16px;
  grid-template-columns: 48px auto minmax(0, 1fr) 48px;
  min-height: 76px;
  padding: 8px 16px;
}

.composer-icon {
  align-items: center;
  border: 1px solid rgba(119, 135, 153, 0.42);
  border-radius: 8px;
  color: #b8c2cf;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  position: relative;
  width: 40px;
}

.composer > p {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.composer-upload-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #cfd6df;
  cursor: pointer;
  display: inline-grid;
  gap: 8px;
  grid-template-columns: 18px auto;
  min-height: 42px;
  overflow: hidden;
  padding: 8px 11px;
  position: relative;
  white-space: nowrap;
}

.composer-upload-button:hover {
  background: #202834;
  border-color: rgba(144, 228, 189, 0.34);
}

.composer-upload-button input {
  cursor: pointer;
  inset: 0;
  opacity: 0;
  position: absolute;
}

#reference-summary:empty {
  display: none;
}

.blocked-banner {
  background: rgba(82, 25, 32, 0.72);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 139, 139, 0.32);
  border-radius: 18px;
  bottom: 24px;
  color: #fecaca;
  left: 50%;
  max-width: 520px;
  padding: 14px 18px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  width: calc(100% - 320px);
}

.composer textarea {
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  color: var(--foreground);
  font-size: 16px;
  line-height: 1.35;
  max-height: 38vh;
  min-height: 44px;
  outline: none;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.composer textarea::placeholder,
.admin-card textarea::placeholder {
  color: #9b9b9b;
}

.composer-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(77, 216, 181, 0.16), var(--inner-glow);
}

.composer textarea:focus,
.admin-card textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(77, 216, 181, 0.16);
}

.composer textarea:focus {
  box-shadow: none;
}

.composer-inner > button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #102018;
  flex: 0 0 auto;
  font-size: 22px;
  height: 48px;
  touch-action: manipulation;
}

.admin-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  overflow-y: auto;
  padding: 28px 32px;
}

.admin-section {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--glass-shadow), var(--inner-glow);
  min-width: 0;
  padding: 16px;
}

.admin-section-wide {
  min-width: 0;
}

.metric-section {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  display: grid;
  gap: 12px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.metric-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.metric-card strong {
  color: var(--foreground);
  display: block;
  font-size: 28px;
  line-height: 1;
}

.admin-section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.admin-section-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 3px;
}

.admin-section-heading h2 {
  font-size: 18px;
  margin: 0;
}

.admin-section-heading > span {
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #d7d7d7;
  display: inline-flex;
  font-size: 13px;
  height: 28px;
  justify-content: center;
  min-width: 28px;
  padding: 0 9px;
}

.admin-card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.admin-card,
.admin-empty {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24), var(--inner-glow);
  padding: 18px;
  min-width: 0;
}

.completed-card {
  cursor: pointer;
  opacity: 0.82;
}

.muted-text {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.blocked-user-list {
  display: grid;
  gap: 10px;
}

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

.recent-prompt-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 11px;
}

.recent-prompt-row strong,
.recent-prompt-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-prompt-row strong {
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
}

.recent-prompt-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.recent-prompt-row mark {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
}

.recent-prompt-row mark.open {
  background: rgba(77, 216, 181, 0.14);
  border-color: rgba(77, 216, 181, 0.32);
  color: var(--accent-strong);
}

.recent-prompt-row mark.declined {
  background: rgba(255, 139, 139, 0.12);
  border-color: rgba(255, 139, 139, 0.26);
  color: var(--danger);
}

.blocked-user-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 11px;
}

.blocked-user-row span {
  color: #d7d7d7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blocked-user-row button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #f3f3f3;
  flex: 0 0 auto;
  padding: 8px 10px;
  touch-action: manipulation;
}

.blocked-user-row button:hover {
  border-color: var(--accent);
}

.admin-card-header {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.admin-card-header strong {
  color: var(--accent-strong);
}

.admin-card p,
.admin-empty p {
  line-height: 1.5;
  margin: 0 0 16px;
}

.creator-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 10px 12px;
  min-width: 0;
}

.creator-row span {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-row button {
  background: rgba(255, 139, 139, 0.12);
  border: 1px solid rgba(255, 139, 139, 0.26);
  border-radius: 12px;
  color: #ffd6d6;
  font-size: 13px;
  padding: 8px 10px;
  touch-action: manipulation;
}

.creator-row button:disabled {
  color: #a3a3a3;
  cursor: default;
  opacity: 0.72;
}

.reference-list {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  margin: -4px 0 14px;
  padding: 10px 12px;
}

.reference-list > span {
  color: var(--muted);
  font-size: 12px;
}

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

.reference-image-card {
  display: grid;
  gap: 8px;
  margin: 0;
  min-width: 0;
}

.reference-image-link {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: block;
  height: 76px;
  overflow: hidden;
}

.reference-image-link:hover {
  border-color: var(--accent);
}

.reference-image-link img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.reference-image-card figcaption {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reference-image-card figcaption span {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-image-card figcaption a {
  color: var(--accent-strong);
  font-size: 13px;
  justify-self: end;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.reference-image-card figcaption a:hover {
  color: var(--foreground);
}

.admin-empty h2 {
  font-size: 20px;
  margin: 0 0 8px;
}

.upload-box {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
  min-height: 126px;
  padding: 18px;
  position: relative;
  text-align: center;
  touch-action: manipulation;
  transition:
    border-color 160ms ease,
    background 160ms ease;
  width: 100%;
}

.upload-box:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--accent);
}

.admin-text-answer {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.45;
  margin-top: 12px;
  min-height: 96px;
  outline: none;
  padding: 13px 14px;
  resize: vertical;
  width: 100%;
}

.upload-box input {
  cursor: pointer;
  inset: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
}

.upload-box span {
  font-weight: 700;
}

.upload-box small {
  color: var(--muted);
}

.upload-preview {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  margin-top: 12px;
  min-height: 24px;
}

.upload-preview-item {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: 42px minmax(0, 1fr);
  margin: 0;
  min-width: 0;
}

.upload-preview-item img {
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  display: block;
  object-fit: cover;
  width: 42px;
}

.upload-preview-item figcaption,
.upload-preview span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-image-picker {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.example-image-button {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  color: var(--muted);
  display: grid;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  padding: 7px;
  text-align: center;
}

.example-image-button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.example-image-button img {
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, 0.24);
  border-radius: 7px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.example-image-button span {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.admin-actions button:first-child {
  background: linear-gradient(135deg, var(--accent), #6aa8ff);
  border-color: rgba(255, 255, 255, 0.28);
  color: #06121e;
  font-weight: 700;
}

.admin-actions button:last-child {
  color: var(--danger);
}

.site-footer {
  background: rgba(7, 13, 24, 0.72);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-top: 1px solid var(--line);
  color: #d7d7d7;
}

.footer-inner {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 0 auto;
  max-width: 1180px;
  padding: 22px 28px;
}

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

.footer-mark {
  align-items: center;
  background: #f6f6f1;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  height: 42px;
  justify-content: center;
  overflow: hidden;
  width: 42px;
}

.footer-mark img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.footer-brand strong {
  display: block;
  font-size: 15px;
}

.footer-brand p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 3px 0 0;
}

.footer-bottom {
  border-top: 1px solid var(--line);
  color: #8f8f8f;
  font-size: 12px;
  padding: 10px 18px;
  text-align: center;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    border-radius: 0;
    border-width: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    border-right: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    max-height: 220px;
    min-height: 0;
    overflow: hidden;
    padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  }

  .brand {
    gap: 10px;
    min-width: 0;
  }

  .brand-mark,
  .avatar {
    height: 36px;
    width: 36px;
  }

  .brand > div {
    min-width: 0;
  }

  .brand strong,
  .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .brand span {
    font-size: 12px;
  }

  .new-chat-button {
    font-size: 0;
    gap: 0;
    grid-template-columns: 1fr;
    height: 40px;
    min-height: 40px;
    padding: 10px;
    width: 44px;
  }

  .new-chat-button .nav-icon {
    justify-self: center;
  }

  .sidebar-label {
    grid-column: 1 / -1;
    margin: 0;
  }

  .chat-list {
    display: flex;
    gap: 8px;
    grid-column: 1 / -1;
    margin: 0 -12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 12px 4px;
    scrollbar-width: none;
  }

  .chat-list::-webkit-scrollbar {
    display: none;
  }

  .chat-row {
    flex: 0 0 min(72vw, 260px);
    grid-template-columns: minmax(0, 1fr) 34px;
    min-height: 44px;
  }

  .chat-tab {
    font-size: 14px;
    min-height: 44px;
    padding: 10px 11px;
  }

  .delete-chat-button {
    height: 34px;
    width: 34px;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-sidebar {
    grid-template-columns: 1fr;
    max-height: 252px;
  }

  .admin-nav {
    display: flex;
    gap: 8px;
    margin: 0 -12px;
    overflow-x: auto;
    padding: 0 12px 4px;
    scrollbar-width: none;
  }

  .admin-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-nav button {
    flex: 0 0 auto;
    grid-template-columns: 18px minmax(0, auto) auto;
    min-height: 40px;
    padding: 8px 10px;
    white-space: nowrap;
  }

  .chat-view,
  .admin-view {
    border-radius: 0;
    height: auto;
    min-height: 0;
  }

  .topbar {
    min-height: 76px;
    padding: 16px;
  }

  .topbar p {
    font-size: 13px;
    margin-bottom: 4px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar button {
    min-height: 40px;
    padding: 8px 10px;
  }

  .message-list {
    gap: 14px;
    padding: 34px 16px calc(140px + env(safe-area-inset-bottom));
  }

  .message {
    gap: 10px;
  }

  .empty-state {
    gap: 12px;
    margin: 2vh 0 auto;
    max-width: 100%;
  }

  .empty-logo {
    height: 54px;
    width: 54px;
  }

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

  .empty-state p {
    font-size: 15px;
    max-width: 330px;
  }

  .example-gallery {
    gap: 8px;
    max-width: 100%;
  }

  .empty-state button {
    font-size: 14px;
    min-height: 38px;
    padding: 8px 12px;
  }

  .user-message .bubble {
    max-width: min(84vw, 620px);
    padding: 10px 12px;
  }

  .assistant-message .bubble {
    max-width: calc(100% - 46px);
  }

  .bubble img {
    max-height: 46dvh;
  }

  .composer {
    left: 0;
    max-width: none;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    transform: none;
  }

  .composer-inner {
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) 44px;
    min-height: 58px;
    padding: 7px 8px;
  }

  .composer-icon {
    display: none;
  }

  .composer-upload-button {
    grid-column: 1 / -1;
    justify-content: center;
    min-height: 38px;
  }

  .composer-icon.icon-image::before {
    height: 14px;
    left: 9px;
    top: 9px;
    width: 14px;
  }

  .composer-icon.icon-image::after {
    height: 6px;
    left: 13px;
    top: 19px;
    width: 10px;
  }

  .composer textarea {
    font-size: 15px;
    max-height: 26dvh;
    min-height: 38px;
    padding: 7px 6px;
  }

  .composer-inner > button {
    font-size: 20px;
    height: 44px;
  }

  .composer > p {
    font-size: 12px;
  }

  .blocked-banner {
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100% - 24px);
  }

  .admin-grid {
    gap: 12px;
    grid-template-columns: 1fr;
    padding: 14px 12px calc(18px + env(safe-area-inset-bottom));
  }

  .metric-section,
  .admin-card-grid {
    grid-template-columns: 1fr;
  }

  .admin-section,
  .admin-card,
  .admin-empty {
    border-radius: 8px;
    padding: 14px;
  }

  .admin-card-header,
  .creator-row,
  .blocked-user-row,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .recent-prompt-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .creator-row button,
  .blocked-user-row button,
  .admin-actions button {
    min-height: 42px;
    width: 100%;
  }

  .upload-box {
    min-height: 110px;
  }

  .site-footer {
    display: none;
  }
}

@media (max-width: 420px) {
  .sidebar {
    max-height: 206px;
  }

  .brand span {
    display: none;
  }

  .chat-row {
    flex-basis: min(78vw, 250px);
  }

  .topbar {
    min-height: 70px;
    padding: 14px 12px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .message-list {
    padding-inline: 12px;
  }

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

  .empty-state button {
    width: 100%;
  }

  .composer-inner {
    grid-template-columns: 36px minmax(0, 1fr) 42px;
  }

  .composer-icon {
    height: 32px;
    width: 32px;
  }

  .image-result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .image-result-actions a {
    justify-content: center;
    min-height: 42px;
    width: 100%;
  }
}
