:root {
  --yellow: #f6c344;
  --navy: #1b2a41;
  --sky: #a8d6ff;
  --sand: #f4f8ff;
  --ink: #0f172a;
  --muted: #667085;
  --border: #d7dce5;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--sky);
  color: var(--ink);
  min-height: 100vh;
}

.page {
  max-width: 1260px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo img {
  height: 46px;
  width: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.logo-tag {
  background: var(--yellow);
  color: var(--navy);
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.titles h1 {
  margin: 6px 0;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.titles .lede {
  margin: 0;
  max-width: 600px;
  color: var(--muted);
}

.icon-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.badge {
  background: var(--yellow);
  color: var(--navy);
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  background: var(--sand);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone.is-dragover {
  border-color: var(--navy);
  background: #e9f2ff;
}

.dropzone__visual {
  display: grid;
  place-items: center;
  gap: 8px;
}

.dropzone__icon {
  font-size: 2rem;
}

.dropzone__title {
  margin: 0;
  font-weight: 700;
}

.dropzone__hint {
  margin: 0;
  color: var(--muted);
}

.dropzone__file {
  margin-top: 12px;
  color: var(--navy);
  font-weight: 600;
}

.ghost-btn {
  margin-top: 10px;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ghost-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0 8px;
  flex-wrap: wrap;
}

.primary-btn {
  background: linear-gradient(135deg, var(--navy), #213556);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.status {
  color: var(--muted);
  min-height: 24px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  display: none;
}

.spinner.is-active {
  display: inline-block;
}

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

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.is-open {
  display: flex;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal__content {
  position: relative;
  background: #fff;
  padding: 20px;
  border-radius: 14px;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
  z-index: 1;
  display: grid;
  gap: 10px;
}

.modal__content input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.result {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 18px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  align-items: start;
}

.result__media {
  display: grid;
  gap: 12px;
  align-content: start;
}

.result__thumb {
  width: 100%;
  height: auto;
  min-height: 400px;
  max-height: 80vh;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(168, 214, 255, 0.5), rgba(27, 42, 65, 0.06));
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result__thumb img {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.creative {
  display: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.creative__caption {
  margin: 0;
  font-style: italic;
  color: var(--navy);
  position: relative;
}

.creative__caption::before,
.creative__caption::after {
  color: var(--muted);
  font-style: normal;
}

.creative__caption::before {
  content: "\"";
  margin-right: 4px;
}

.creative__caption::after {
  content: "\"";
  margin-left: 4px;
}

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

.result__labels h3 {
  margin: 0 0 8px;
}

.breedmix {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.pill {
  background: var(--sand);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.breedmix__list {
  display: grid;
  gap: 8px;
}

.breedmix__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.breedmix__row .label {
  font-weight: 700;
  color: var(--navy);
}

.breedmix__row .value {
  color: var(--muted);
}

.breedmix__reason {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.agepanel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.agepanel__details {
  display: grid;
  gap: 8px;
}

.agepanel__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.agepanel__row .label {
  font-weight: 700;
  color: var(--navy);
}

.agepanel__row .value {
  color: var(--muted);
}

.scorepanel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.scorepanel__details {
  display: grid;
  gap: 8px;
}

.scorepanel__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.scorepanel__row .label {
  font-weight: 700;
  color: var(--navy);
}

.scorepanel__row .value {
  color: var(--muted);
}

.healthpanel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.healthpanel__details {
  display: grid;
  gap: 8px;
}

.healthpanel__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.healthpanel__row .label {
  font-weight: 700;
  color: var(--navy);
}

.healthpanel__row .value {
  color: var(--muted);
}

.imagepanel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.imagepanel__details {
  display: grid;
  gap: 8px;
}

.imagepanel__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.imagepanel__row .label {
  font-weight: 700;
  color: var(--navy);
}

.imagepanel__row .value {
  color: var(--muted);
}

.meta {
  color: var(--muted);
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.table-wrapper {
  overflow: auto;
}

#analysisTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

#analysisTable th,
#analysisTable td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

#analysisTable th {
  background: #f8fafc;
  color: var(--navy);
}

#analysisBody tr:hover {
  background: #fdf7e9;
}

.confidence {
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-left {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

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

  .actions {
    align-items: flex-start;
  }
}

/* Ribbon Bar */
.ribbon-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.ribbon {
  flex: 1;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 4px;
  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ribbon::-webkit-scrollbar {
  display: none;
}

.ribbon-item {
  flex: 0 0 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
  background: var(--sand);
}

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

.ribbon-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ribbon-item.is-pending img,
.ribbon-item.is-uploading img {
  opacity: 0.5;
}

.ribbon-item.is-active {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(27, 42, 65, 0.1);
}

.ribbon-item.is-uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  place-items: center;
}

/* Spinner for ribbon item */
.ribbon-item.is-uploading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -10px;
  /* Half of height */
  margin-left: -10px;
  /* Half of width */
  width: 20px;
  height: 20px;
  border: 2px solid var(--navy);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 2;
}

.ribbon-nav {
  background: var(--sand);
  border: 1px solid var(--border);
  color: var(--navy);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.2rem;
  line-height: 1;
  padding-bottom: 2px;
}

.ribbon-nav:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* Child item style */
.ribbon-item.is-child {
  border: 2px dashed var(--navy);
  opacity: 0.9;
}

/* Error item style */
.ribbon-item.is-error {
  border-color: #b91c1c;
  border-width: 2px;
}