:root {
  --c-page-bg: #faf9f6;
  --c-text-default: #27272a;
  --c-text-secondary: #3f3f46;
  --c-text-muted: #71717a;
  --c-text-subtle: #a1a1aa;
  --c-text-faint: #d4d4d8;
  --c-text-error: #dc2626;
  --c-text-success: #15803d;
  --c-text-warning: #ea580c;
  --c-text-pending: #a16207;
  --c-border-dark: #27272a;
  --c-border-medium: #52525b;
  --c-border-light: #d4d4d8;
  --c-bg-white: #ffffff;
  --c-bg-light: #f4f4f5;
  --c-bg-subtle: #fafafa;
  --c-bg-accent: #eff6ff;
  --c-btn-primary: #fde68a;
  --c-btn-primary-hover: #fcd34d;
  --c-btn-secondary: #fbcfe8;
  --c-btn-secondary-hover: #f9a8d4;
  --c-btn-danger: #fca5a5;
  --c-btn-danger-hover: #f87171;
  --c-btn-disabled: #e4e4e7;
  --c-btn-send-active: #86efac;
  --c-btn-send-hover: #4ade80;
  --c-tab-human-active: #bbf7d0;
  --c-tab-ai-active: #e9d5ff;
  --c-tab-inactive: #f4f4f5;
  --c-credits-pill-bg: #fde68a;
  --c-bubble-user: #dcfce7;
  --c-bubble-pending: #fefce8;
  --c-bubble-pending-border: #fcd34d;
  --c-bubble-claimed: #f0e6ff;
  --c-bubble-claimed-border: #c084fc;
  --c-bubble-ai: #faf5ff;
  --c-bubble-expired: #fff7ed;
  --c-focus-border: #a855f7;
  --c-share-btn-bg: #e9d5ff;
  --c-share-btn-border: #c084fc;
  --c-share-btn-text: #6b21a8;
  --c-report-btn-bg: #fef2f2;
  --c-report-btn-border: #fca5a5;
  --c-report-btn-text: #dc2626;
  --c-timer-bar-bg: #f4f4f5;
  --c-timer-bar-normal: #86efac;
  --c-timer-bar-urgent: #fdba74;
  --c-timer-bar-critical: #f87171;
  --paper-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--c-page-bg);
  color: var(--c-text-default);
  font-family: "Comic Relief", "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  letter-spacing: 0;
  overscroll-behavior: none;
}

body.papyrus-mode,
body.papyrus-mode * {
  font-family: Papyrus, fantasy, "Comic Relief", cursive !important;
}

button,
textarea,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.check-row a,
.legal-copy a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

svg {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.font-sketch {
  font-family: "Comic Relief", "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
}

.app-shell {
  display: flex;
  min-height: 100dvh;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-page-bg);
}

.app-frame {
  width: min(100% - 24px, 672px);
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin: 18px auto 0;
}

.tabs {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: stretch;
  min-height: 56px;
  border: 2.5px solid var(--c-border-dark);
  border-bottom: 0;
  border-radius: 15px 15px 0 0;
  overflow: hidden;
  background: var(--c-bg-white);
}

.tab {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-right: 2.5px solid var(--c-border-dark);
  padding: 0 10px;
  background: var(--c-tab-inactive);
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.tab.active[data-tab="human"] {
  background: var(--c-tab-human-active);
  color: var(--c-text-default);
  font-weight: 700;
}

.tab.active[data-tab="ai"] {
  background: var(--c-tab-ai-active);
  color: var(--c-text-default);
  font-weight: 700;
}

.credits-pill {
  min-width: 72px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0 12px;
  background: var(--c-credits-pill-bg);
  color: var(--c-text-secondary);
  font-size: 14px;
  font-weight: 700;
}

.panel {
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 2.5px solid var(--c-border-dark);
  border-top: 0;
  border-radius: 0 0 15px 15px;
  background: var(--c-bg-white);
}

.panel.active {
  display: flex;
}

.chat-scroll,
.ai-content {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 10px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.chat-header img {
  width: 38px;
  height: 38px;
  animation: wiggle 1.6s ease-in-out infinite;
}

.chat-header h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.spacer {
  flex: 1;
}

.info-dot {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--c-bg-light);
  color: var(--c-text-muted);
  cursor: pointer;
}

.empty-state {
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--c-text-muted);
}

.empty-state img {
  width: 118px;
  height: 118px;
  opacity: 0.95;
  animation: wiggle 1.7s ease-in-out infinite;
}

.empty-state h2 {
  margin: 0;
  color: var(--c-text-default);
  font-size: 20px;
}

.empty-state p {
  width: min(100%, 420px);
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0 0 18px;
}

.bubble-row {
  display: flex;
}

.bubble-row.user {
  justify-content: flex-end;
}

.bubble-row.ai {
  justify-content: flex-start;
}

.bubble {
  max-width: 85%;
  border: 2px solid var(--c-border-medium);
  padding: 9px 12px;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble.user {
  max-width: 80%;
  border-radius: 15px 15px 4px 15px;
  background: var(--c-bubble-user);
}

.bubble.ai {
  border-radius: 15px 15px 15px 4px;
  background: var(--c-bubble-ai);
}

.bubble.pending {
  background: var(--c-bubble-pending);
  border-color: var(--c-bubble-pending-border);
  color: var(--c-text-pending);
}

.bubble.claimed {
  background: var(--c-bubble-claimed);
  border-color: var(--c-bubble-claimed-border);
  color: var(--c-share-btn-text);
}

.loading-copy {
  display: inline;
  line-height: 1.45;
}

.bubble.expired {
  background: var(--c-bubble-expired);
  border-color: #fdba74;
  color: var(--c-text-warning);
}

.bubble-label {
  display: block;
  margin-bottom: 5px;
  color: var(--c-text-subtle);
  font-size: 12px;
}

.bubble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tiny-button {
  border: 1px solid var(--c-border-light);
  border-radius: 8px;
  padding: 3px 8px;
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.tiny-button.share {
  border-color: var(--c-share-btn-border);
  background: var(--c-share-btn-bg);
  color: var(--c-share-btn-text);
}

.tiny-button.report {
  border-color: var(--c-report-btn-border);
  background: var(--c-report-btn-bg);
  color: var(--c-report-btn-text);
}

.tiny-button.cancel {
  border-color: var(--c-report-btn-border);
  background: var(--c-report-btn-bg);
  color: var(--c-report-btn-text);
}

.spinner {
  width: 13px;
  height: 13px;
  display: inline-block;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}

.response-canvas,
.draw-canvas {
  display: block;
  width: 100%;
  border: 2px solid var(--c-border-light);
  border-radius: 8px;
  background: #fff;
}

.response-canvas {
  max-width: 280px;
  aspect-ratio: 4 / 3;
}

.note-image {
  display: block;
  width: min(100%, 260px);
  max-height: 220px;
  object-fit: cover;
  margin-top: 9px;
  border: 2px solid var(--c-border-light);
  border-radius: 10px;
  background: #fff;
}

.prompt-card .note-image {
  width: min(100%, 420px);
  max-height: 280px;
}

.input-bar {
  flex: 0 0 auto;
  border-top: 2px solid var(--c-border-light);
  padding: 14px 12px max(12px, env(safe-area-inset-bottom));
  background: var(--c-bg-subtle);
}

.hint {
  margin: 0 0 8px;
  color: var(--c-text-muted);
  font-size: 12px;
}

.hint.error {
  color: var(--c-text-error);
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.mode-chip {
  appearance: none;
  -webkit-appearance: none;
  min-height: 42px;
  border: 2.5px solid var(--c-border-light);
  border-radius: var(--paper-radius);
  background-color: var(--c-bg-white);
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.mode-chip.active {
  border-color: var(--c-border-dark);
  background-color: var(--c-btn-primary);
  color: var(--c-text-default);
  font-weight: 700;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
  transform: translate(-1px, -1px);
}

.mode-chip:hover {
  border-color: var(--c-border-medium);
}

.mode-chip:focus-visible {
  outline: 3px solid var(--c-focus-border);
  outline-offset: 2px;
}

.mode-chip[data-human-type="image"].active {
  background-color: var(--c-btn-secondary);
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 9px;
  padding: 8px;
  border: 2px solid var(--c-border-light);
  border-radius: 10px;
  background: var(--c-bg-white);
  color: var(--c-text-muted);
  font-size: 12px;
}

.image-preview img {
  width: 54px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--c-border-light);
  border-radius: 7px;
}

.image-preview div {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.image-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-draw-slot {
  margin: 0 0 10px;
}

.ask-draw-slot .draw-board {
  gap: 7px;
}

.ask-draw-slot .draw-canvas-wrap {
  width: min(100%, 360px);
  height: min(28vh, 210px);
  margin: 0 auto;
}

.ask-draw-slot .palette,
.ask-draw-slot .draw-tools {
  gap: 5px;
}

.compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.textarea-wrap {
  position: relative;
  min-width: 0;
  flex: 1;
}

textarea {
  width: 100%;
  min-height: 42px;
  max-height: 82px;
  resize: none;
  overflow: hidden;
  border: 2.5px solid var(--c-border-dark);
  border-radius: 16px;
  padding: 9px 44px 9px 12px;
  background: var(--c-bg-white);
  color: var(--c-text-default);
  outline: none;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

textarea:focus {
  border-color: var(--c-focus-border);
}

.char-count {
  position: absolute;
  right: 11px;
  bottom: 5px;
  color: var(--c-text-faint);
  font-size: 10px;
}

.round-send,
.image-button {
  flex: 0 0 auto;
  border: 2.5px solid var(--c-border-dark);
  cursor: pointer;
}

.round-send,
.image-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.round-send {
  border-radius: 50%;
  background: var(--c-btn-send-active);
}

.image-button {
  border-radius: 12px;
  background: var(--c-bg-white);
  color: var(--c-text-muted);
}

.image-button.active {
  background: var(--c-btn-secondary);
  color: var(--c-text-default);
}

.round-send:disabled {
  cursor: not-allowed;
  background: var(--c-btn-disabled);
  opacity: 0.45;
}

.round-send svg,
.image-button svg {
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}


.card {
  border: 2.5px solid var(--c-border-dark);
  border-radius: var(--paper-radius);
  padding: 18px;
  background: var(--c-bg-white);
}

.card.accent {
  background: var(--c-bg-accent);
}

.card + .card,
.card + .button,
.button + .button,
.button + .card {
  margin-top: 12px;
}

.ai-title {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.2;
  text-align: center;
}

.ai-subtitle {
  margin: 0;
  text-align: center;
  color: var(--c-text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.center-stack {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.button {
  position: relative;
  border: 2.5px solid var(--c-border-dark);
  border-radius: var(--paper-radius);
  padding: 10px 22px;
  background: var(--c-btn-primary);
  color: var(--c-text-default);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
}

.button:hover:not(:disabled) {
  transform: scale(1.03);
  background: var(--c-btn-primary-hover);
}

.button:active:not(:disabled) {
  transform: scale(0.96);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.button.secondary {
  background: var(--c-btn-secondary);
}

.button.secondary:hover:not(:disabled) {
  background: var(--c-btn-secondary-hover);
}

.button.danger {
  background: var(--c-btn-danger);
}

.button.danger:hover:not(:disabled) {
  background: var(--c-btn-danger-hover);
}

.button.ghost {
  background: transparent;
  color: var(--c-text-muted);
}

.button.full {
  width: 100%;
}

.timer {
  margin-bottom: 12px;
}

.timer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.timer-label {
  color: var(--c-text-muted);
  font-size: 14px;
}

.timer-value {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.timer.urgent .timer-label,
.timer.urgent .timer-value {
  color: #f97316;
  font-weight: 700;
}

.timer.critical .timer-label,
.timer.critical .timer-value {
  color: #ef4444;
  font-weight: 700;
}

.timer-bar {
  height: 16px;
  overflow: hidden;
  border: 2px solid var(--c-border-dark);
  border-radius: var(--paper-radius);
  background: var(--c-timer-bar-bg);
}

.timer-fill {
  width: 100%;
  height: 100%;
  background: var(--c-timer-bar-normal);
  transition: width 1s linear, background 0.2s;
}

.prompt-meta,
.small-muted {
  color: var(--c-text-subtle);
  font-size: 12px;
}

.prompt-card p {
  margin: 8px 0 0;
  font-size: 18px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 2.5px solid var(--c-border-dark);
  border-radius: var(--paper-radius);
  margin: 12px 0;
}

.segmented button {
  border: 0;
  padding: 9px 12px;
  background: var(--c-bg-white);
  color: var(--c-text-muted);
  cursor: pointer;
}

.segmented button + button {
  border-left: 2px solid var(--c-border-dark);
}

.segmented button.active {
  background: var(--c-tab-ai-active);
  color: var(--c-text-default);
  font-weight: 700;
}

.ai-answer {
  height: 160px;
  max-height: none;
  padding: 12px;
}

.ai-actions,
.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ai-actions .button,
.result-actions .button {
  flex: 1;
  padding-inline: 12px;
}

.draw-board {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.draw-canvas-wrap {
  position: relative;
  border: 2.5px solid var(--c-border-dark);
  border-radius: 15px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 4 / 3;
  touch-action: none;
}

.draw-canvas {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  touch-action: none;
}

.draw-tools,
.palette,
.sticker-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.swatch,
.tool-button,
.sticker-button {
  border: 2px solid var(--c-border-light);
  border-radius: 8px;
  background: var(--c-bg-white);
  cursor: pointer;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.swatch.active,
.tool-button.active,
.sticker-button.active {
  border-color: var(--c-border-dark);
  transform: scale(1.08);
}

.tool-button {
  min-width: 38px;
  min-height: 32px;
  padding: 4px 8px;
  color: var(--c-text-muted);
  font-size: 12px;
}

.sticker-tray {
  max-height: 74px;
  overflow: auto;
  padding: 3px;
}

.sticker-button {
  min-width: 46px;
  min-height: 30px;
  border-radius: 999px;
  color: var(--c-text-muted);
  font-size: 11px;
}

.sticker-button.active {
  background: var(--c-btn-primary);
  color: var(--c-text-default);
  font-weight: 700;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(100%, 410px);
  max-height: min(92vh, 720px);
  overflow: auto;
  border: 2.5px solid var(--c-border-dark);
  border-radius: var(--paper-radius);
  padding: 22px;
  background: var(--c-bg-white);
  color: var(--c-text-default);
}

.modal-card h3 {
  margin: 0 0 10px;
  font-size: 19px;
}

.modal-card p,
.modal-card li {
  color: var(--c-text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.modal-card ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin: 14px 0 18px;
  list-style: none;
}

.legal-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.legal-card {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 2.5px solid var(--c-border-dark);
  border-radius: 14px;
  padding: 28px 24px 24px;
  background: var(--c-bg-white);
  color: var(--c-text-default);
}

.legal-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  align-self: center;
  border: 2px solid var(--c-border-dark);
  border-radius: 50%;
  background: var(--c-btn-primary);
  font-weight: 700;
  font-size: 24px;
}

.legal-card h2,
.legal-card p {
  margin: 0;
  text-align: center;
}

.legal-card p {
  color: var(--c-text-muted);
  font-size: 14px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 2px solid var(--c-border-medium);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}

.check-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--c-border-dark);
}

.footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 16px 14px;
  color: var(--c-text-subtle);
  text-align: center;
  font-size: 12px;
}

.author-meta {
  position: fixed;
  right: 12px;
  bottom: 10px;
  z-index: 850;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--c-text-muted);
  font-size: 11px;
  line-height: 1;
  opacity: 0.78;
  transition: opacity 140ms ease;
}

.author-meta:hover,
.author-meta:focus-within {
  opacity: 1;
}

.author-hover {
  position: relative;
}

.author-chip,
.version-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--c-border-light);
  border-radius: 999px;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--c-bg-white) 90%, transparent);
  box-shadow: 0 4px 14px rgba(39, 39, 42, 0.08);
  color: var(--c-text-muted);
  backdrop-filter: blur(8px);
}

.author-chip {
  cursor: pointer;
}

.author-chip:focus-visible {
  outline: 3px solid var(--c-focus-border);
  outline-offset: 2px;
}

.author-avatar-dot {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-btn-primary);
  color: var(--c-text-default);
  font-size: 10px;
  font-weight: 700;
}

.version-chip {
  cursor: default;
  user-select: none;
}

.author-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 176px;
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 2px solid var(--c-border-dark);
  border-radius: 14px;
  padding: 10px;
  background: var(--c-bg-white);
  box-shadow: 0 12px 32px rgba(39, 39, 42, 0.18);
  color: var(--c-text-default);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px) scale(0.98);
  transform-origin: bottom right;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.author-hover:hover .author-popover,
.author-hover:focus-within .author-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.author-popover img {
  display: block;
  background: #ffffff;
}

.author-popover strong {
  font-size: 13px;
}

.author-popover span {
  color: var(--c-text-muted);
  font-size: 11px;
  line-height: 1.35;
}

.author-card img {
  width: 108px;
  height: 108px;
  border: 2px solid var(--c-border-light);
  border-radius: 50%;
  object-fit: cover;
}

.qr-card {
  width: 218px;
}

.qr-card img {
  width: 188px;
  max-height: 262px;
  object-fit: contain;
  border: 1px solid var(--c-border-light);
  border-radius: 10px;
  padding: 4px;
}

.admin-body {
  min-height: 100dvh;
  overflow: auto;
  background: var(--c-page-bg);
}

.admin-shell {
  width: min(100% - 24px, 1080px);
  margin: 24px auto 48px;
}

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

.admin-header h1,
.admin-header p,
.admin-card h2,
.admin-card p {
  margin: 0;
}

.admin-header h1 {
  font-size: 26px;
}

.admin-header p,
.admin-muted,
.admin-empty,
.admin-status {
  color: var(--c-text-muted);
  font-size: 13px;
}

.admin-card {
  border: 2.5px solid var(--c-border-dark);
  border-radius: 14px;
  padding: 16px;
  background: var(--c-bg-white);
}

.admin-card + .admin-card,
.admin-grid + .admin-card {
  margin-top: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 14px;
  margin-top: 14px;
}

.admin-token-row {
  display: grid;
  gap: 8px;
  color: var(--c-text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.admin-token-row input {
  width: 100%;
  border: 2px solid var(--c-border-medium);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--c-bg-subtle);
  color: var(--c-text-default);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-actions.compact {
  margin-top: 10px;
}

.admin-actions.compact .button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.admin-status[data-type="error"] {
  color: var(--c-text-error);
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.admin-metric {
  border: 2px solid var(--c-border-light);
  border-radius: 10px;
  padding: 10px;
  background: var(--c-bg-subtle);
}

.admin-metric span,
.admin-metric strong {
  display: block;
}

.admin-metric span {
  color: var(--c-text-muted);
  font-size: 12px;
}

.admin-metric strong {
  margin-top: 4px;
  font-size: 18px;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.admin-item {
  border: 2px solid var(--c-border-light);
  border-radius: 10px;
  padding: 12px;
  background: var(--c-bg-subtle);
}

.admin-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-item-head span {
  color: var(--c-text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.admin-item p {
  margin: 6px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.legal-page {
  width: min(100% - 24px, 760px);
}

.legal-copy {
  display: grid;
  gap: 12px;
}

.legal-copy h2 {
  font-size: 20px;
}

.legal-copy p {
  color: var(--c-text-secondary);
  line-height: 1.6;
}

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

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2deg);
  }
}

@media (max-width: 760px) {
  .app-frame {
    width: min(100% - 8px, 672px);
    margin-top: 4px;
  }

  .author-meta {
    right: 8px;
    bottom: 6px;
    gap: 4px;
    font-size: 10px;
  }

  .author-chip,
  .version-chip {
    min-height: 22px;
    padding: 3px 6px;
  }

  .author-popover {
    bottom: calc(100% + 7px);
  }

  .qr-card {
    width: 204px;
  }

  .qr-card img {
    width: 174px;
    max-height: 244px;
  }

  .chat-scroll,
  .ai-content {
    padding: 12px 10px 8px;
  }

  .tab {
    min-height: 50px;
    font-size: 14px;
  }

  .credits-pill {
    min-width: 62px;
    min-height: 50px;
    padding-inline: 8px;
    font-size: 13px;
  }

  .compose-row {
    gap: 6px;
  }

  .ai-actions,
  .result-actions {
    flex-wrap: wrap;
  }

  .ai-actions .button,
  .result-actions .button {
    min-width: calc(50% - 4px);
  }

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

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

@media (max-width: 430px) {
  .chat-header h1 {
    font-size: 16px;
  }

  .bubble {
    max-width: 92%;
  }

  .bubble.user {
    max-width: 88%;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-page-bg: #1a1a1e;
    --c-text-default: #e4e4e7;
    --c-text-secondary: #d4d4d8;
    --c-text-muted: #a1a1aa;
    --c-text-subtle: #71717a;
    --c-text-faint: #52525b;
    --c-border-dark: #52525b;
    --c-border-medium: #71717a;
    --c-border-light: #3f3f46;
    --c-bg-white: #27272a;
    --c-bg-light: #323238;
    --c-bg-subtle: #222226;
    --c-bg-accent: #1c2535;
    --c-btn-primary: #78621a;
    --c-btn-primary-hover: #92711a;
    --c-btn-secondary: #7c2d5c;
    --c-btn-secondary-hover: #9d3474;
    --c-btn-disabled: #3f3f46;
    --c-btn-send-active: #166534;
    --c-btn-send-hover: #15803d;
    --c-tab-human-active: #1a4a2a;
    --c-tab-ai-active: #3b1f6e;
    --c-tab-inactive: #323238;
    --c-credits-pill-bg: #78621a;
    --c-bubble-user: #1a3a2a;
    --c-bubble-pending: #3a3520;
    --c-bubble-pending-border: #92711a;
    --c-bubble-claimed: #2a1f3a;
    --c-bubble-claimed-border: #7c3aed;
    --c-bubble-ai: #2a2535;
    --c-bubble-expired: #3a2a1a;
    --c-share-btn-bg: #3b1f6e;
    --c-report-btn-bg: #3a1a1a;
    --c-timer-bar-bg: #323238;
  }

  .empty-state img,
  .chat-header img {
    filter: invert(1);
  }
}
