:root {
  color-scheme: light dark;
  --bg: #f5f7f8;
  --page-top: #ffffff;
  --surface: #ffffff;
  --surface-strong: #eef3f5;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --header-bg: rgba(255, 255, 255, 0.88);
  --text: #18242b;
  --muted: #63717a;
  --line: #d9e1e5;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --blue: #2563eb;
  --danger: #b4233a;
  --amber: #a15c07;
  --metric-bg: linear-gradient(180deg, #f8fbfb 0%, #eef5f4 100%);
  --upload-bg: linear-gradient(135deg, #ffffff 0%, #edf6f4 100%);
  --upload-active-bg: #e3f4f0;
  --code-bg: #102128;
  --code-text: #dff7f2;
  --notice-bg: #fff7d8;
  --notice-border: #e0cb8b;
  --shadow: 0 18px 50px rgba(18, 36, 43, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1418;
    --page-top: #101b20;
    --surface: #142126;
    --surface-strong: #1b2b31;
    --panel-bg: rgba(20, 33, 38, 0.94);
    --header-bg: rgba(14, 23, 27, 0.9);
    --text: #e6eef1;
    --muted: #9aaab1;
    --line: #2b3d44;
    --accent: #2dd4bf;
    --accent-strong: #14b8a6;
    --blue: #60a5fa;
    --danger: #fb7185;
    --amber: #fbbf24;
    --metric-bg: linear-gradient(180deg, #19282e 0%, #132126 100%);
    --upload-bg: linear-gradient(135deg, #16252a 0%, #102026 100%);
    --upload-active-bg: #173b36;
    --code-bg: #071216;
    --code-text: #d8fff8;
    --notice-bg: #332812;
    --notice-border: #8a6a22;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 0%, rgba(15, 118, 110, 0.16), transparent 32rem),
    linear-gradient(180deg, var(--page-top) 0%, var(--bg) 42%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

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

.nav-shell {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.main-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
}

.main-nav a:hover,
.main-nav a.is-active {
  background: var(--surface-strong);
  color: var(--text);
}

.account {
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.shell {
  padding: 36px 0 64px;
}

.view,
.auth-panel,
.feature-strip article {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-view {
  min-height: 440px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: stretch;
  padding: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-copy {
  align-self: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 0.98;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
}

.hero-text {
  max-width: 680px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

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

.hero-panel {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--metric-bg);
}

.metric.wide {
  grid-column: 1 / -1;
  min-height: 120px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  font-size: 28px;
  line-height: 1.1;
}

.feature-strip {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.feature-strip article {
  padding: 20px;
}

.feature-icon {
  width: 40px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.feature-strip p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-panel {
  margin-top: 18px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 780;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.upload-zone {
  position: relative;
  min-height: 230px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  margin: 0 20px 20px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--upload-bg);
}

.upload-zone.is-dragging {
  border-color: var(--accent);
  background: var(--upload-active-bg);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-copy {
  display: grid;
  gap: 8px;
}

.upload-copy strong {
  font-size: 32px;
  line-height: 1.1;
}

.upload-copy span,
.image-detail,
.token-detail {
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-height: 24px;
  margin: 0 22px 16px;
  color: var(--amber);
  font-size: 14px;
}

.upload-progress {
  margin: 0 20px 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--blue) 100%);
  transition: width 220ms ease;
}

.upload-progress.is-active .progress-bar {
  background-size: 180% 100%;
  animation: progress-sheen 1.2s linear infinite;
}

@keyframes progress-sheen {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 180% 50%;
  }
}

.upload-results {
  margin: 0 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-subhead {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.section-subhead h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.upload-result-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.upload-result-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.upload-result-row .icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.upload-result-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--surface);
}

.upload-result-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-result-detail {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.gallery-controls {
  margin: 0 20px 16px;
  display: grid;
  gap: 12px;
}

.segmented {
  width: fit-content;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segment,
.filter-tag {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
  font-weight: 780;
}

.segment.is-active,
.filter-tag.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(18, 36, 43, 0.08);
}

.filter-block {
  display: grid;
  gap: 8px;
}

.filter-block span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  border: 1px solid var(--line);
  background: var(--surface);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 0 20px 20px;
}

.image-grid.is-list {
  grid-template-columns: 1fr;
}

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

.image-grid.is-list .image-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 240px;
  align-items: stretch;
}

.thumb-link {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-strong);
}

.thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.image-grid.is-list .thumb-link {
  aspect-ratio: auto;
  min-height: 76px;
}

.image-meta {
  min-height: 74px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

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

.image-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.image-grid.is-list .image-actions {
  border-top: 0;
  border-left: 1px solid var(--line);
}

.icon-button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.icon-button:last-child {
  border-right: 0;
}

.delete-image,
.revoke-token {
  color: var(--danger);
}

.empty {
  margin: 0 20px 20px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.token-form {
  display: flex;
  gap: 8px;
}

.token-form input {
  width: min(260px, 42vw);
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.api-example {
  margin: 0 20px 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
}

.api-example code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.token-secret {
  margin: 0 20px 14px;
  padding: 12px;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--notice-bg);
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.token-list {
  padding: 0 20px 20px;
  display: grid;
  gap: 8px;
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .nav-shell {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 0;
  }

  .main-nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .account {
    min-width: 0;
    justify-content: flex-start;
  }

  .hero-view {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .feature-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-shell,
  .shell {
    width: min(100vw - 20px, 1180px);
  }

  .shell {
    padding-top: 18px;
  }

  .hero-view,
  .section-head,
  .auth-panel,
  .upload-zone {
    align-items: stretch;
  }

  .hero-view {
    padding: 22px;
  }

  .hero-panel,
  .upload-zone {
    grid-template-columns: 1fr;
  }

  .image-grid.is-list .image-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .image-grid.is-list .image-actions {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .section-head,
  .auth-panel {
    flex-direction: column;
  }

  .upload-copy strong {
    font-size: 24px;
  }

  .token-form {
    width: 100%;
    display: grid;
  }

  .token-form input {
    width: 100%;
  }

  .upload-result-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .upload-result-row .icon-button {
    grid-column: 1 / -1;
  }
}
