:root {
  color-scheme: light;
  --paper: #f7f7f2;
  --ink: #111;
  --muted: #5f5f5a;
  --line: #1b1b1b;
  --soft-line: #d7d7cf;
  --white: #fff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

body.viewer-open {
  overflow: hidden;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 2px solid var(--line);
  background: rgba(247, 247, 242, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.social-link {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.social-link:hover {
  color: var(--muted);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.hero {
  max-width: 820px;
  padding: 0 0 32px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.sidebar,
.detail {
  border: 2px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.callback-panel {
  max-width: 760px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  padding: clamp(20px, 4vw, 34px);
}

.callback-field {
  display: grid;
  gap: 8px;
  margin: 22px 0;
  font-weight: 800;
}

.callback-code {
  min-height: 132px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.sidebar {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.toolbar {
  padding: 16px;
  border-bottom: 2px solid var(--line);
}

.search-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
}

.puzzle-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.puzzle-button {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.puzzle-button:hover,
.puzzle-button[aria-current="true"] {
  background: var(--ink);
  color: var(--paper);
}

.puzzle-date {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.puzzle-title {
  font-size: 1rem;
  font-weight: 800;
}

.puzzle-theme {
  color: currentColor;
  font-size: 0.88rem;
  opacity: 0.72;
}

.detail {
  min-height: 520px;
  padding: clamp(18px, 3vw, 34px);
}

.detail-header {
  display: grid;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--line);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.description {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.start-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(190px, 0.8fr);
  gap: 16px;
  margin-top: 24px;
  padding: clamp(16px, 3vw, 24px);
  border: 2px solid var(--line);
  background: var(--white);
}

.start-copy {
  min-width: 0;
}

.start-copy .eyebrow {
  margin-bottom: 8px;
}

.start-copy h3 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 0.95;
}

.start-copy p:not(.eyebrow) {
  max-width: 540px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.step-list {
  display: grid;
  gap: 8px;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-weight: 900;
}

.step-list span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
}

.target-preview {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}

.target-preview span {
  max-width: 100%;
  padding: 7px 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: 0.9rem;
  font-weight: 800;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  cursor: pointer;
}

.download-button:hover {
  background: var(--paper);
  color: var(--ink);
}

.secondary-button {
  background: var(--paper);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--ink);
  color: var(--paper);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.image-panel {
  min-width: 0;
}

.image-panel h3 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.image-open-button {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.image-open-button:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

.puzzle-image {
  width: 100%;
  min-height: 260px;
  display: block;
  border: 2px solid var(--line);
  background:
    repeating-linear-gradient(45deg, #fff, #fff 12px, #eeeeea 12px, #eeeeea 24px);
  object-fit: contain;
}

.image-open-button:hover .puzzle-image {
  filter: contrast(1.08);
}

.solution-gate {
  min-height: 260px;
  display: grid;
  place-content: center;
  padding: 24px;
  border: 2px solid var(--line);
  background:
    linear-gradient(rgba(247, 247, 242, 0.88), rgba(247, 247, 242, 0.88)),
    repeating-linear-gradient(45deg, #fff, #fff 12px, #eeeeea 12px, #eeeeea 24px);
  text-align: center;
}

.solution-lock {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 280px;
}

.solution-lock::before {
  content: "?";
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 900;
}

.solution-kicker,
.solution-copy {
  margin: 0;
}

.solution-kicker {
  font-size: 1rem;
  font-weight: 900;
}

.solution-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.object-section {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.text-block {
  border-top: 2px solid var(--line);
  padding-top: 16px;
}

.text-block h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.object-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.75;
}

.caption {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.55;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 32px;
  padding: 22px 0 0;
  border-top: 2px solid var(--line);
}

.footer-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.footer-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.footer-name,
.footer-copy {
  margin: 0;
}

.footer-name {
  font-size: 1rem;
  font-weight: 900;
}

.footer-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.footer-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.footer-links a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.footer-links a:hover {
  color: var(--muted);
}

.empty {
  display: grid;
  min-height: 420px;
  place-content: center;
  gap: 10px;
  text-align: center;
}

.empty h2,
.empty p {
  margin: 0;
}

.empty code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  background: var(--white);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(247, 247, 242, 0.98);
  color: var(--ink);
}

.image-viewer.is-open {
  display: grid;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(14px, 3vw, 28px);
  border-bottom: 2px solid var(--line);
  background: var(--paper);
}

.viewer-title {
  margin: 0;
  font-weight: 800;
}

.viewer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.viewer-controls button {
  min-width: 44px;
  min-height: 38px;
  padding: 7px 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.viewer-controls button:hover {
  background: var(--ink);
  color: var(--paper);
}

.viewer-stage {
  min-height: 0;
  overflow: auto;
  padding: 24px;
  text-align: center;
}

.viewer-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: inline-block;
  border: 2px solid var(--line);
  background: var(--white);
  transform-origin: top left;
}

.creator-shell {
  width: min(1320px, calc(100% - 32px));
}

.creator-panel {
  border: 2px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.creator-controls {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 2px solid var(--line);
}

.creator-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.creator-status.is-error {
  color: #9c1117;
}

.creator-form {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 120px;
  gap: 12px;
}

.creator-form label {
  display: grid;
  gap: 6px;
}

.creator-form span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.creator-form textarea {
  resize: vertical;
}

.wide-field {
  grid-column: 1 / -1;
}

.creator-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 0;
}

.creator-list {
  padding: 18px;
  border-right: 2px solid var(--line);
}

.creator-list h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.caption-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-top: 2px solid var(--line);
}

.caption-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.caption-header h2 {
  margin: 0;
  font-size: 1rem;
}

.caption-textarea {
  min-height: 420px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
  white-space: pre-wrap;
}

.marker-list {
  display: grid;
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.marker-select {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.marker-select span {
  flex: 0 0 auto;
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.82rem;
}

.marker-select[aria-current="true"] {
  background: var(--ink);
  color: var(--paper);
}

.marker-select[aria-current="true"] span {
  background: var(--paper);
  color: var(--ink);
}

.answer-workspace {
  min-width: 0;
  padding: 18px;
}

.workspace-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.answer-canvas {
  position: relative;
  width: 100%;
  border: 2px solid var(--line);
  overflow: hidden;
  background: var(--white);
}

.answer-base-image {
  width: 100%;
  display: block;
  user-select: none;
}

.marker-layer {
  position: absolute;
  inset: 0;
}

.answer-marker {
  position: absolute;
  width: clamp(22px, 2.4vw, 34px);
  height: clamp(22px, 2.4vw, 34px);
  border: 2px solid #fff;
  border-radius: 50%;
  background: #d71920;
  color: #fff;
  font-weight: 900;
  line-height: 1;
  cursor: grab;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.answer-marker:active {
  cursor: grabbing;
}

.answer-marker[aria-current="true"] {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.creator-previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.creator-previews h2 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.creator-preview-image {
  width: 100%;
  min-height: 180px;
  display: block;
  border: 2px solid var(--line);
  background:
    repeating-linear-gradient(45deg, #fff, #fff 12px, #eeeeea 12px, #eeeeea 24px);
  object-fit: contain;
}

@media (max-width: 860px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .header-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    justify-content: flex-start;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout,
  .image-grid,
  .creator-layout,
  .creator-form,
  .creator-previews,
  .object-section,
  .start-panel {
    grid-template-columns: 1fr;
  }

  .creator-list {
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 28px;
  }

  .detail {
    padding: 16px;
  }

  .viewer-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .viewer-stage {
    padding: 10px;
  }

}
