:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f7f7f2);
  --text: var(--tg-theme-text-color, #293128);
  --muted: var(--tg-theme-hint-color, #737d6c);
  --surface: var(--tg-theme-secondary-bg-color, #eef0e8);
  --accent: #405b33;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 system-ui,
    -apple-system,
    sans-serif;
}
main {
  max-width: 1100px;
  margin: auto;
  padding: 24px 18px calc(32px + env(safe-area-inset-bottom));
}
header {
  margin: 12px 0 26px;
}
.brand {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: none;
}
h1 {
  font-size: clamp(27px, 5vw, 40px);
  line-height: 1.15;
  margin: 12px 0;
}
header p,
#status,
#detail-tags {
  color: var(--muted);
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid #929a8545;
  border-radius: 12px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.filters {
  display: grid;
  gap: 12px;
}
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.look {
  border: 0;
  padding: 0;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
}
.look img {
  display: block;
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}
.look .label {
  display: block;
  padding: 12px 13px 14px;
}
.look strong {
  display: block;
  line-height: 1.3;
}
.look small {
  color: var(--muted);
}
button {
  font: inherit;
  cursor: pointer;
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
#more,
#retry,
#choose,
#choose-free {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 13px;
  padding: 14px 20px;
  font-weight: 650;
  min-height: 48px;
}
#more,
#retry {
  display: block;
  margin: 24px auto;
}
#more[hidden],
#retry[hidden] {
  display: none;
}
dialog {
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  width: min(520px, calc(100% - 24px));
  max-height: 92dvh;
  overflow: auto;
}
dialog:focus {
  outline: none;
}
dialog::backdrop {
  background: #172014a8;
}
#detail-image {
  display: block;
  width: 100%;
  max-height: 50dvh;
  object-fit: contain;
  background: var(--surface);
}
.detail-body {
  padding: 18px 22px;
}
.detail-body h2 {
  margin: 8px 0;
  font-size: 24px;
}
#choose {
  width: 100%;
}
.close {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #29312812;
  border-radius: 50%;
  background: #fffffff2;
  color: #293128;
  line-height: 1;
  box-shadow: 0 2px 8px #0002;
  -webkit-tap-highlight-color: transparent;
}
.close:focus {
  outline: none;
}
.close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.close:active {
  background: #edf0e8;
}
.detail-actions {
  display: grid;
  gap: 10px;
  padding: 16px 22px 0;
}
.detail-actions.has-free {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#choose-free {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #929a8560;
}
#choose-free[hidden] {
  display: none;
}
#selection-status {
  grid-column: 1/-1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
#selection-status:empty {
  display: none;
}

a {
  color: inherit;
}
.admin {
  max-width: 900px;
}
.admin form {
  display: grid;
  gap: 14px;
  background: var(--surface);
  padding: 24px;
  border-radius: 18px;
  margin: 24px 0;
}
.admin label.check {
  flex-direction: row;
  align-items: center;
}
.check input {
  width: 20px;
  min-height: 20px;
}
.admin button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  padding: 12px;
}
.admin-card {
  display: flex;
  gap: 16px;
  align-items: center;
  border-top: 1px solid #929a8545;
  padding: 16px 0;
}
.admin-card img {
  width: 72px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
}
.admin-card div {
  flex: 1;
}
.admin textarea {
  font: inherit;
  min-height: 70px;
}
.admin .actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  main {
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom));
  }
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .look .label {
    padding: 10px;
    font-size: 14px;
  }
  .look small {
    font-size: 11px;
  }
  header p {
    font-size: 14px;
  }
  h1 {
    font-size: 30px;
  }
}

.admin form[hidden] {
  display: none;
}
