/*
 * Flower adapts the beveled button and filter-control treatment from
 * https://zh.minecraft.wiki/w/Minecraft_Wiki/styles.css (CC BY-NC-SA 3.0).
 * Changes: adapted colors, sizing, focus states, and layout for Flower.
 * The adapted button and filter styles are shared under the same license.
 * Panel and dialog visual references: HuanChen-Wiki MediaWiki_Common.css.
 */
:root {
  color-scheme: light;
  --page: #e9eee6;
  --page-soft: #f1f3ed;
  --surface: #fbfcf8;
  --surface-raised: #ffffff;
  --surface-inset: #e2e8de;
  --line: #c8d1c2;
  --line-strong: #858f80;
  --text: #273129;
  --muted: #667266;
  --faint: #8c978a;
  --green: #3f7d3b;
  --green-hover: #32692f;
  --green-pressed: #285527;
  --green-pale: #e1edda;
  --green-shadow: #9cb696;
  --orange: #b87738;
  --danger: #a64137;
  --focus: #327bb1;
  --shadow: rgb(39 49 41 / 10%);
  --check-a: #e1e7dc;
  --check-b: #f2f4ee;
  --font: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #1c211e;
  --page-soft: #222925;
  --surface: #2b322d;
  --surface-raised: #313a34;
  --surface-inset: #202622;
  --line: #48564a;
  --line-strong: #68766a;
  --text: #e6ece4;
  --muted: #b3bdb1;
  --faint: #879488;
  --green: #6ea35f;
  --green-hover: #5b914d;
  --green-pressed: #47733e;
  --green-pale: #344533;
  --green-shadow: #263725;
  --orange: #e1a765;
  --danger: #f09488;
  --focus: #84bff0;
  --shadow: rgb(0 0 0 / 25%);
  --check-a: #313b34;
  --check-b: #252d28;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 20rem;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: var(--green); }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-160%);
  padding: 0.625rem 0.875rem;
  border: 0.125rem solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem clamp(1rem, 4vw, 4rem);
  border-bottom: 0.125rem solid var(--line);
  background: var(--surface);
}
.brand, .footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  text-decoration: none;
}
.brand-name { font-size: 1.25rem; font-weight: 760; letter-spacing: -0.06em; }
.brand-dot { color: var(--green); }
.brand-mark {
  position: relative;
  display: inline-block;
  width: 1.625rem;
  height: 1.625rem;
  flex: 0 0 1.625rem;
  transform: rotate(-10deg);
}
.brand-mark i {
  position: absolute;
  width: 0.625rem;
  height: 0.625rem;
  border: 0.125rem solid var(--green);
  background: var(--green-pale);
}
.brand-mark i:nth-child(1) { top: 0.0625rem; left: 0.5rem; border-radius: 70% 20% 70% 20%; transform: rotate(-24deg); }
.brand-mark i:nth-child(2) { top: 0.5rem; right: 0.0625rem; border-radius: 20% 70% 20% 70%; transform: rotate(24deg); }
.brand-mark i:nth-child(3) { bottom: 0.0625rem; left: 0.5rem; border-radius: 20% 70% 20% 70%; transform: rotate(-24deg); }
.brand-mark i:nth-child(4) { top: 0.5rem; left: 0.0625rem; border-radius: 70% 20% 70% 20%; transform: rotate(24deg); }
.brand-mark.small { transform: scale(0.78) rotate(-10deg); transform-origin: left center; margin-right: -0.25rem; }
.header-tools, .auth-actions { display: flex; align-items: center; }
.header-tools { gap: 0.75rem; }
.icon-button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  border: 0.125rem solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { border-color: var(--line); background: var(--page-soft); color: var(--text); }
.theme-glyph { font-size: 1.1rem; line-height: 1; }
.theme-label { font-size: 0.8125rem; }
.header-divider { width: 1px; height: 1.625rem; background: var(--line); }
.auth-actions { gap: 0.625rem; }
.auth-status { max-width: 10rem; overflow: hidden; color: var(--muted); font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }

.page-shell { width: min(78rem, calc(100% - 2rem)); margin: 0 auto; }
.hero {
  position: relative;
  min-height: 14rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin: 1.375rem 0 1.125rem;
  padding: clamp(1.25rem, 4vw, 2.75rem);
  overflow: hidden;
  border: 0.125rem solid var(--line-strong);
  background: var(--surface);
  box-shadow: 0 0.25rem 0 var(--line), inset 0 0.125rem var(--surface-raised);
}
.hero::before {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(135deg, transparent 48%, var(--page-soft) 48%, var(--page-soft) 49%, transparent 49%);
  background-size: 1.25rem 1.25rem;
  content: "";
  opacity: 0.64;
  pointer-events: none;
}
.hero-copy, .hero-meta { position: relative; z-index: 1; }
.hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.12; letter-spacing: -0.055em; }
.hero-stamp {
  position: absolute;
  top: 50%;
  right: clamp(2rem, 10vw, 8rem);
  width: 9rem;
  height: 9rem;
  transform: translateY(-50%);
  opacity: 0.42;
}
.stamp-ring { position: absolute; inset: 0.5rem; border: 0.125rem solid var(--green); border-radius: 50%; }
.stamp-ring::before, .stamp-ring::after { position: absolute; inset: 0.625rem; border: 0.0625rem dashed var(--green); border-radius: 50%; content: ""; }
.stamp-ring::after { inset: 1.1875rem; border-style: solid; }
.stamp-leaf { position: absolute; top: 1.125rem; left: 3.5rem; width: 2rem; height: 3.5rem; border: 0.125rem solid var(--green); border-radius: 100% 0 100% 0; background: var(--green-pale); transform-origin: bottom center; }
.leaf-one { transform: rotate(-33deg); }
.leaf-two { transform: rotate(33deg) scaleX(-1); }
.stamp-center { position: absolute; top: 4.375rem; left: 4.125rem; width: 0.75rem; height: 0.75rem; border: 0.125rem solid var(--green); border-radius: 50%; background: var(--green); }
.hero-meta {
  position: absolute;
  right: 1.25rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 60%;
  color: var(--muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}
.hero-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-light, .sync-dot { width: 0.4375rem; height: 0.4375rem; flex: 0 0 0.4375rem; border-radius: 50%; background: var(--faint); }
.status-light.is-ready, .sync-state.is-ready .sync-dot { background: var(--green); box-shadow: 0 0 0 0.1875rem var(--green-pale); }
.status-light.is-error, .sync-state.is-error .sync-dot { background: var(--danger); }
.meta-separator { color: var(--line-strong); }

.main-nav {
  min-height: 3.5rem;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  border: 0.125rem solid var(--line-strong);
  border-bottom: 0;
  background: var(--surface-inset);
}
.nav-tabs { min-width: 0; display: flex; align-items: stretch; }
.nav-tab {
  position: relative;
  min-width: 11.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  border: 0;
  border-right: 0.125rem solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.nav-tab:hover { background: var(--surface); color: var(--text); }
.nav-tab.is-active { background: var(--surface); color: var(--text); }
.nav-tab.is-active::after { position: absolute; right: 0; bottom: -0.125rem; left: 0; height: 0.1875rem; background: var(--green); content: ""; }
.tab-index { color: var(--faint); font-size: 0.625rem; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.tab-count { min-width: 1.5rem; padding: 0.0625rem 0.3125rem; border: 0.0625rem solid var(--line); color: var(--muted); font-size: 0.6875rem; line-height: 1.35; text-align: center; }
.tab-lock { color: var(--green); font-size: 0.875rem; }
.nav-tools { display: flex; align-items: center; gap: 0.875rem; padding: 0.375rem 0.75rem; }
.sync-state { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.sync-state.is-running .sync-dot { animation: pulse 0.9s ease-in-out infinite alternate; background: var(--orange); }
.sync-icon { display: inline-block; font-size: 1rem; line-height: 0.8; }

.content-panel {
  min-height: 28rem;
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 0.125rem solid var(--line-strong);
  background: var(--surface);
  box-shadow: inset 0.0625rem 0.0625rem var(--surface-raised), 0 0.25rem 0 var(--line);
}
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; padding-bottom: 1.125rem; border-bottom: 0.0625rem solid var(--line); }
.panel-heading h2 { margin: 0.375rem 0 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.035em; }
.filter-bar { display: flex; align-items: center; gap: 0.625rem; margin: 1.125rem 0; }
.search-field {
  min-width: 0;
  min-height: 2.875rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 0.75rem;
  border: 0.125rem solid var(--line-strong);
  background: var(--surface-inset);
  box-shadow: inset 0 0.125rem var(--shadow);
}
.search-field:focus-within { outline: 0.125rem solid var(--focus); outline-offset: 0.0625rem; }
.filter-bar > .search-field { flex: 1 1 28rem; }
.search-icon { position: relative; width: 0.8125rem; height: 0.8125rem; flex: 0 0 0.8125rem; border: 0.125rem solid var(--muted); border-radius: 50%; }
.search-icon::after { position: absolute; right: -0.3125rem; bottom: -0.1875rem; width: 0.375rem; height: 0.125rem; background: var(--muted); content: ""; transform: rotate(45deg); transform-origin: left; }
.search-field input { width: 100%; min-width: 0; padding: 0.625rem 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-field input::placeholder { color: var(--faint); opacity: 1; }
.search-hint { display: none; color: var(--faint); font-size: 0.75rem; }
.select-field { position: relative; min-width: 11rem; }

/* Adapted control geometry follows the attributed Wiki button and sort styles above. */
.button, .select-field input, .select-field select {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem 0.75rem;
  border: 0.125rem solid var(--line-strong);
  border-radius: 0;
  background: var(--page-soft);
  box-shadow: inset 0 -0.3125rem var(--line), inset 0.125rem 0.125rem var(--surface-raised), inset -0.125rem -0.4375rem var(--line);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.1s, box-shadow 0.1s, transform 0.1s;
}
.button:hover:enabled, .select-field input:hover, .select-field select:hover { background: var(--surface-inset); }
.button:active:enabled, .select-field input:active, .select-field select:active { padding-top: 0.625rem; padding-bottom: 0.625rem; background: var(--surface-inset); box-shadow: inset 0.125rem 0.125rem var(--line), inset -0.125rem -0.125rem var(--surface-raised); }
.button-primary { border-color: var(--green-pressed); background: var(--green); box-shadow: inset 0 -0.3125rem var(--green-shadow), inset 0.125rem 0.125rem rgb(255 255 255 / 35%), inset -0.125rem -0.4375rem rgb(0 0 0 / 13%); color: #fff; }
.button-primary:hover:enabled { background: var(--green-hover); }
.button-primary:active:enabled { background: var(--green-pressed); box-shadow: inset 0.125rem 0.125rem rgb(255 255 255 / 22%); }
.button-quiet { background: transparent; box-shadow: none; }
.button-quiet:hover:enabled { background: var(--page-soft); }
.button-outline { background: var(--surface); }
.button-small { min-height: 2.375rem; padding: 0.375rem 0.6875rem 0.5625rem; font-size: 0.75rem; }
.button-small:active:enabled { padding-top: 0.4375rem; padding-bottom: 0.4375rem; }
.select-field input, .select-field select {
  width: 100%;
  justify-content: flex-start;
  padding-right: 2rem;
  color-scheme: inherit;
  text-align: left;
}
.select-field input { outline: 0; }
.select-field input::placeholder { color: var(--muted); opacity: 1; }
.select-field select { appearance: none; }
.select-chevron { position: absolute; top: 50%; right: 0.8125rem; width: 0.5rem; height: 0.5rem; border-right: 0.125rem solid var(--muted); border-bottom: 0.125rem solid var(--muted); pointer-events: none; transform: translateY(-70%) rotate(45deg); }
.result-count { min-width: 4.5rem; color: var(--muted); font-size: 0.75rem; text-align: right; white-space: nowrap; }
.text-button { padding: 0.375rem 0.25rem; border: 0; background: transparent; color: var(--green); font-size: 0.75rem; font-weight: 700; text-decoration: underline; text-underline-offset: 0.1875rem; cursor: pointer; }
.text-button:hover { color: var(--green-hover); }

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border: 0.125rem solid var(--line);
  background: var(--green-pale);
  color: var(--muted);
  font-size: 0.8125rem;
}
.selection-bar strong { color: var(--text); font-variant-numeric: tabular-nums; }
.selection-actions { display: flex; align-items: center; gap: 0.875rem; }
.texture-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.875rem; }
.texture-card {
  min-width: 0;
  overflow: hidden;
  border: 0.125rem solid var(--line);
  background: var(--surface-raised);
  box-shadow: inset 0.0625rem 0.0625rem var(--surface-raised), 0 0.125rem 0 var(--line);
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.texture-card:hover { border-color: var(--green); transform: translateY(-0.125rem); box-shadow: inset 0.0625rem 0.0625rem var(--surface-raised), 0 0.25rem 0 var(--green-shadow); }
.texture-card.is-selected { border-color: var(--green); box-shadow: 0 0 0 0.125rem var(--green-pale), 0 0.1875rem 0 var(--green); }
.texture-card-head { min-height: 2.75rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.625rem 0.375rem; }
.texture-select { width: 1.125rem; height: 1.125rem; flex: 0 0 1.125rem; margin: 0; accent-color: var(--green); cursor: pointer; }
.texture-category { min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.6875rem; text-overflow: ellipsis; white-space: nowrap; }
.texture-preview {
  width: 100%;
  aspect-ratio: 1 / 0.82;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 1rem;
  border: 0;
  border-block: 0.0625rem solid var(--line);
  background-color: var(--surface-inset);
  background-image: linear-gradient(45deg, var(--check-a) 25%, transparent 25%), linear-gradient(-45deg, var(--check-a) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--check-a) 75%), linear-gradient(-45deg, transparent 75%, var(--check-a) 75%);
  background-size: 1rem 1rem;
  background-position: 0 0, 0 0.5rem, 0.5rem -0.5rem, -0.5rem 0;
  cursor: zoom-in;
}
.texture-preview img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.preview-placeholder { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0.125rem solid var(--line-strong); color: var(--muted); font-size: 1.25rem; }
.texture-info { min-width: 0; padding: 0.75rem 0.75rem 0.875rem; }
.texture-name { display: block; overflow: hidden; margin: 0; font-size: 0.875rem; font-weight: 750; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.texture-filename { display: block; overflow: hidden; margin-top: 0.25rem; color: var(--muted); font: 0.6875rem/1.4 ui-monospace, "Cascadia Code", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.texture-path { display: block; overflow: hidden; margin-top: 0.25rem; color: var(--faint); font-size: 0.625rem; text-overflow: ellipsis; white-space: nowrap; }
.texture-badges { min-height: 1.75rem; display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; margin-top: 0.5rem; }
.badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.375rem; border: 0.0625rem solid var(--line); background: var(--page-soft); color: var(--muted); font-size: 0.625rem; line-height: 1.3; }
.badge-converted { border-color: #d5b48e; background: color-mix(in srgb, var(--orange) 10%, var(--surface)); color: var(--orange); }
.badge-mers { border-color: var(--green); background: var(--green-pale); color: var(--green); font-weight: 800; letter-spacing: 0.035em; }
.badge-mers .mers-icon { width: 0.6875rem; height: 0.6875rem; display: inline-grid; place-items: center; border: 0.0625rem solid currentColor; font-size: 0.5rem; line-height: 1; }
.texture-actions { display: flex; gap: 0.5rem; margin-top: 0.625rem; }
.texture-actions .button { min-height: 2.125rem; flex: 1; padding: 0.3125rem 0.375rem 0.5rem; font-size: 0.6875rem; }
.texture-actions .button:active:enabled { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.empty-state { min-height: 16rem; display: grid; place-content: center; justify-items: center; padding: 2rem 1rem; color: var(--muted); text-align: center; }
.empty-mark { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0.125rem solid var(--line); color: var(--green); font-size: 1.25rem; }
.empty-state h3 { margin: 0.875rem 0 0.25rem; color: var(--text); font-size: 1rem; }
.empty-state p { max-width: 26rem; margin: 0 0 0.875rem; font-size: 0.8125rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.875rem; margin-top: 1.25rem; }
.page-indicator { min-width: 6rem; color: var(--muted); font-size: 0.75rem; text-align: center; font-variant-numeric: tabular-nums; }

.download-queue { margin: 0 0 1rem; padding: 0.875rem; border: 0.125rem solid var(--line-strong); background: var(--page-soft); }
.queue-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.queue-heading h3 { margin: 0.25rem 0 0; font-size: 1rem; }
.queue-note { margin: 0.625rem 0; color: var(--muted); font-size: 0.75rem; }
.queue-list { display: grid; gap: 0.375rem; margin: 0; padding: 0; list-style: none; }
.queue-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.75rem; padding: 0.5rem 0.625rem; border: 0.0625rem solid var(--line); background: var(--surface); }
.queue-file { min-width: 0; overflow: hidden; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.queue-status { color: var(--muted); font-size: 0.6875rem; white-space: nowrap; }
.queue-status.is-success { color: var(--green); }
.queue-status.is-error { color: var(--danger); }

.storage-meter { min-width: 12rem; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 0.625rem; }
.storage-label { color: var(--muted); font-size: 0.6875rem; }
.storage-meter strong { font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: right; }
.storage-track { grid-column: 1 / -1; height: 0.375rem; overflow: hidden; border: 0.0625rem solid var(--line); background: var(--surface-inset); }
.storage-track progress { width: 100%; height: 100%; display: block; border: 0; appearance: none; accent-color: var(--green); }
.storage-track progress::-webkit-progress-bar { background: var(--surface-inset); }
.storage-track progress::-webkit-progress-value { background: var(--green); }
.storage-track progress::-moz-progress-bar { background: var(--green); }
.files-login { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; padding: 1rem; border: 0.125rem solid var(--line); background: var(--page-soft); }
.login-mark { width: 2rem; height: 2rem; display: grid; place-items: center; flex: 0 0 2rem; border: 0.125rem solid var(--green); color: var(--green); }
.files-login div { flex: 1; }
.files-login h3, .upload-copy h3 { margin: 0; font-size: 0.875rem; }
.files-login p, .upload-copy p { margin: 0.125rem 0 0; color: var(--muted); font-size: 0.75rem; }
.upload-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; padding: 1rem; border: 0.125rem dashed var(--line-strong); background: var(--page-soft); }
.upload-copy { display: flex; align-items: center; gap: 0.75rem; }
.upload-icon { width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border: 0.125rem solid var(--green); background: var(--green-pale); color: var(--green); font-size: 1.25rem; font-weight: 700; }
.choose-files { cursor: pointer; }
.upload-list { display: grid; gap: 0.5rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.375rem 0.75rem; padding: 0.625rem 0.75rem; border: 0.0625rem solid var(--line); background: var(--surface-raised); }
.upload-row-head { min-width: 0; display: flex; justify-content: space-between; gap: 0.75rem; }
.upload-name { overflow: hidden; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { color: var(--muted); font-size: 0.6875rem; white-space: nowrap; }
.upload-status.is-error { color: var(--danger); }
.upload-status.is-success { color: var(--green); }
.upload-progress { width: 100%; height: 0.375rem; grid-column: 1 / -1; appearance: none; border: 0.0625rem solid var(--line); background: var(--surface-inset); accent-color: var(--green); }
.upload-progress::-webkit-progress-bar { background: var(--surface-inset); }
.upload-progress::-webkit-progress-value { background: var(--green); }
.upload-progress::-moz-progress-bar { background: var(--green); }
.files-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 0.75rem; }
.files-toolbar h3 { margin: 0; font-size: 1rem; }
.file-total { margin-left: 0.25rem; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.files-search { width: min(20rem, 55%); min-height: 2.5rem; }
.files-search input { font-size: 0.8125rem; }
.file-table-wrap { overflow-x: auto; border: 0.125rem solid var(--line); }
.file-table { width: 100%; border-collapse: collapse; text-align: left; }
.file-table th { padding: 0.625rem 0.75rem; background: var(--surface-inset); color: var(--muted); font-size: 0.6875rem; font-weight: 700; white-space: nowrap; }
.file-table td { padding: 0.75rem; border-top: 0.0625rem solid var(--line); font-size: 0.75rem; }
.file-table tbody tr:hover { background: var(--page-soft); }
.file-table th:nth-child(2), .file-table td:nth-child(2) { width: 7rem; }
.file-table th:nth-child(3), .file-table td:nth-child(3) { width: 12rem; }
.file-table th:last-child, .file-table td:last-child { width: 10.5rem; text-align: right; }
.file-name-cell { max-width: 26rem; overflow-wrap: anywhere; font-weight: 700; }
.file-actions { display: flex; justify-content: flex-end; gap: 0.375rem; }
.file-actions .button { min-height: 2rem; padding: 0.25rem 0.5rem 0.4375rem; font-size: 0.6875rem; }
.button-danger { color: var(--danger); }
.button-danger:hover:enabled { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.file-empty { display: grid; place-items: center; gap: 0.625rem; padding: 2rem 1rem; color: var(--muted); text-align: center; }
.file-empty .empty-mark { width: 2rem; height: 2rem; font-size: 1rem; }
.file-empty p { margin: 0; font-size: 0.8125rem; }

.site-footer { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 1rem; padding: 1.375rem 0 2rem; color: var(--faint); }
.footer-brand { color: var(--muted); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.attribution { justify-self: center; margin: 0; font-size: 0.625rem; text-align: center; }
.attribution a { color: var(--muted); text-underline-offset: 0.125rem; }

.dialog {
  width: min(31rem, calc(100vw - 2rem));
  max-width: none;
  max-height: min(88dvh, 48rem);
  padding: 0;
  overflow: hidden;
  border: 0.1875rem solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0.375rem 0 var(--shadow), inset 0.0625rem 0.0625rem var(--surface-raised);
}
.dialog::backdrop { background: rgb(12 18 13 / 58%); backdrop-filter: blur(0.125rem); }
.dialog[open] { animation: dialog-in 0.16s ease-out; }
.dialog-head { min-height: 4.125rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 0.125rem solid var(--line); background: var(--page-soft); }
.dialog-head h2 { margin: 0; font-size: 1.125rem; line-height: 1.25; }
.dialog-close { width: 2.375rem; height: 2.375rem; flex: 0 0 2.375rem; border: 0.125rem solid var(--line); background: var(--surface); color: var(--muted); font-size: 1.375rem; line-height: 1; cursor: pointer; }
.dialog-close:hover { border-color: var(--line-strong); color: var(--text); }
.dialog-body { display: grid; gap: 0.875rem; padding: 1.25rem; }
.form-field { display: grid; gap: 0.3125rem; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.form-field input { min-height: 2.875rem; width: 100%; padding: 0.5625rem 0.6875rem; border: 0.125rem solid var(--line-strong); border-radius: 0; background: var(--surface-inset); color: var(--text); font-size: 0.875rem; }
.form-field input:focus { outline: 0.125rem solid var(--focus); outline-offset: 0.0625rem; }
.form-error { margin: 0; color: var(--danger); font-size: 0.75rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.625rem; padding: 0.875rem 1.25rem; border-top: 0.125rem solid var(--line); background: var(--page-soft); }
.preview-dialog { width: min(46rem, calc(100vw - 2rem)); }
.preview-dialog-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(12rem, 0.9fr); gap: 1rem; max-height: calc(88dvh - 9rem); padding: 1rem; overflow: auto; }
.preview-stage { min-height: 15rem; display: grid; place-items: center; padding: 1rem; border: 0.125rem solid var(--line); background-color: var(--surface-inset); background-image: linear-gradient(45deg, var(--check-a) 25%, transparent 25%), linear-gradient(-45deg, var(--check-a) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--check-a) 75%), linear-gradient(-45deg, transparent 75%, var(--check-a) 75%); background-size: 1.25rem 1.25rem; background-position: 0 0, 0 0.625rem, 0.625rem -0.625rem, -0.625rem 0; }
.preview-stage img { max-width: 100%; max-height: 28rem; image-rendering: pixelated; object-fit: contain; }
.preview-details { align-content: start; display: grid; gap: 0.625rem; }
.preview-detail { padding-bottom: 0.5rem; border-bottom: 0.0625rem solid var(--line); }
.preview-detail dt { color: var(--faint); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.preview-detail dd { overflow-wrap: anywhere; margin: 0.125rem 0 0; color: var(--text); font-size: 0.75rem; }
.toast-region { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; display: grid; justify-items: end; gap: 0.5rem; pointer-events: none; }
.toast { max-width: min(26rem, calc(100vw - 2rem)); padding: 0.625rem 0.875rem; border: 0.125rem solid var(--line-strong); background: var(--surface-raised); color: var(--text); box-shadow: 0 0.1875rem 0 var(--line-strong); font-size: 0.75rem; animation: toast-in 0.15s ease-out; }
.toast.is-error { border-color: var(--danger); }
.toast.is-success { border-color: var(--green); }

@keyframes pulse { to { opacity: 0.35; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(0.375rem); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.375rem); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 68rem) {
  .texture-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer { grid-template-columns: auto 1fr; }
}
@media (max-width: 48rem) {
  .site-header { min-height: 3.75rem; padding-inline: 1rem; }
  .header-tools { gap: 0.375rem; }
  .theme-label, .auth-status { display: none; }
  .page-shell { width: min(100% - 1.25rem, 42rem); }
  .hero { min-height: 12.5rem; margin-top: 0.75rem; padding: 1.25rem; }
  .hero-stamp { right: 0.5rem; width: 6.5rem; height: 6.5rem; opacity: 0.28; }
  .stamp-leaf { left: 2.5rem; width: 1.5rem; height: 2.5rem; }
  .stamp-center { top: 3.125rem; left: 3rem; }
  .hero-meta { right: 0.875rem; bottom: 0.625rem; max-width: 72%; font-size: 0.625rem; }
  .main-nav { flex-direction: column; gap: 0; }
  .nav-tabs { min-height: 3.25rem; }
  .nav-tab { min-width: 0; flex: 1; padding-inline: 0.5rem; }
  .nav-tools { justify-content: space-between; padding: 0.5rem 0.625rem; border-top: 0.0625rem solid var(--line); }
  .content-panel { padding: 1rem 0.75rem; }
  .panel-heading { align-items: flex-start; flex-direction: column; gap: 0.5rem; }
  .filter-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .filter-bar > .search-field { grid-column: 1 / -1; }
  .select-field { min-width: 0; }
  .result-count { align-self: center; }
  .texture-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; }
  .texture-card-head { min-height: 2.375rem; padding-inline: 0.5rem; }
  .texture-preview { aspect-ratio: 1 / 0.78; padding: 0.625rem; }
  .texture-info { padding: 0.625rem 0.5rem 0.6875rem; }
  .texture-name { font-size: 0.8125rem; }
  .texture-actions { gap: 0.3125rem; }
  .texture-actions .button { padding-inline: 0.25rem; font-size: 0.625rem; }
  .storage-meter { min-width: 0; width: 100%; }
  .files-login { flex-wrap: wrap; }
  .files-login div { min-width: calc(100% - 4rem); }
  .upload-card { align-items: flex-start; flex-direction: column; }
  .files-toolbar { align-items: flex-start; flex-direction: column; }
  .files-search { width: 100%; }
  .file-table { min-width: 38rem; }
  .site-footer { grid-template-columns: 1fr; justify-items: center; gap: 0.5rem; padding-bottom: 1.5rem; }
  .attribution { max-width: 34rem; }
  .preview-dialog-body { grid-template-columns: 1fr; }
  .preview-stage { min-height: 12rem; }
  .queue-item { grid-template-columns: minmax(0, 1fr) auto; }
  .queue-item .button { grid-column: 1 / -1; justify-self: end; }
}
@media (max-width: 23rem) {
  .hero h1 { font-size: 1.75rem; }
  .nav-tab { gap: 0.375rem; font-size: 0.8125rem; }
  .texture-grid { gap: 0.5rem; }
  .badge { padding-inline: 0.25rem; font-size: 0.5625rem; }
  .pagination { gap: 0.375rem; }
  .pagination .button { padding-inline: 0.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
