:root {
  color-scheme: light;
  --bg: #f8f7f4;
  --surface: #ffffff;
  --text: #20201d;
  --focus: #2d6f5e;
  --shadow: 0 18px 45px rgb(31 28 22 / 14%);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
}

.site-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1rem 1.5rem;
}

h1 {
  margin: 0;
  color: #d65f32;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: #8a8175;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.gallery-grid {
  column-count: 4;
  column-gap: 1rem;
}

.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.category-filter[hidden] {
  display: none;
}

.category-button {
  border: 1px solid rgb(32 32 29 / 12%);
  border-radius: 999px;
  background: rgb(255 255 255 / 56%);
  color: #5d554b;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.55rem 0.8rem;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.category-button:hover,
.category-button[aria-pressed="true"] {
  border-color: rgb(214 95 50 / 44%);
  background: #d65f32;
  color: #fff;
}

.gallery-empty {
  margin: 0;
  color: #8a8175;
  font-size: 0.95rem;
  line-height: 1.6;
}

.gallery-status {
  margin: 1rem 0 0;
  color: #8a8175;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.gallery-status[hidden] {
  display: none;
}

.gallery-sentinel {
  height: 1px;
}

.gallery-item {
  display: inline-block;
  position: relative;
  width: 100%;
  margin: 0 0 1rem;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(32 32 29 / 10%);
  cursor: zoom-in;
  padding: 0;
  break-inside: avoid;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  background: #ebe6db;
  transition: transform 260ms ease;
}

.gallery-info {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  gap: 0.35rem;
  padding: 2.25rem 0.8rem 0.7rem;
  background: linear-gradient(180deg, rgb(0 0 0 / 0%), rgb(0 0 0 / 72%));
  color: #fff;
  pointer-events: none;
  text-align: left;
}

.gallery-meta {
  color: rgb(255 255 255 / 74%);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.gallery-title {
  display: block;
  overflow: hidden;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.025);
}

.gallery-item:focus-visible,
.category-button:focus-visible,
.icon-button:focus-visible,
.arrow-button:focus-visible {
  outline: 3px solid rgb(45 111 94 / 28%);
  outline-offset: 3px;
}

.lightbox {
  width: min(1040px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  color: #fff;
}

.lightbox::backdrop {
  background: rgb(12 11 9 / 78%);
  backdrop-filter: blur(10px);
}

.icon-button,
.arrow-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 999px;
  background: rgb(255 255 255 / 10%);
  color: #fff;
  cursor: pointer;
}

.icon-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.7rem;
  line-height: 1;
}

.arrow-button {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 2rem;
}

.icon-button:hover,
.arrow-button:hover {
  background: rgb(255 255 255 / 18%);
}

.lightbox-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.lightbox-stage img {
  width: 100%;
  max-height: calc(100vh - 10rem);
  object-fit: contain;
  border-radius: 8px;
  transform-origin: center center;
  transition: transform 160ms ease;
  will-change: transform;
}

.lightbox-stage.is-pinching img {
  transition: none;
}

.lightbox-details {
  display: grid;
  gap: 0.45rem;
  margin: 0.85rem auto 0;
  max-width: min(760px, 100%);
  text-align: center;
}

.lightbox-details h2 {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-meta {
  margin: 0;
  color: rgb(255 255 255 / 72%);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
}

.lightbox-description {
  margin: 0;
  color: rgb(255 255 255 / 78%);
  font-size: 0.85rem;
  line-height: 1.55;
}

.lightbox-description[hidden] {
  display: none;
}

.admin-page {
  background: #f4f1eb;
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1rem 1.5rem;
}

.admin-header h1 {
  color: var(--text);
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0;
  text-transform: none;
}

.admin-kicker {
  margin: 0 0 0.45rem;
  color: #d65f32;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.admin-link {
  border: 1px solid rgb(32 32 29 / 12%);
  border-radius: 999px;
  background: #fff;
  color: #4f463d;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
}

.admin-shell {
  display: grid;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.admin-panel {
  border: 1px solid rgb(32 32 29 / 10%);
  border-radius: 8px;
  background: rgb(255 255 255 / 78%);
  padding: 1rem;
}

.admin-panel h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.2;
}

.admin-form,
.admin-edit-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.admin-form {
  margin-top: 1rem;
}

.admin-form label,
.admin-edit-form label,
.admin-category-field,
.admin-search {
  display: grid;
  gap: 0.35rem;
  color: #6d6257;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.admin-form input,
.admin-form textarea,
.admin-edit-form input,
.admin-edit-form textarea,
.admin-search input {
  width: 100%;
  border: 1px solid rgb(32 32 29 / 14%);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
  padding: 0.7rem 0.75rem;
  text-transform: none;
}

.admin-category-field {
  position: relative;
}

.admin-category-control {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
}

.admin-category-trigger {
  width: 100%;
  min-width: 0;
  border: 1px solid rgb(32 32 29 / 14%);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  padding: 0.7rem 2.2rem 0.7rem 0.75rem;
  text-align: left;
}

.admin-category-trigger::after {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #8a8175;
  border-bottom: 2px solid #8a8175;
  content: "";
  pointer-events: none;
  transform: translateY(-68%) rotate(45deg);
}

.admin-category-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-category-control:not(.has-value) .admin-category-value {
  color: #9a9187;
  font-weight: 500;
}

.admin-category-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.3rem);
  right: 0;
  left: 0;
  display: grid;
  max-height: 14rem;
  overflow: auto;
  border: 1px solid rgb(32 32 29 / 12%);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgb(31 28 22 / 16%);
  padding: 0.35rem;
}

.admin-category-menu[hidden] {
  display: none;
}

.admin-category-option {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.58rem 0.65rem;
  text-align: left;
}

.admin-category-option:hover,
.admin-category-option:focus-visible {
  background: #f4eee9;
}

.admin-category-panel {
  display: grid;
  gap: 0.85rem;
}

.admin-category-panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.admin-category-panel-head p {
  margin: 0.3rem 0 0;
  color: #8a8175;
  font-size: 0.82rem;
  line-height: 1.4;
}

.admin-category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.admin-category-tag {
  border: 1px solid rgb(214 95 50 / 28%);
  border-radius: 999px;
  background: #fff7f2;
  color: #9f3d1e;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.58rem 0.82rem;
}

.admin-category-tag:hover,
.admin-category-tag:focus-visible {
  background: #d65f32;
  color: #fff;
}

.admin-category-add {
  border-style: dashed;
  background: #fff;
  color: #5d554b;
}

.admin-form textarea,
.admin-edit-form textarea {
  resize: vertical;
}

.admin-field-wide {
  grid-column: span 2;
}

.admin-upload-progress {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.admin-upload-progress[hidden] {
  display: none;
}

.admin-upload-progress-track {
  overflow: hidden;
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: #efe7dd;
}

.admin-upload-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #d65f32;
  transition: width 160ms ease;
}

.admin-upload-progress p {
  margin: 0;
  color: #756b61;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.4;
}

.admin-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-toolbar p,
.admin-status,
.admin-empty {
  margin: 0;
  color: #8a8175;
  font-size: 0.82rem;
  line-height: 1.5;
}

.admin-status[data-state="error"] {
  color: #b23620;
}

.admin-search {
  min-width: min(280px, 100%);
}

.admin-list {
  display: grid;
  gap: 0.8rem;
}

.admin-item {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 0.9rem;
  border-top: 1px solid rgb(32 32 29 / 10%);
  padding-top: 0.8rem;
}

.admin-item img {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #ebe6db;
  object-fit: cover;
}

.admin-actions {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.admin-primary,
.admin-danger {
  align-self: end;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.78rem 1rem;
}

.admin-primary {
  background: #d65f32;
  color: #fff;
}

.admin-danger {
  background: #f0e5de;
  color: #9f2d19;
}

.admin-secondary {
  align-self: end;
  border: 1px solid rgb(32 32 29 / 12%);
  border-radius: 999px;
  background: #fff;
  color: #5d554b;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.78rem 1rem;
}

.admin-toast {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 999px;
  background: #2d6f5e;
  box-shadow: 0 12px 34px rgb(31 28 22 / 18%);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  padding: 0.82rem 1.05rem;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.admin-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast[hidden] {
  display: none;
}

.admin-primary:disabled,
.admin-danger:disabled,
.admin-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.admin-category-dialog,
.admin-confirm-dialog {
  width: min(460px, calc(100vw - 2rem));
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.admin-category-dialog::backdrop,
.admin-confirm-dialog::backdrop {
  background: rgb(16 14 11 / 46%);
  backdrop-filter: blur(5px);
}

.admin-category-dialog-card,
.admin-confirm-card {
  display: grid;
  gap: 1rem;
  border: 1px solid rgb(32 32 29 / 12%);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 28px 80px rgb(31 28 22 / 26%);
  padding: 1rem;
}

.admin-category-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-category-dialog-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1.2;
}

.admin-dialog-close {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgb(32 32 29 / 10%);
  border-radius: 999px;
  background: #fff;
  color: #7a7066;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.admin-dialog-field {
  display: grid;
  gap: 0.4rem;
  color: #6d6257;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.admin-dialog-field input {
  width: 100%;
  border: 1px solid rgb(32 32 29 / 14%);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
  padding: 0.75rem 0.8rem;
  text-transform: none;
}

.admin-dialog-message {
  min-height: 1.25rem;
  margin: 0;
  color: #8a8175;
  font-size: 0.82rem;
  line-height: 1.45;
}

.admin-dialog-message[data-state="error"] {
  color: #b23620;
}

.admin-confirm-message {
  margin: 0;
  color: #5d554b;
  font-size: 0.92rem;
  line-height: 1.55;
}

.admin-dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.55rem;
  align-items: center;
}

.device-page {
  min-height: 100vh;
  background: var(--bg);
}

.device-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.device-card {
  width: min(440px, 100%);
  border: 1px solid rgb(32 32 29 / 10%);
  border-radius: 8px;
  background: rgb(255 255 255 / 82%);
  box-shadow: 0 18px 44px rgb(31 28 22 / 12%);
  padding: 1.35rem;
  text-align: center;
}

.device-icon {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: #d65f32;
  color: #fff;
}

.device-icon svg {
  width: 1.85rem;
  height: 1.85rem;
}

.device-card h1 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: none;
}

.device-card h1 span {
  display: block;
}

.device-card h1 [lang="en"] {
  margin-top: 0.35rem;
  color: #51483e;
  font-size: 0.98rem;
  font-weight: 800;
}

.device-copy {
  margin: 0.85rem 0 1rem;
  color: #6d6257;
  font-size: 0.92rem;
  line-height: 1.65;
}

.device-copy span {
  display: block;
}

.device-copy span + span {
  margin-top: 0.35rem;
}

.device-copy [lang="en"] {
  color: #756b61;
  font-size: 0.86rem;
  line-height: 1.55;
}

.device-url {
  overflow-wrap: anywhere;
  border: 1px solid rgb(32 32 29 / 10%);
  border-radius: 8px;
  background: #f4f1eb;
  color: #5d554b;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
  padding: 0.78rem;
}

.device-button {
  width: 100%;
  margin-top: 1rem;
  border: 0;
  border-radius: 999px;
  background: #d65f32;
  color: #fff;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.2;
  padding: 0.9rem 1rem;
}

.device-button.is-success {
  background: #2d6f5e;
}

@media (max-width: 980px) {
  .gallery-grid {
    column-count: 3;
  }

  .admin-form,
  .admin-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .site-header {
    padding-top: 2rem;
  }

  .gallery-grid {
    column-count: 2;
    column-gap: 0.75rem;
  }

  .category-filter {
    flex-wrap: nowrap;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  .category-filter::-webkit-scrollbar {
    display: none;
  }

  .category-button {
    flex: 0 0 auto;
    font-size: 0.72rem;
    padding: 0.5rem 0.65rem;
  }

  .gallery-item {
    margin-bottom: 0.75rem;
  }

  .gallery-info {
    gap: 0.28rem;
    padding: 1.75rem 0.6rem 0.55rem;
  }

  .gallery-meta {
    font-size: 0.58rem;
  }

  .gallery-title {
    font-size: 0.8rem;
  }

  .lightbox-stage {
    grid-template-columns: 1fr 1fr;
  }

  .lightbox-stage img {
    grid-column: 1 / -1;
    grid-row: 1;
    max-height: calc(100vh - 11rem);
  }

  .lightbox-details {
    margin-top: 0.75rem;
  }

  .lightbox-details h2 {
    font-size: 0.95rem;
  }

  .lightbox-meta {
    font-size: 0.7rem;
  }

  .arrow-button {
    display: none;
  }

  .admin-header {
    align-items: stretch;
    flex-direction: column;
    padding-top: 2rem;
  }

  .admin-link {
    text-align: center;
  }

  .admin-toolbar,
  .admin-item {
    display: grid;
  }

  .admin-form,
  .admin-edit-form,
  .admin-item {
    grid-template-columns: 1fr;
  }

  .admin-field-wide {
    grid-column: auto;
  }

  .admin-item img {
    width: 100%;
    aspect-ratio: 16 / 10;
  }

  .admin-actions {
    justify-content: space-between;
  }

  .admin-dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .admin-dialog-actions span {
    display: none;
  }
}
