:root {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #16211d;
  --muted: #63706a;
  --line: #d8e0dc;
  --accent: #0f7a5f;
  --accent-2: #b83232;
  --soft: #e7f2ee;
  --shadow: 0 14px 38px rgba(22, 33, 29, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(15, 122, 95, 0.12), transparent 34%),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.mobile-text {
  display: none;
}

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

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--ink);
  text-decoration: none;
}

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

.brand strong {
  line-height: 1.05;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 72% 22%, rgba(255, 255, 255, 0.55), transparent 24%),
    linear-gradient(145deg, #12392f, #1aa67d);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.logo-mark {
  background: #fff;
  overflow: hidden;
  border: 1px solid rgba(15, 122, 95, 0.16);
  box-shadow: 0 6px 16px rgba(15, 122, 95, 0.12);
}

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

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 28px;
  align-items: stretch;
}

.hero-copy {
  padding: 34px 0 12px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 10px;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
}

.admin-title {
  font-size: clamp(28px, 3vw, 42px);
}

.subtitle {
  margin: 18px 0 0;
  max-width: 650px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.club-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.club-strip span {
  border: 1px solid rgba(15, 122, 95, 0.2);
  background: rgba(255, 255, 255, 0.7);
  color: #1d5d4e;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.club-footer {
  margin-top: 28px;
  padding: 8px 0 2px;
}

.club-footer .club-strip {
  justify-content: center;
  margin-top: 0;
}

.club-footer .club-strip span {
  border: 0;
  background: transparent;
  color: #9aa5a0;
  border-radius: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}

.club-footer .club-strip span + span::before {
  content: "·";
  margin-right: 10px;
  color: #c1cac5;
}

.upload-panel,
.result-panel,
.admin-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.upload-panel {
  padding: 22px;
}

.dropzone {
  border: 1px dashed #91aaa0;
  background: var(--soft);
  border-radius: 8px;
  min-height: 210px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  transition: border-color 0.18s, background 0.18s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #ddefe8;
}

.dropzone strong {
  display: block;
  font-size: 18px;
  margin-bottom: 8px;
}

.dropzone span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.selected-preview-panel {
  border: 1px solid var(--line);
  background: #f8faf8;
  border-radius: 8px;
  overflow: hidden;
}

.selected-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.selected-preview-head strong {
  color: var(--ink);
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-preview-panel img {
  display: block;
  width: 100%;
  height: min(52vh, 520px);
  object-fit: contain;
  background: #fff;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  background: #e8eeeb;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  background: var(--accent-2);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.status {
  margin-top: 14px;
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.result-panel {
  margin-top: 28px;
  padding: 22px;
  display: none;
}

.result-panel.active {
  display: block;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.image-box {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.image-box header {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.image-box img {
  display: block;
  width: 100%;
  max-height: 720px;
  object-fit: contain;
  background: #fff;
}

.feedback {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.feedback textarea {
  min-height: 42px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

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

.result-head {
  align-items: flex-start;
}

.inline-status {
  margin: 4px 0 0;
}

.compare-switch {
  position: relative;
  width: 188px;
  height: 46px;
  border-radius: 999px;
  padding: 4px;
  background: #e4ece8;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  color: var(--muted);
  font-weight: 900;
  overflow: hidden;
}

.compare-switch span {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 13px;
}

.compare-switch i {
  position: absolute;
  inset: 4px auto 4px 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(15, 122, 95, 0.22);
  transition: transform 0.22s ease;
}

.compare-switch[aria-pressed="false"] span:first-child,
.compare-switch[aria-pressed="true"] span:nth-child(2) {
  color: #fff;
}

.compare-switch[aria-pressed="true"] i {
  transform: translateX(100%);
}

.single-compare {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, #f9fbfa 25%, transparent 25%),
    linear-gradient(-45deg, #f9fbfa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f9fbfa 75%),
    linear-gradient(-45deg, transparent 75%, #f9fbfa 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.single-compare:focus {
  outline: 3px solid rgba(15, 122, 95, 0.28);
  outline-offset: 3px;
}

.compare-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  opacity: 0;
  transform: scale(0.995);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.compare-image.is-visible {
  opacity: 1;
  transform: scale(1);
}

.compare-badge {
  position: absolute;
  z-index: 3;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(22, 33, 29, 0.72);
  color: #fff;
  backdrop-filter: blur(8px);
  font-weight: 900;
}

.compare-badge small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.record-card > div:last-child {
  padding: 12px;
}

.record-card p {
  margin: 6px 0 0;
}

.record-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.record-images img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: #fff;
}

.admin-panel {
  padding: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar input[type="search"] {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.checkline {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1060px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: #f0f5f2;
  color: #31423b;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr.deleted {
  opacity: 0.58;
}

.thumbs {
  display: flex;
  gap: 8px;
  background: transparent;
  padding: 0;
}

.thumbs img {
  width: 92px;
  height: 122px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.rating.good {
  color: var(--accent);
  font-weight: 800;
}

.rating.bad {
  color: var(--accent-2);
  font-weight: 800;
}

.empty {
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.feedback-cell {
  max-width: 260px;
  white-space: pre-wrap;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(1100px, calc(100vw - 32px));
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(8, 18, 15, 0.5);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  padding: 16px;
}

.modal-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-images img {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #f8faf8;
}

@media (max-width: 860px) {
  .hero,
  .modal-images,
  .feedback {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .userbar,
  .actions {
    width: 100%;
  }

  .userbar {
    width: auto;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .userbar .btn {
    flex: 0 0 auto;
  }

  .userbar #userState,
  .userbar #adminLink,
  .userbar #devLoginBtn,
  .userbar #logoutBtn {
    display: none;
  }

  .desktop-text {
    display: none;
  }

  .mobile-text {
    display: inline;
  }

  #loginBtn {
    min-width: 74px;
    width: auto;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
  }

  .hero-copy {
    padding-top: 10px;
  }

  .upload-panel,
  .result-panel,
  .admin-panel {
    border-radius: 14px;
  }

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

  .compare-switch {
    width: 100%;
  }

  .single-compare {
    min-height: min(72vh, 540px);
  }

  .feedback textarea {
    min-height: 88px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  h1 {
    font-size: 38px;
  }

  .subtitle {
    font-size: 15px;
  }

  .topbar {
    gap: 10px;
    padding-bottom: 18px;
  }

  .brand {
    min-width: 0;
  }

  .brand strong {
    max-width: 168px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dropzone {
    min-height: 160px;
  }

  .actions .btn,
  .feedback .btn,
  .toolbar .btn {
    width: 100%;
  }

  .club-strip span {
    flex: 1 1 auto;
    text-align: center;
  }

  .single-compare {
    min-height: 430px;
  }

  .compare-badge {
    left: 10px;
    top: 10px;
    max-width: calc(100% - 20px);
  }

  .record-images img {
    height: 150px;
  }
}
