:root {
  --ink: #2c241c;
  --paper: #f3ead8;
  --paper-deep: #e8dcc8;
  --paper-edge: #c9b89a;
  --specimen: #fff9ef;
  --rust: #8b4a32;
  --mint-ink: #1f6b5c;
  --lamp-off: #b8a894;
  --lamp-on: #e8a020;
  --fix: #d4a04a;
  --fix-shadow: #9a6b28;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(
      0deg,
      rgba(120, 90, 60, 0.03) 0,
      rgba(120, 90, 60, 0.03) 1px,
      transparent 1px,
      transparent 6px
    ),
    linear-gradient(175deg, #ebe2d0 0%, var(--paper) 42%, #efe6d6 100%);
  min-height: 100dvh;
  line-height: 1.45;
}

a {
  color: var(--ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.masthead {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.65rem 1rem 0;
}

.masthead .back {
  font-size: 0.86rem;
}

.lab-sheet {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0.85rem 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.hero {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.35rem 0.15rem 0;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: #7a6550;
}

.hero h1 {
  margin: 0.1rem 0;
  font-size: 1.38rem;
  line-height: 1.2;
  font-weight: 800;
}

.hero h1 span {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rust);
}

.catch {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: #4a4038;
}

.inspector {
  position: relative;
  margin: 0;
  flex-shrink: 0;
}

.inspector .burapi {
  display: block;
  width: 52px;
  height: auto;
  filter: drop-shadow(0 3px 0 rgba(60, 40, 20, 0.15));
}

.inspector .loupe {
  position: absolute;
  right: -6px;
  bottom: 2px;
  width: 22px;
  height: 22px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 252, 245, 0.55);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.inspector .loupe::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: -5px;
  width: 12px;
  height: 4px;
  background: var(--ink);
  transform: rotate(42deg);
  border-radius: 2px;
}

.specimen-stage {
  background: var(--specimen);
  border: 2px solid var(--paper-edge);
  border-radius: 16px;
  padding: 0.65rem 0.7rem 0.75rem;
  box-shadow:
    0 4px 0 rgba(100, 75, 45, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.spec-label {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #7a6550;
}

.swatch {
  border-radius: 10px;
  border: 2px solid var(--paper-edge);
  padding: 0.55rem 0.5rem;
  min-height: 108px;
  transition:
    color 0.45s ease,
    background-color 0.45s ease,
    filter 0.45s ease,
    opacity 0.45s ease;
}

.swatch.is-faded {
  filter: saturate(0.75) contrast(0.88);
  opacity: 0.92;
}

.swatch.is-sharp {
  filter: none;
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.swatch.is-ink-settle {
  animation: ink-settle 0.55s ease;
}

@keyframes ink-settle {
  0% {
    filter: saturate(0.7) contrast(0.85);
  }
  100% {
    filter: none;
  }
}

.sample-normal {
  font-size: 16px;
  margin: 0 0 0.45rem;
}

.sample-large {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.chip-bridge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  min-height: 36px;
}

.color-chip {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 rgba(60, 40, 20, 0.2);
  transition:
    background-color 0.45s ease,
    transform 0.5s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.color-chip.chip-move {
  transform: translateX(12px) scale(1.08);
}

.chip-arrow {
  font-size: 0.85rem;
  color: #7a6550;
  font-weight: 700;
}

.meter-panel {
  text-align: center;
  padding: 0.25rem 0;
}

.ratio-dial {
  display: inline-block;
  min-width: 11rem;
  padding: 0.55rem 1rem 0.65rem;
  border-radius: 999px;
  border: 3px double var(--paper-edge);
  background: linear-gradient(180deg, #fffdf8, #f5ebda);
  box-shadow: inset 0 2px 8px rgba(120, 90, 60, 0.08);
  transition: transform 0.35s ease;
}

.ratio-dial.pulse {
  animation: dial-pulse 0.5s ease;
}

@keyframes dial-pulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.ratio-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #7a6550;
}

.ratio-value {
  margin: 0.1rem 0 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink);
}

.lamp-row {
  list-style: none;
  padding: 0;
  margin: 0.65rem 0 0;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.lamp-row li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.lamp {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #8a7860;
  background: radial-gradient(circle at 35% 30%, #f0e8dc, var(--lamp-off));
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.12);
  transition:
    background 0.4s ease,
    box-shadow 0.4s ease,
    transform 0.35s ease;
}

.lamp.pass {
  background: radial-gradient(circle at 35% 28%, #fff4c8, var(--lamp-on));
  box-shadow:
    0 0 12px rgba(232, 160, 32, 0.55),
    inset 0 -1px 2px rgba(120, 70, 10, 0.2);
}

.lamp.pass.lit {
  animation: lamp-blink 0.45s ease;
}

@keyframes lamp-blink {
  0% {
    transform: scale(0.85);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.lamp.fail {
  background: radial-gradient(circle at 35% 30%, #f5ebe5, #c9a8a0);
}

.lamp-cap {
  font-size: 0.62rem;
  color: #6a5a48;
  max-width: 4.5rem;
  text-align: center;
  line-height: 1.2;
}

.compare {
  margin-top: 0.55rem;
  padding: 0.5rem 0.55rem;
  border-radius: 10px;
  background: rgba(255, 252, 245, 0.85);
  border: 1px dashed var(--paper-edge);
  font-size: 0.78rem;
  text-align: left;
}

.compare[hidden] {
  display: none !important;
}

.compare-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.compare dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.55rem;
}

.compare dd {
  margin: 0;
  font-family: ui-monospace, monospace;
}

.cta-row {
  display: grid;
  gap: 0.45rem;
}

.btn-fix {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, #f0c878, var(--fix));
  color: var(--ink);
  box-shadow: 0 4px 0 var(--fix-shadow);
  cursor: pointer;
}

.btn-fix:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--fix-shadow);
}

.cta-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cta-sub button,
.btn-chip {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 2px solid var(--ink);
  padding: 0.4rem 0.75rem;
  background: #fff9ef;
  color: var(--ink);
  font-size: 0.82rem;
}

.panel {
  background: rgba(255, 249, 239, 0.92);
  border: 2px solid var(--paper-edge);
  border-radius: 14px;
  padding: 0.7rem 0.75rem;
  box-shadow: 0 3px 0 rgba(100, 75, 45, 0.1);
}

.panel h2 {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: #7a6550;
}

.panel.secondary {
  background: rgba(255, 252, 245, 0.75);
}

.color-row {
  display: grid;
  grid-template-columns: 4.2em 44px 1fr;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.color-row label {
  font-size: 0.8rem;
  font-weight: 700;
}

.color-row input[type="color"] {
  width: 44px;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
}

.color-row input[type="text"] {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92rem;
  padding: 0.42rem 0.5rem;
  border: 2px solid var(--paper-edge);
  border-radius: 8px;
  width: 100%;
  background: #fffdf8;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.3rem;
}

.recent-list button {
  width: 100%;
  text-align: left;
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
}

.live-msg {
  min-height: 1.15em;
  font-size: 0.82rem;
  margin: 0;
  color: var(--mint-ink);
}

.disclaimer {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
  font-size: 0.74rem;
  color: #5a5048;
}

button:focus-visible,
.btn-chip:focus-visible,
input:focus-visible {
  outline: 3px solid #1a2848;
  outline-offset: 2px;
}

html[data-capture="1"] .capture-hide,
html[data-promo-shot="1"] .promo-hide {
  display: none !important;
}

html[data-capture="1"] body,
html[data-promo-shot="1"] body {
  background: var(--paper);
}

html[data-capture="1"] .lab-sheet {
  padding-top: max(env(safe-area-inset-top), 6px);
}

html[data-capture="1"] .capture-hud {
  background: #fff9ef;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
}

html[data-promo-shot="1"] body {
  margin: 0;
  width: 390px;
  height: 844px;
  min-height: 844px;
  max-height: 844px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 12px 14px;
  box-sizing: border-box;
}

html[data-promo-shot="1"] .lab-sheet {
  max-width: 100%;
  width: 100%;
  padding: 0;
  gap: 0.38rem;
  flex: 0 0 auto;
  margin: auto 0;
  box-sizing: border-box;
}

html[data-promo-shot="1"] .hero {
  padding: 0;
}

html[data-promo-shot="1"] .kicker {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

html[data-promo-shot="1"] .hero h1 {
  font-size: 1.2rem;
}

html[data-promo-shot="1"] .hero h1 span {
  font-size: 1rem;
}

html[data-promo-shot="1"] .catch {
  font-size: 0.78rem;
  line-height: 1.35;
}

html[data-promo-shot="1"] .specimen-stage {
  padding: 0.45rem 0.48rem 0.5rem;
}

html[data-promo-shot="1"] .pair-grid {
  gap: 0.4rem;
}

html[data-promo-shot="1"] .swatch {
  min-height: 84px;
  padding: 0.36rem 0.38rem;
}

html[data-promo-shot="1"] .sample-normal {
  margin-bottom: 0.25rem;
  font-size: 12.5px;
  line-height: 1.28;
}

html[data-promo-shot="1"] .sample-large {
  font-size: 17px;
  line-height: 1.15;
}

html[data-promo-shot="1"] .meter-panel {
  padding: 0.1rem 0;
}

html[data-promo-shot="1"] .ratio-value {
  font-size: 1.58rem;
}

html[data-promo-shot="1"] .lamp-row {
  margin-top: 0.3rem;
  gap: 0.45rem;
}

html[data-promo-shot="1"] .lamp-cap {
  font-size: 0.58rem;
}

html[data-promo-shot="1"] .cta-row {
  gap: 0.3rem;
}

html[data-promo-shot="1"] .btn-fix {
  padding: 0.62rem 0.75rem;
  font-size: 0.98rem;
}

html[data-promo-shot="1"] .live-msg {
  display: none;
}

html[data-promo-shot="1"] .inputs-panel,
html[data-promo-shot="1"] .cta-sub,
html[data-promo-shot="1"] .chip-bridge {
  display: none !important;
}

html[data-promo-shot="1"] .promo-only {
  display: flex !important;
}

.promo-only {
  display: none;
}

html[data-promo-shot="1"] .promo-stamp {
  justify-content: center;
  margin: 0.05rem 0 0;
}

.aa-stamp {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--rust);
  border: 3px solid var(--rust);
  border-radius: 8px;
  padding: 0.18rem 0.6rem;
  transform: rotate(-3deg);
  background: rgba(255, 252, 245, 0.9);
}

@media (min-width: 720px) {
  .lab-sheet {
    max-width: 640px;
    gap: 0.85rem;
  }

  .hero h1 {
    font-size: 1.55rem;
  }

  .ratio-value {
    font-size: 1.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .swatch,
  .color-chip,
  .ratio-dial,
  .lamp {
    transition: none;
    animation: none !important;
  }
}
