:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f3ec;
  color: #171412;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: #f7f3ec;
}

body {
  margin: 0;
  background: #f7f3ec;
  color: #171412;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.sheet-panel:focus-visible {
  outline: 3px solid #0a6f75;
  outline-offset: 3px;
}

.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;
}

.site-header {
  width: min(100%, 1180px);
  min-height: 68px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.action-button,
.copy-link-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d9d1c6;
  border-radius: 6px;
  background: #fffdf9;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
}

.action-button {
  padding: 0 12px;
}

.action-button img,
.copy-link-button img,
.sheet-close img,
.search-field img {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.action-button:hover,
.copy-link-button:hover {
  border-color: #9f9487;
  background: #ffffff;
}

.action-feedback {
  min-height: 20px;
  margin: 4px 0 0;
  color: #5f554c;
  font-size: 0.8125rem;
  text-align: right;
}

.page-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 10px 16px 48px;
}

.intro {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #b9232f;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 18ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: 0;
}

.guidance {
  max-width: 50ch;
  margin: 14px 0 0;
  color: #5f554c;
  font-size: 0.975rem;
  line-height: 1.55;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  max-width: 680px;
  margin-top: 24px;
}

.search-input-wrap {
  position: relative;
  min-width: 0;
}

.search-field {
  display: flex;
  min-width: 0;
  height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid #cfc5b9;
  border-radius: 6px;
  background: #fffdf9;
}

.search-field:focus-within {
  border-color: #171412;
  box-shadow: 0 0 0 1px #171412;
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #171412;
}

.search-field input::placeholder {
  color: #8b8177;
}

.search-history-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid #cfc5b9;
  border-radius: 6px;
  background: #fffdf9;
  box-shadow: 0 12px 28px rgb(45 34 25 / 0.16);
}

.search-history-panel[hidden] {
  display: none;
}

.search-history-header {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid #e4ddd4;
  color: #675d54;
  font-size: 0.78rem;
  font-weight: 750;
}

.search-history-clear {
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a91925;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
}

.search-history-list {
  max-height: 352px;
  overflow-y: auto;
}

.search-history-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #eee8df;
  background: transparent;
  color: #171412;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.search-history-item:last-child {
  border-bottom: 0;
}

.search-history-item:hover,
.search-history-item:focus-visible,
.search-history-clear:hover,
.search-history-clear:focus-visible {
  background: #f2ece3;
}

.search-button,
.recovery-button {
  min-height: 48px;
  border: 1px solid #a91925;
  border-radius: 6px;
  background: #b9232f;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.search-button {
  min-width: 88px;
  padding: 0 16px;
}

.search-button:hover,
.recovery-button:hover {
  background: #9f1e28;
}

.field-error {
  min-height: 22px;
  max-width: 680px;
  margin: 6px 0 0;
  color: #9f1e28;
  font-size: 0.875rem;
  font-weight: 650;
}

.catalog {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid #ded6cc;
}

.catalog-toolbar {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.catalog-toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.sort-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  width: 164px;
  min-width: 164px;
  padding: 3px;
  border: 1px solid #d2c9bd;
  border-radius: 6px;
  background: #eee8df;
}

.sort-button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: #62584f;
  font-size: 0.8125rem;
  font-weight: 800;
}

.sort-button.is-selected {
  background: #171412;
  color: #ffffff;
}

.catalog-status {
  min-height: 22px;
  margin: 8px 0 0;
  color: #675d54;
  font-size: 0.85rem;
}

.catalog-recovery {
  min-height: 0;
}

.catalog-recovery:not(:empty) {
  margin: 8px 0 16px;
}

.catalog-more {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}

.catalog-more[hidden] {
  display: none;
}

.more-button {
  min-width: 148px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #171412;
  border-radius: 6px;
  background: #171412;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.more-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.recovery-button {
  min-height: 40px;
  padding: 0 14px;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
  transition: opacity 140ms ease;
}

.poster-grid.is-refreshing {
  opacity: 0.76;
}

.poster-card,
.poster-skeleton {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 8px;
  background: #dfd7cc;
}

.poster-card {
  border: 1px solid #cfc5b9;
  color: #ffffff;
  box-shadow: 0 4px 14px rgb(45 34 25 / 0.1);
}

.poster-card:hover .poster-image {
  transform: scale(1.018);
}

.poster-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 160ms ease;
}

.poster-topline {
  position: absolute;
  top: 9px;
  left: 9px;
  right: 9px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 5px;
}

.code-badge,
.view-badge {
  min-width: 0;
  max-width: calc((100% - 5px) / 2);
  padding: 5px 7px;
  border-radius: 4px;
  font-size: 0.625rem;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.code-badge {
  border: 1px solid rgb(23 20 18 / 0.24);
  background: #f4c84a;
  color: #171412;
  font-weight: 900;
}

.view-badge {
  background: rgb(18 15 13 / 0.78);
  color: #ffffff;
  font-weight: 700;
  text-align: right;
}

.poster-title {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 72px;
  display: -webkit-box;
  padding: 10px;
  overflow: hidden;
  background: rgb(18 15 13 / 0.78);
  color: #ffffff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.poster-skeleton {
  border: 1px solid #d5ccc0;
  background: #e7e0d6;
}

.poster-skeleton::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 12px;
  left: 10px;
  height: 42px;
  border-radius: 4px;
  background: #d5ccc0;
  animation: skeleton-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes skeleton-pulse {
  from { opacity: 0.52; }
  to { opacity: 1; }
}

.instruction-sheet[hidden] {
  display: none;
}

.instruction-sheet {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(23 20 18 / 0.62);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 24px);
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  overflow: auto;
  border-radius: 8px 8px 0 0;
  background: #fffdf9;
  box-shadow: 0 -14px 38px rgb(23 20 18 / 0.22);
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d9d1c6;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.sheet-kicker {
  margin: 0 52px 8px 0;
  color: #b9232f;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sheet-panel h2 {
  max-width: 22ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  line-height: 1.08;
}

.sheet-panel p:not(.sheet-kicker) {
  max-width: 52ch;
  margin: 14px 0 0;
  color: #5f554c;
  line-height: 1.55;
}

.copy-link-button {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  border-color: #171412;
  background: #f4c84a;
}

.sheet-feedback {
  min-height: 22px;
  margin: 8px 0 0;
  color: #4b433c;
  font-size: 0.875rem;
  font-weight: 700;
}

.sheet-open {
  overflow: hidden;
}

.clipboard-proxy {
  position: fixed;
  top: -1000px;
  left: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

@media (min-width: 640px) {
  .site-header {
    padding-inline: 24px;
  }

  .page-shell {
    padding: 18px 24px 64px;
  }

  h1 {
    font-size: 3.2rem;
  }

  .poster-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .sheet-panel {
    width: min(520px, calc(100% - 32px));
    margin: 0 auto 20px;
    border-radius: 8px;
  }
}

@media (min-width: 920px) {
  .page-shell {
    padding-top: 28px;
  }

  .intro {
    max-width: 820px;
  }

  .poster-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }

  .instruction-sheet {
    align-items: center;
  }
}

@media (min-width: 1240px) {
  .poster-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 359px) {
  .site-header,
  .page-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .action-button {
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .action-button img {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 479px) {
  .search-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-button {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
  }

  .catalog-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .sort-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
  }

  .sort-button {
    min-width: 0;
    padding: 6px;
    overflow-wrap: anywhere;
  }
}

@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;
  }
}
