* { box-sizing: border-box; }

:root {
  --bg: #f4f7fb;
  --bg-2: #eef3f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1f2937;
  --muted: #475569;
  --border: #dbe3ef;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

body.dark {
  --bg: #0f172a;
  --bg-2: #111827;
  --surface: #111827;
  --surface-2: #1f2937;
  --text: #e5e7eb;
  --muted: #cbd5e1;
  --border: #334155;
  --primary: #818cf8;
  --primary-soft: #312e81;
  --success-bg: #14532d;
  --success-text: #dcfce7;
  --danger-bg: #450a0a;
  --danger-text: #fecaca;
  --danger-border: #7f1d1d;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

body.dark-gray {
  --bg: #181818;
  --bg-2: #222222;
  --surface: #252525;
  --surface-2: #303030;
  --text: #efefef;
  --muted: #c7c7c7;
  --border: #4a4a4a;
  --primary: #9db4ff;
  --primary-soft: #3a3a3a;
  --success-bg: #1f4a2d;
  --success-text: #d9f6e1;
  --danger-bg: #4a1f1f;
  --danger-text: #ffd7d7;
  --danger-border: #7a3b3b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.cotton-candy {
  --bg: #fdf2ff;
  --bg-2: #eefbff;
  --surface: #ffffff;
  --surface-2: #f9f4ff;
  --text: #2b2240;
  --muted: #5f5a7a;
  --border: #d9c6eb;
  --primary: #e8b0ff;
  --primary-soft: #aceaff;
  --success-bg: #dbf7ff;
  --success-text: #1f4a6e;
  --danger-bg: #ffe8f3;
  --danger-text: #7a2f57;
  --danger-border: #f2bfd8;
  --shadow: 0 10px 26px rgba(146, 95, 173, 0.16);
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
}
.page {
  max-width: 1550px;
  margin: 0 auto;
  padding: 24px;
}

.site-footer {
  margin-top: 24px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 14px;
}

.site-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}
.hero, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero {
  padding: 32px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}
.hero-brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.hero-logo {
  width: 148px;
  height: 148px;
  object-fit: contain;
  flex: 0 0 auto;
}
.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

#themeToggleBtn {
  white-space: nowrap;
  min-width: 136px;
}

#clearCacheBtn {
  white-space: nowrap;
  min-width: 136px;
}

.copy-name-btn {
  padding: 6px 8px !important;
  font-size: 13px;
  min-width: auto;
  border-radius: 8px;
}

.copy-name-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 10px;
}

.hero-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.45;
}

.hero-notice strong {
  color: var(--text);
}
h1, h2, h3 { margin-top: 0; }
p, li, label, span, div, strong, code { color: inherit; }
.panel {
  padding: 24px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 24px;
}
.left-col {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.right-col {
  min-width: 0;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
button, .file-label, select, input {
  font: inherit;
}
button, .file-label {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
}
button:hover, .file-label:hover {
  filter: brightness(1.03);
}
.file-label input {
  display: none;
}
textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  font-family: Consolas, monospace;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
}
select, input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--surface-2);
  color: var(--text);
}

select {
  background: #dbeeff;
  border-color: #9fc8ff;
  color: #163b63;
}

.target-mode-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.target-mode-pill {
  width: 96px;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  cursor: pointer;
}

.target-mode-pill:hover {
  border-color: var(--primary);
}

.target-mode-pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

body.dark .target-mode-pill.active,
body.dark-gray .target-mode-pill.active {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.16);
}

.custom-target-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.custom-target-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.custom-target-item input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 0;
  background: var(--surface-2);
  color: var(--text);
}

.custom-target-summary {
  align-items: stretch;
}

.custom-target-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.custom-target-apply-btn {
  border-radius: 12px;
  font-weight: 700;
}

@media (max-width: 560px) {
  .custom-target-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

body.dark select {
  background: #22344d;
  border-color: #446186;
  color: #e5efff;
}

body.dark-gray select {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

body.cotton-candy select {
  /*background: #aceaff;*/
  border-color: #8fdcf8;
  color: #163b63;
}
.card-list {
  display: grid;
  gap: 12px;
  max-height: 540px;
  overflow: auto;
}
.dino-card, .result-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  background: var(--surface);
}
.dino-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
body.dark .dino-card.selected,
body.dark-gray .dino-card.selected {
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}
.top-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: bold;
}
.badge.missing {
  background: var(--surface-2);
  color: transparent;
  border: 1px solid var(--border);
  min-width: 30px;
}
.badge.gray {
  background: var(--surface-2);
  color: var(--muted);
}
.badge.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}
body.dark .badge.warning,
body.dark-gray .badge.warning {
  background: #4a3210;
  color: #fde68a;
  border-color: #f59e0b;
}
.badge.mutation {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}
.color-grid, .pill-row, .coverage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
}
/*
.color-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
}
.color-pill.empty {
  background: var(--surface-2);
  opacity: 0.55;
}
.color-pill.empty .dot {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  text-shadow: none;
}
*/
.dot {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  border: 1px solid black;
}
.color-pill.disabled .dot {
  background: var(--surface-2, #888);
  border: 2px solid #e53e3e;
  color: transparent;
  text-shadow: none;
  opacity: 0.6;
  position: relative;
}
.color-pill.disabled .dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #e53e3e;
  transform: rotate(45deg);
  border-radius: 1px;
}

.color-pill.owned .dot {
  border: 2px solid #48bb78;
  box-shadow: 0 0 0 1px #48bb78;
}

.result-card + .result-card { margin-top: 16px; }
.result-card.copied-highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
  animation: copiedFlash 1.2s ease-out forwards;
}
body.dark .result-card.copied-highlight,
body.dark-gray .result-card.copied-highlight {
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
  animation: copiedFlashDark 1.2s ease-out forwards;
}
@keyframes copiedFlash {
  0%   { background: var(--primary-soft); }
  100% { background: var(--surface); }
}
@keyframes copiedFlashDark {
  0%   { background: var(--primary-soft); }
  100% { background: var(--surface); }
}
.metrics {
  color: var(--muted);
  margin: 8px 0 14px;
}
.region-list {
  display: grid;
  gap: 8px;
}
.region-item {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
}
.selected-box {
  margin: 8px 0 16px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.hidden { display: none; }
.error {
  margin-top: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  padding: 12px 14px;
  border-radius: 14px;
}

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 400px;
  word-break: break-word;
  animation: slideIn 0.3s ease-out;
  pointer-events: auto;
  cursor: default;
}

.toast.fade-out {
  animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(420px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(420px);
    opacity: 0;
  }
}

.toolbar-panel {
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
}

.toolbar button {
  background: #dbeeff;
  border-color: #9fc8ff;
  color: #163b63;
}

.toolbar button:hover {
  background: #c6e2ff;
  filter: none;
}

body.dark .toolbar button,
body.dark-gray .toolbar button {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

body.dark .toolbar button:hover,
body.dark-gray .toolbar button:hover {
  background: var(--surface-2);
  filter: brightness(1.08);
}

.toolbar button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 99;
}

#dropOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#dropOverlay.visible {
  opacity: 1;
  pointer-events: none;
}
.drop-overlay-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 90%;
  max-width: 900px;
  padding: 24px;
}
.drop-zone {
  border: 3px dashed var(--primary);
  border-radius: 24px;
  padding: 48px 32px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
  opacity: 0.6;
}
.drop-zone.active {
  opacity: 1;
  box-shadow: 0 12px 60px rgba(79, 70, 229, 0.4);
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.02);
}
.drop-overlay-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.drop-overlay-label {
  font-size: 20px;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 4px;
}
.drop-overlay-sublabel {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 100;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-body {
  display: grid;
  gap: 8px;
}

.report-row {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.report-row-small {
  padding: 1px 12px;
}

.report-row-action {
  cursor: pointer;
}

.report-row-action:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

body.dark .report-row-action:hover,
body.dark-gray .report-row-action:hover {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.16);
}

.report-row .meta {
  color: var(--muted);
  font-size: 13px;
}

.report-row-next {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.solid-next-group {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.solid-next-group-head {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

.event-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.event-pill {
  width: 88px;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  cursor: pointer;
}

.event-pill:hover {
  border-color: var(--primary);
}

.event-pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

body.dark .event-pill.active,
body.dark-gray .event-pill.active {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.16);
}

.event-pill-icon {
  font-size: 20px;
  line-height: 1;
}

.event-pill-label {
  font-size: 12px;
  font-weight: 700;
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.status-icon.success {
  color: #16a34a;
}

.status-icon.failure {
  color: #dc2626;
}

.status-tooltip {
  position: relative;
}

.status-tooltip[data-tooltip]:hover::after,
.status-tooltip[data-tooltip]:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 120;
  pointer-events: none;
}

.status-tooltip[data-tooltip]:hover::before,
.status-tooltip[data-tooltip]:focus-visible::before {
  content: "";
  position: absolute;
  left: calc(100% + 5px);
  top: 50%;
  transform: translateY(-50%);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 5px solid var(--border);
  z-index: 121;
  pointer-events: none;
}

body.dark .status-icon.success,
body.dark-gray .status-icon.success {
  color: #4ade80;
}

body.dark .status-icon.failure,
body.dark-gray .status-icon.failure {
  color: #f87171;
}
.best-match {
  margin-right: 8px;
  background: var(--success-bg);
  color: var(--success-text);
}
.target-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.count {
  color: var(--muted);
  font-size: 13px;
}

.mutation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.mutation-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mutation-toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #94a3b8;
  transition: background 0.2s ease;
  flex: 0 0 auto;
}

.mutation-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.mutation-toggle input:checked + .mutation-toggle-track {
  background: var(--primary);
}

.mutation-toggle input:checked + .mutation-toggle-track .mutation-toggle-thumb {
  transform: translateX(18px);
}

.mutation-toggle input:focus-visible + .mutation-toggle-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.mutation-toggle-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.scroll-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 90;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.scroll-to-top:hover {
  filter: brightness(1.1);
}

.scroll-to-top.hidden {
  opacity: 0;
  visibility: hidden;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .hero-brand { align-items: center; }
}

@media (max-width: 640px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
