:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --text: #202123;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft-line: #f0f0f0;
  --accent: #111827;
  --success: #10a37f;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

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

button,
a {
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  align-items: center;
  overflow: hidden;
  background: #050505;
  padding: clamp(18px, 3.8vw, 48px);
}

.auth-screen::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  background:
    radial-gradient(circle at 78% 46%, rgba(255, 255, 255, 0.18), transparent 24%),
    radial-gradient(circle at 18% 16%, rgba(234, 188, 128, 0.18), transparent 28%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.08) 42%, rgba(0, 0, 0, 0.5)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.36)),
    url("/auth-poster.png?v=20260524-21") center center / cover no-repeat;
  opacity: 1;
  pointer-events: none;
}

.auth-screen::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.06) 42%, rgba(0, 0, 0, 0.48)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.34)),
    url("/auth-poster-ai.png?v=20260524-21") center center / cover no-repeat;
  opacity: 0;
  animation: authBackgroundSwap 32s ease-in-out infinite;
  pointer-events: none;
}

.auth-background-copy {
  position: absolute;
  left: clamp(28px, 6vw, 86px);
  bottom: clamp(30px, 7vw, 92px);
  z-index: 2;
  max-width: min(560px, 48vw);
  color: #fff;
  text-shadow: 0 16px 42px rgba(0, 0, 0, 0.52);
  pointer-events: none;
}

.auth-background-copy span {
  display: block;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-background-copy strong {
  display: block;
  font-size: clamp(28px, 4.4vw, 58px);
  line-height: 1.16;
  letter-spacing: 0;
}

.admin-auth {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #fff;
  padding: 24px;
}

.auth-layout {
  position: relative;
  z-index: 3;
  display: grid;
  width: min(1420px, 100%);
  min-height: calc(100vh - clamp(36px, 7.6vw, 96px));
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 0;
  align-items: center;
  margin: 0 auto;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-screen .auth-card {
  position: relative;
  width: 100%;
  justify-self: center;
  align-self: center;
  grid-column: 2;
  overflow: hidden;
  isolation: isolate;
  border-color: rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  padding: clamp(28px, 3vw, 42px);
  backdrop-filter: blur(16px) saturate(145%);
  animation: authCardFloat 7s ease-in-out infinite, authCardGlow 5.5s ease-in-out infinite alternate;
}

.auth-screen .auth-card::before,
.auth-screen .auth-card::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.auth-screen .auth-card::before {
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.86),
    rgba(234, 188, 128, 0.44),
    rgba(16, 163, 127, 0.34),
    rgba(255, 255, 255, 0.66)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.72;
  animation: authCardBorder 6s linear infinite;
}

.auth-screen .auth-card::after {
  inset: -38% auto -38% -34%;
  z-index: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  filter: blur(1px);
  transform: rotate(16deg);
  animation: authCardSheen 8s ease-in-out infinite;
}

.auth-screen .auth-card > * {
  position: relative;
  z-index: 1;
}

.logo-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.auth-screen .logo-row {
  display: block;
  margin-bottom: 26px;
}

.auth-screen .logo-row h1 {
  max-width: none;
  color: #fff;
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.04;
  letter-spacing: 0;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.auth-kicker,
.auth-subtitle {
  margin: 0;
  letter-spacing: 0;
}

.auth-kicker {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.auth-subtitle {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.logo-dot,
.message-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.logo-row h1,
.chat-header h2,
.admin-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.logo-row p,
.chat-header p,
.admin-header p,
.fine-print,
.muted {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--surface-2);
  padding: 4px;
}

.auth-screen .auth-tabs {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.18);
}

.auth-tabs button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  padding: 10px;
}

.auth-tabs button.active {
  background: rgba(255, 255, 255, 0.42);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--text);
}

.auth-screen input:focus {
  border-color: rgba(138, 98, 56, 0.75);
  box-shadow: 0 0 0 4px rgba(138, 98, 56, 0.13);
}

.auth-form button,
.stack-form button,
.send-button,
.new-chat,
.admin-actions button,
.secondary-button,
.table-actions button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 11px 14px;
  font-weight: 650;
}

.form-error,
.warning {
  color: var(--danger);
}

@keyframes authCardFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -6px, 0);
  }
}

@keyframes authCardGlow {
  from {
    box-shadow:
      0 30px 80px rgba(0, 0, 0, 0.3),
      0 0 0 rgba(234, 188, 128, 0),
      inset 0 1px 0 rgba(255, 255, 255, 0.28);
  }
  to {
    box-shadow:
      0 38px 98px rgba(0, 0, 0, 0.42),
      0 0 36px rgba(234, 188, 128, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.42);
  }
}

@keyframes authCardBorder {
  from {
    filter: hue-rotate(0deg);
  }
  to {
    filter: hue-rotate(360deg);
  }
}

@keyframes authCardSheen {
  0%,
  34% {
    opacity: 0;
    transform: translateX(0) rotate(16deg);
  }
  48% {
    opacity: 0.72;
  }
  100% {
    opacity: 0;
    transform: translateX(560%) rotate(16deg);
  }
}

@keyframes authBackgroundSwap {
  0%,
  46% {
    opacity: 0;
  }
  50%,
  96% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-screen .auth-card,
  .auth-screen .auth-card::before,
  .auth-screen .auth-card::after,
  .auth-screen::after,
  .thinking-copy,
  .generation-sheen,
  .generation-line {
    animation: none;
  }
}

.chat-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 14px;
  overflow: hidden;
}

.new-chat {
  width: 100%;
  text-align: left;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  padding: 8px 4px;
}

.recharge-button,
.usage-log-button {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  text-align: center;
}

.usage-log-button {
  margin-top: 10px;
  background: #f7f7f8;
  font-size: 13px;
}

.usage-log-button:hover,
.recharge-button:hover {
  border-color: rgba(16, 163, 127, 0.45);
  background: #fff;
}

.conversation-panel {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.conversation-panel:first-of-type {
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
}

.conversation-panel:nth-of-type(2) {
  flex: 0 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: 32vh;
}

.panel-label {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  padding: 0 4px;
}

.trash-toggle {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  padding: 5px 6px;
}

.trash-toggle:hover {
  background: #ececf1;
  color: var(--text);
}

.trash-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 4px;
  grid-auto-rows: minmax(54px, max-content);
  min-height: 0;
  overflow-y: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
  align-items: center;
  border-radius: 10px;
  min-height: 54px;
  padding: 4px;
}

.conversation-item.active,
.conversation-item:hover {
  background: #ececf1;
}

.conversation-title,
.conversation-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 6px;
  text-align: left;
}

.conversation-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item.trash {
  grid-template-columns: minmax(0, 1fr) auto;
}

.icon-text {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  font-size: 12px;
}

.icon-text:hover {
  background: #fff;
  color: var(--text);
}

.empty-trash {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.profile-box {
  flex: 0 0 auto;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.profile-name {
  font-weight: 700;
}

.profile-tier {
  margin-top: 6px;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
}

.usage-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.profile-quota-progress {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef0f3;
}

.profile-quota-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 220ms ease;
}

.profile-reset {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.chat-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  min-width: 0;
  min-height: 100vh;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--soft-line);
  padding: 14px 24px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.settings-row select {
  width: auto;
  min-width: 96px;
  padding: 8px 10px;
}

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

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 760px);
  gap: 14px;
  justify-content: center;
  padding: 16px 24px;
}

.message.user .message-avatar {
  background: #111827;
}

.message-body {
  min-width: 0;
  line-height: 1.7;
}

.message-body p {
  margin: 0;
  white-space: pre-wrap;
}

.message-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.scroll-bottom-button {
  position: absolute;
  right: max(24px, calc((100% - 860px) / 2 + 16px));
  bottom: 112px;
  z-index: 18;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  cursor: pointer;
}

.scroll-bottom-button:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.scroll-bottom-button[hidden] {
  display: none;
}

.thinking-block {
  display: grid;
  gap: 14px;
  width: min(100%, 560px);
}

.thinking-copy {
  color: #8b95a1;
  font-weight: 650;
  animation: thinkingPulse 1.7s ease-in-out infinite;
}

.thinking-copy span {
  color: #b5bdc8;
}

.generation-stage {
  width: min(100%, 480px);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(229, 231, 235, 0.92)),
    #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.generation-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.4), rgba(203, 213, 225, 0.32));
}

.generation-frame::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08)),
    repeating-linear-gradient(0deg, rgba(148, 163, 184, 0.09) 0 1px, transparent 1px 18px);
}

.generation-sheen {
  position: absolute;
  inset: -35% auto -35% -30%;
  width: 34%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.86), transparent);
  filter: blur(1px);
  animation: generationSweep 2.4s ease-in-out infinite;
}

.generation-hint {
  position: absolute;
  left: 18px;
  bottom: 16px;
  color: rgba(71, 85, 105, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.generation-line {
  position: absolute;
  height: 2px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.38);
  animation: sketchLine 2s ease-in-out infinite;
}

.line-a {
  left: 18%;
  top: 46%;
  width: 46%;
}

.line-b {
  left: 34%;
  top: 56%;
  width: 38%;
  animation-delay: 0.22s;
}

.line-c {
  left: 25%;
  top: 66%;
  width: 28%;
  animation-delay: 0.44s;
}

.generated-card {
  width: min(100%, 760px);
}

.generated-partial {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.92);
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

.generated-partial button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.generated-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 10px;
  align-items: start;
}

.generated-main-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.generated-image {
  display: block;
  width: 100%;
  max-height: 74vh;
  object-fit: contain;
  background: #fff;
  cursor: zoom-in;
}

.generated-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.generated-actions button {
  pointer-events: auto;
  border: 0;
  background: rgba(17, 24, 39, 0.58);
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(12px);
}

.generated-primary-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.generated-edit,
.generated-annotate {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
}

.generated-annotate {
  background: rgba(17, 24, 39, 0.42) !important;
}

.generated-icon-actions {
  display: flex;
  gap: 8px;
}

.generated-icon-actions button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
}

.generated-thumbs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.generated-thumbs button {
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 2px;
}

.generated-thumbs button.active {
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.16);
}

.generated-thumbs img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

@media (max-width: 560px) {
  .generated-partial {
    align-items: stretch;
    flex-direction: column;
  }

  .generated-gallery {
    grid-template-columns: 1fr;
  }

  .generated-thumbs {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .generated-thumbs button {
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
  }
}

@keyframes thinkingPulse {
  0%,
  100% {
    opacity: 0.56;
  }
  50% {
    opacity: 1;
  }
}

@keyframes generationSweep {
  0% {
    transform: translateX(0) rotate(18deg);
    opacity: 0;
  }
  18% {
    opacity: 0.9;
  }
  72% {
    opacity: 0.85;
  }
  100% {
    transform: translateX(420%) rotate(18deg);
    opacity: 0;
  }
}

@keyframes sketchLine {
  0%,
  100% {
    opacity: 0.28;
    transform: scaleX(0.72);
  }
  50% {
    opacity: 0.78;
    transform: scaleX(1);
  }
}

.thumb-grid,
.reference-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.thumb-item,
.reference-item {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.thumb-item {
  position: relative;
  display: block;
  overflow: hidden;
  background: #fff;
}

.reference-item {
  position: relative;
  display: block;
  overflow: visible;
  background: #fff;
}

.thumb-grid > img,
.thumb-item img,
.reference-item img {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  border-radius: 9px;
  object-fit: cover;
}

.thumb-grid > img {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
}

.thumb-missing {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  padding: 8px;
}

.reference-index {
  position: absolute;
  left: 5px;
  bottom: 5px;
  z-index: 2;
  min-width: 28px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}

.reference-annotation-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}

.reference-annotate {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 3;
  min-height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.reference-item:hover .reference-annotate,
.reference-item:focus-within .reference-annotate {
  opacity: 1;
}

.reference-remove {
  position: absolute;
  top: -7px;
  left: -7px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 16px;
  line-height: 20px;
  font-weight: 700;
  font-family: Arial, sans-serif;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.22);
}

.reference-remove:hover {
  background: #000;
}

.reference-remove:focus-visible {
  outline: 2px solid var(--success);
  outline-offset: 2px;
}

.reference-annotation-editor {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(8px);
}

.reference-annotation-editor.hidden {
  display: none;
}

.annotation-panel {
  width: min(1180px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.annotation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.annotation-header strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.annotation-header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.annotation-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
}

.annotation-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  min-height: 0;
  padding: 18px;
}

.annotation-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  border-radius: 14px;
  background: #f8fafc;
}

.annotation-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.annotation-canvas img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 150px);
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  user-select: none;
}

.annotation-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.annotation-box {
  position: absolute;
  display: block;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  border: 2px solid #0ea5e9;
  border-radius: 6px;
  background: rgba(14, 165, 233, 0.08);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.03);
}

.annotation-box.selected,
.annotation-box:focus-visible {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  outline: none;
}

.annotation-box.draft {
  border-style: dashed;
}

.annotation-box span {
  position: absolute;
  top: -12px;
  left: -12px;
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.annotation-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.annotation-side label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.annotation-side textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

.annotation-actions {
  display: grid;
  gap: 8px;
}

.annotation-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.annotation-actions button:first-child {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.annotation-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .reference-annotation-editor {
    padding: 10px;
  }

  .annotation-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .annotation-canvas img {
    max-height: 56vh;
  }
}

.composer {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

.composer-box {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 72px;
  align-items: end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  padding: 8px;
}

.composer.drag-over .composer-box {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.14), 0 10px 30px rgba(0, 0, 0, 0.06);
}

.attach-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 24px;
}

.attach-button input {
  display: none;
}

.composer textarea {
  min-height: 38px;
  max-height: 180px;
  border: 0;
  resize: none;
  padding: 8px;
  line-height: 1.55;
}

.send-button {
  min-height: 38px;
  padding: 0 14px;
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 6px 0;
  color: var(--muted);
  font-size: 12px;
}

.composer-meta button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.rename-dialog,
.usage-log-dialog {
  width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.usage-log-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: min(720px, calc(100vh - 42px));
}

.rename-dialog::backdrop,
.usage-log-dialog::backdrop {
  background: rgba(17, 24, 39, 0.32);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox img {
  max-width: min(100%, 1500px);
  max-height: 92vh;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  object-fit: contain;
}

.image-lightbox button {
  position: fixed;
  top: 18px;
  right: 20px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  backdrop-filter: blur(10px);
}

.rename-dialog h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.usage-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 14px;
}

.usage-log-head p,
.usage-log-head h2 {
  margin: 0;
}

.usage-log-head p {
  color: var(--success);
  font-size: 12px;
  font-weight: 750;
}

.usage-log-head h2 {
  margin-top: 5px;
  color: #111827;
  font-size: 22px;
}

.usage-log-head button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.usage-log-body {
  display: grid;
  gap: 10px;
  max-height: min(560px, calc(100vh - 180px));
  margin-top: 14px;
  overflow-y: auto;
}

.usage-log-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.usage-log-empty.warning {
  color: var(--warning);
}

.usage-log-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: #fafafa;
  padding: 12px;
}

.usage-log-row,
.usage-log-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.usage-log-row strong {
  color: #111827;
  font-size: 16px;
}

.usage-log-row span {
  border-radius: 999px;
  background: #eef7f3;
  color: var(--success);
  font-size: 12px;
  padding: 4px 8px;
}

.usage-log-item p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.usage-log-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.usage-log-item code {
  width: max-content;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 7px;
}

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

.dialog-actions button {
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
}

.dialog-actions button[value="save"] {
  background: var(--accent);
  color: #fff;
}

.billing-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(16, 163, 127, 0.09), transparent 28%),
    linear-gradient(180deg, #fbfbfb 0%, #f3f4f6 100%);
  padding: clamp(20px, 4vw, 48px);
}

.billing-header,
.billing-intro,
.billing-plans,
.billing-status {
  width: min(1180px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.billing-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.billing-header p,
.billing-header h1,
.billing-header span {
  margin: 0;
}

.billing-header p {
  color: var(--success);
  font-size: 12px;
  font-weight: 750;
}

.billing-header h1 {
  margin-top: 8px;
  font-size: clamp(32px, 4.5vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}

.billing-header span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.billing-header a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 14px;
  text-decoration: none;
}

.billing-intro {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.billing-intro div,
.billing-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.07);
}

.billing-intro div {
  padding: 14px 16px;
}

.billing-intro strong,
.billing-intro span {
  display: block;
}

.billing-intro span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.billing-plans {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.billing-card {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 330px;
  padding: 18px;
}

.billing-card.current {
  border-color: rgba(16, 163, 127, 0.52);
  box-shadow: 0 18px 50px rgba(16, 163, 127, 0.12);
}

.billing-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.billing-card h2 {
  margin: 0;
  font-size: 24px;
}

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

.current-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(16, 163, 127, 0.1);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
}

.billing-quota {
  border-top: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
  color: var(--accent);
  font-weight: 700;
  padding: 12px 0;
}

.billing-free {
  display: grid;
  gap: 8px;
  border-radius: 12px;
  background: var(--surface-2);
  padding: 14px;
}

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

.billing-price-row {
  display: grid;
  gap: 10px;
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
}

.billing-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.billing-price strong {
  font-size: 26px;
}

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

.billing-pay-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.billing-pay-actions button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 9px 8px;
}

.billing-pay-actions button:hover {
  border-color: var(--accent);
}

.billing-pay-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.billing-status {
  min-height: 22px;
  margin-top: 16px;
  color: var(--success);
  font-size: 14px;
}

.billing-status.warning {
  color: var(--warning);
}

.billing-page {
  min-height: 100vh;
  background: #fff;
  padding: 12px clamp(18px, 4vw, 48px) 42px;
}

.billing-header,
.billing-hero,
.billing-note,
.billing-plans,
.billing-status {
  width: min(1120px, 100%);
  margin-right: auto;
  margin-left: auto;
}

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

.billing-back,
.billing-header-actions {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.billing-back {
  padding: 0 14px;
}

.billing-header-actions {
  color: var(--muted);
  padding: 0 13px;
}

.billing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 28px;
  align-items: start;
  margin-bottom: 20px;
}

.billing-kicker {
  margin: 0 0 8px;
  color: var(--success);
  font-size: 13px;
  font-weight: 750;
}

.billing-hero h1 {
  max-width: 760px;
  margin: 0;
  color: #111827;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.06;
  letter-spacing: 0;
}

.billing-title-deco {
  display: flex;
  max-width: 640px;
  margin-top: 22px;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: #475569;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.5;
  text-transform: uppercase;
}

.billing-title-deco i {
  width: 72px;
  height: 1px;
  background: linear-gradient(90deg, rgba(16, 163, 127, 0.85), rgba(17, 24, 39, 0.12));
}

.billing-subcopy {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.billing-account-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fafb;
  padding: 15px;
}

.billing-account-top span,
.billing-account-top strong {
  display: block;
}

.billing-account-top span,
.billing-quota-grid span {
  color: var(--muted);
  font-size: 13px;
}

.billing-account-top strong {
  margin-top: 7px;
  color: var(--text);
  font-size: 15px;
}

.billing-quota-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ececf1;
}

.billing-quota-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 220ms ease;
}

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

.billing-quota-grid div {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.billing-quota-grid strong {
  display: block;
  margin-top: 5px;
  color: #111827;
  font-size: 18px;
}

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

.billing-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f7f8;
  color: var(--muted);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.billing-note p {
  margin: 0;
  line-height: 1.55;
}

.billing-note-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  margin-top: 8px;
}

.billing-plans {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.billing-card {
  display: flex;
  min-height: 468px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
  padding: 18px;
}

.billing-card.current {
  border-color: rgba(16, 163, 127, 0.55);
  box-shadow: 0 0 0 1px rgba(16, 163, 127, 0.18);
}

.billing-plan-top {
  display: flex;
  min-height: 132px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.billing-card h2 {
  margin: 0;
  color: #111827;
  font-size: 25px;
  letter-spacing: 0;
}

.billing-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.plan-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e6f4ef;
  color: #0f7a5f;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.billing-plan-main {
  border-top: 1px solid var(--soft-line);
  padding-top: 14px;
}

.billing-plan-main strong,
.billing-plan-main span {
  display: block;
}

.billing-plan-main strong {
  color: #111827;
  font-size: 17px;
}

.billing-plan-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.billing-plan-free,
.billing-price-list {
  margin-top: 18px;
}

.billing-plan-free {
  border-radius: 12px;
  background: #f7f7f8;
  padding: 14px;
}

.billing-plan-free strong {
  display: block;
  color: #111827;
  font-size: 28px;
}

.billing-plan-free span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.billing-price-list {
  display: grid;
  gap: 12px;
}

.billing-price-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: #fafafa;
  padding: 12px;
}

.billing-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.billing-price strong {
  color: #111827;
  font-size: 26px;
  letter-spacing: 0;
}

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

.billing-pay-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.pay-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #111827;
  padding: 0 10px;
}

.pay-button:hover {
  border-color: #c7c7c7;
  background: #f7f7f8;
}

.pay-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pay-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.pay-icon.alipay {
  background: #1677ff;
}

.pay-icon.wechat {
  background: #07c160;
}

.pay-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.billing-features {
  display: grid;
  gap: 8px;
  margin: auto 0 0;
  padding: 18px 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.billing-status {
  min-height: 22px;
  margin-top: 18px;
  color: var(--success);
  font-size: 14px;
  line-height: 1.6;
}

.billing-status.warning {
  color: var(--warning);
}

.admin-shell {
  min-height: 100vh;
  background: #f7f7f8;
  padding: clamp(18px, 3vw, 32px);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto 18px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-actions a {
  color: var(--muted);
  text-decoration: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto 16px;
  align-items: start;
}

.admin-panel {
  width: min(1280px, 100%);
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.secondary-button,
.table-actions button {
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 10px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  min-height: auto;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.generation-count-button {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.generation-log-wrap table {
  min-width: 1280px;
}

.log-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
}

.log-status.is-good {
  background: rgba(16, 163, 127, 0.12);
  color: #047857;
}

.log-status.is-bad {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
}

.prompt-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 650;
}

.prompt-details pre {
  max-width: 420px;
  max-height: 180px;
  overflow: auto;
  margin: 7px 0 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.table-wrap {
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-top: 1px solid var(--soft-line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

tbody tr:first-child td {
  border-top: 0;
}

th {
  background: #fafafa;
  color: var(--muted);
  font-weight: 600;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.key-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.11);
  color: #475569;
  font-size: 12px;
  font-weight: 750;
  padding: 0 9px;
  white-space: nowrap;
}

.key-status-pill.is-good {
  background: rgba(16, 163, 127, 0.12);
  color: #047857;
}

.key-status-pill.is-warn {
  background: rgba(245, 158, 11, 0.13);
  color: #92400e;
}

.key-status-pill.is-bad {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
}

.key-status-pill.is-disabled {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

.key-status-sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .auth-screen {
    padding: 14px;
  }

  .auth-background-copy {
    left: 28px;
    bottom: 30px;
    max-width: min(420px, 58vw);
  }

  .auth-background-copy span {
    margin-bottom: 14px;
    font-size: 11px;
  }

  .auth-background-copy strong {
    font-size: clamp(24px, 4.1vw, 34px);
    line-height: 1.18;
  }

  .auth-layout {
    width: min(720px, 100%);
    min-height: calc(100vh - 28px);
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-screen .auth-card {
    grid-column: 1;
    order: 0;
    justify-self: end;
    width: min(440px, 100%);
    padding: 22px;
    border-radius: 24px;
  }

  .chat-shell {
    grid-template-columns: minmax(220px, 36vw) minmax(0, 1fr);
  }

  .chat-sidebar {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .billing-title-deco {
    margin-top: 14px;
    gap: 8px 10px;
  }

  .billing-title-deco i {
    width: 52px;
  }

  .billing-intro,
  .billing-plans {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-row {
    justify-content: flex-start;
  }

  .message {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 14px 16px;
  }

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

@media (max-width: 560px) {
  .auth-screen {
    overflow: auto;
  }

  .auth-background-copy {
    left: 24px;
    right: 24px;
    bottom: 28px;
    max-width: none;
  }

  .auth-background-copy strong {
    font-size: 24px;
    line-height: 1.18;
  }

  .auth-layout {
    min-height: calc(100vh - 28px);
    grid-template-columns: 1fr;
  }

  .auth-screen .auth-card {
    width: 100%;
    justify-self: center;
  }

  .auth-screen .logo-row h1 {
    max-width: none;
    font-size: 30px;
  }

  .chat-shell {
    display: block;
    height: auto;
    overflow: visible;
  }

  .chat-sidebar,
  .chat-main {
    height: auto;
    min-height: 0;
  }

  .chat-sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    overflow: visible;
  }

  .profile-box {
    margin-top: 8px;
  }

  .billing-page {
    padding: 16px;
  }

  .billing-hero {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .billing-intro,
  .billing-plans {
    grid-template-columns: 1fr;
  }

  .billing-card {
    min-height: 0;
  }

  .composer-box {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .send-button {
    grid-column: 1 / -1;
  }
}
