:root {
  color-scheme: light;
  --ink: #182018;
  --muted: #6b7569;
  --paper: #f5f4ed;
  --card: #fffef9;
  --line: #deddd3;
  --green: #315c42;
  --green-dark: #234331;
  --lime: #d9f99d;
  --red: #9c3d35;
  --shadow: 0 18px 50px rgba(39, 55, 41, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 8%, rgba(217, 249, 157, .42), transparent 25rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 74px;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid rgba(49, 92, 66, .14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 244, 237, .78);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 19px; font-weight: 750; letter-spacing: -.03em; }
.brand-mark { width: 27px; height: 27px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; transform: rotate(2deg); }
.brand-mark i { display: block; background: var(--green); border-radius: 2px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: #91b778; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #58a669; box-shadow: 0 0 0 4px rgba(88, 166, 105, .13); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 74px 0 90px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin-bottom: 54px; }
.eyebrow, .section-label { margin: 0 0 12px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(25px, 5.3vw, 68px); font-weight: 500; line-height: 1.06; letter-spacing: -.055em; white-space: nowrap; }
.subtitle { max-width: 620px; margin: 22px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.count-card { flex: 0 0 auto; min-width: 150px; padding: 20px 22px; border-left: 1px solid var(--line); }
.count-card strong { display: block; font-family: Georgia, serif; font-size: 42px; line-height: 1; color: var(--green); }
.count-card span { display: block; margin-top: 9px; color: var(--muted); font-size: 12px; }

.upload-panel { padding: clamp(24px, 4vw, 44px); background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.panel-head, .library-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 29px; font-weight: 500; letter-spacing: -.025em; }
.token-field { display: grid; gap: 6px; width: min(260px, 45%); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.token-field input { width: 100%; padding: 10px 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #faf9f3; outline: none; }
.token-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(49, 92, 66, .1); }

.drop-zone { min-height: 210px; padding: 32px; border: 1.5px dashed #aeb7a8; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 24px; text-align: left; background: #faf9f3; transition: border-color .2s, background .2s, transform .2s; cursor: pointer; outline: none; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragging { border-color: var(--green); background: #f4f8eb; transform: translateY(-1px); }
.upload-symbol { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: var(--green-dark); font-size: 27px; font-weight: 600; }
.drop-zone strong { display: block; font-size: 17px; }
.drop-zone p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.primary-button { padding: 11px 17px; border: 0; border-radius: 9px; color: #fff; background: var(--green); font-weight: 700; font-size: 13px; cursor: pointer; transition: background .2s, transform .2s; }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:focus-visible, button:focus-visible { outline: 3px solid rgba(49, 92, 66, .22); outline-offset: 2px; }
.progress-wrap { margin-top: 20px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: #e8e8df; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .2s; }
.notice { min-height: 20px; margin: 14px 0 -8px; color: var(--green); font-size: 13px; }
.notice.error { color: var(--red); }

.library { margin-top: 68px; }
.text-button { border: 0; border-bottom: 1px solid var(--ink); padding: 3px 0; background: transparent; cursor: pointer; font-size: 13px; }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.image-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--card); transition: transform .2s, box-shadow .2s; }
.image-card:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(39, 55, 41, .1); }
.image-button { display: block; width: 100%; aspect-ratio: 1 / .82; padding: 0; border: 0; overflow: hidden; background: #e6e7df; cursor: zoom-in; }
.image-button img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .35s; }
.image-card:hover img { transform: scale(1.025); }
.card-body { padding: 13px 14px 14px; }
.card-meta { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.file-size { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.card-actions { display: flex; justify-content: space-between; margin-top: 13px; padding-top: 11px; border-top: 1px solid #ecebe3; }
.card-actions button { border: 0; padding: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.card-actions button:hover { color: var(--ink); }
.card-actions .delete-button:hover { color: var(--red); }
.empty-state, .loading-state { padding: 76px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
.empty-state span { display: block; font-size: 37px; color: #aab2a5; transform: rotate(4deg); }
.empty-state h3 { margin: 14px 0 5px; color: var(--ink); }
.empty-state p { margin: 0; font-size: 13px; }
.loading-state { font-size: 13px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 30px; color: var(--muted); font-size: 12px; }
.pagination button { padding: 8px 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); cursor: pointer; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.preview-dialog { width: min(920px, calc(100% - 30px)); max-height: 90vh; padding: 0; border: 0; border-radius: 16px; background: #101510; box-shadow: 0 30px 90px rgba(0, 0, 0, .4); overflow: hidden; }
.preview-dialog::backdrop { background: rgba(18, 25, 19, .75); backdrop-filter: blur(6px); }
.preview-dialog img { width: 100%; max-height: calc(90vh - 76px); display: block; object-fit: contain; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; color: white; background: rgba(0, 0, 0, .58); font-size: 25px; cursor: pointer; }
.dialog-meta { min-height: 66px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #e9eee9; }
.dialog-meta code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

@media (max-width: 900px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .hero { align-items: center; }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 20px; }
  .status { font-size: 0; }
  main { width: min(100% - 28px, 1180px); padding-top: 48px; }
  .hero { display: block; margin-bottom: 36px; }
  .count-card { margin-top: 28px; padding: 0; border: 0; display: flex; align-items: baseline; gap: 9px; }
  .count-card strong { font-size: 30px; }
  .panel-head { display: block; }
  .token-field { width: 100%; margin-top: 20px; }
  .drop-zone { min-height: 240px; flex-direction: column; gap: 14px; text-align: center; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 11px; }
  .image-button { aspect-ratio: 1; }
}

@media (max-width: 420px) {
  .gallery { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
