:root {
  --bg: #f6f6f6;
  --panel: #ffffff;
  --line: #d6d6d6;
  --text: #202124;
  --muted: #5f6368;
  --accent: #0f9d58;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  width: min(1400px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.start-checking {
  height: 38px;
  border: 1px solid #0d8a4b;
  border-radius: 999px;
  padding: 0 16px;
  background: #16a85c;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  background: #e9f5ee;
  color: #1e7d46;
  border: 1px solid #bfdfca;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.toolbar {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px repeat(6, auto) minmax(120px, auto);
  gap: 10px;
  align-items: end;
}

.toolbar label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.toolbar input,
.toolbar select,
.toolbar button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  font: inherit;
}

.toolbar button {
  cursor: pointer;
  font-weight: 700;
}

.summary {
  font-size: 0.9rem;
  color: var(--muted);
  align-self: center;
}

.map-stats {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  padding: 4px 5px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #243042;
  font-size: clamp(0.7rem, 2.5vw, 1.2rem);
  line-height: 1.15;
  white-space: normal;
  pointer-events: none;
  max-width: 160px;
  max-height: 105px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#xAccountDisplay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  font-weight: 600;
  font-size: clamp(0.55rem, 1.2vw, 0.7rem);
  white-space: nowrap;
  color: #243042;
  pointer-events: none;
  overflow: visible;
  display: inline-block;
}

#xAccountDisplay.xAccountDisplay-small {
  font-size: clamp(0.5rem, 1vw, 0.6rem);
}

@media (min-width: 768px) {
  #xAccountDisplay {
    font-size: 1.02rem;
  }

  #xAccountDisplay.xAccountDisplay-small {
    font-size: 0.9rem;
  }
}

.workspace {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

body.shared-preview .toolbar {
  display: none;
}

body.shared-preview .workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.shared-preview .side-pane {
  display: none;
}

body.shared-preview .pdf-check {
  pointer-events: none;
}

body.shared-preview .map-stats {
  font-size: clamp(0.75rem, 2.8vw, 1.3rem);
  padding: 5px 6px;
  line-height: 1.2;
}

.pdf-pane,
.side-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.pdf-pane {
  padding: 8px;
}

.loading {
  padding: 14px;
  color: var(--muted);
}

.pdf-stage {
  position: relative;
  width: 100%;
}

.pdf-stage img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

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

.pdf-check {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transform: translate(0, 0);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-check.hidden {
  display: none;
}

.pdf-check.checked {
  border-color: #0d8a4b;
  background: #16a85c;
}

.pdf-check.checked::after {
  content: "";
  position: static;
  width: 25%;
  height: 50%;
  border: solid #fff;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
  border-radius: 0;
}

.side-pane {
  padding: 10px;
}

.hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.x-account-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  color: var(--muted);
}

.x-account-field input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  background: #fff;
}

.x-account-field select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  background: #fff;
}

.event-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.event-item h3 {
  margin: 0;
  font-size: 0.93rem;
}

.event-item h3 a {
  color: #0b57d0;
  text-decoration: none;
}

.event-item h3 a:hover {
  text-decoration: underline;
}

.event-item p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.event-item .event-controls {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.event-item .event-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.event-item .event-controls input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
}

.event-item .state {
  margin-top: 4px;
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .event-list {
    max-height: none;
  }
}
}

.badge.region {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
}

.badge.window {
  background: rgba(180, 83, 9, 0.12);
  color: var(--accent-2);
}

.badge.status.visit,
.badge.status.exhibit,
.badge.status.both {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
}

.badge.status.unmarked {
  background: rgba(31, 41, 55, 0.06);
  color: var(--muted);
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  box-shadow: none;
  padding: 9px 12px;
}

.toggle.active.visit,
.toggle.active.exhibit {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.toggle.reset {
  background: transparent;
}

#shareCanvas {
  position: fixed;
  left: -9999px;
  top: 0;
}

@media (max-width: 980px) {
  .hero,
  .grid,
  .event-top {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    justify-items: start;
  }

  .badges {
    justify-content: flex-start;
  }
}

@media (max-width: 1200px) {
  body.shared-preview .map-stats {
    font-size: 1.0rem;
    padding: 4px 5px;
    line-height: 1.15;
    max-width: 150px;
    max-height: 95px;
  }

  .map-stats {
    font-size: 0.9rem;
    padding: 3px 4px;
    line-height: 1.15;
    max-width: 150px;
    max-height: 95px;
  }
}

@media (max-width: 980px) {
  body.shared-preview .map-stats {
    font-size: 0.9rem;
    padding: 4px 5px;
    line-height: 1.15;
    max-width: 140px;
    max-height: 90px;
  }

  .map-stats {
    font-size: 0.8rem;
    padding: 3px 4px;
    line-height: 1.15;
    max-width: 140px;
    max-height: 90px;
  }
}

@media (max-width: 768px) {
  .toolbar {
    grid-template-columns: minmax(150px, 1fr) 120px repeat(6, auto) minmax(100px, auto);
  }

  .toolbar button {
    font-size: 0.85rem;
    padding: 0 8px;
  }

  body.shared-preview .map-stats {
    font-size: 0.75rem;
    padding: 3px 4px;
    line-height: 1.15;
    max-width: 130px;
    max-height: 85px;
  }

  .map-stats {
    font-size: 0.7rem;
    padding: 3px 4px;
    line-height: 1.15;
    max-width: 130px;
    max-height: 85px;
  }
}

@media (max-width: 640px) {
  .toolbar {
    grid-template-columns: minmax(130px, 1fr) 100px repeat(6, auto) minmax(90px, auto);
  }

  .toolbar button {
    font-size: 0.8rem;
    padding: 0 6px;
    height: 36px;
  }

  .toolbar input,
  .toolbar select {
    height: 36px;
    font-size: 0.9rem;
  }

  .app-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 12px;
  }

  .hero,
  .controls,
  .results {
    padding: 16px;
    border-radius: 20px;
  }

  button,
  .field input,
  .field select {
    border-radius: 12px;
  }

  body.shared-preview .map-stats {
    font-size: 0.65rem;
    padding: 3px 4px;
    line-height: 1.1;
    max-width: 120px;
    max-height: 85px;
  }

  .map-stats {
    font-size: 0.6rem;
    padding: 2px 3px;
    line-height: 1.1;
    max-width: 120px;
    max-height: 85px;
  }
}

@media (max-width: 480px) {
  .toolbar {
    grid-template-columns: minmax(120px, 1fr) 90px repeat(6, auto) minmax(80px, auto);
  }

  .toolbar button {
    font-size: 0.75rem;
    padding: 0 5px;
    height: 34px;
  }

  .toolbar input,
  .toolbar select {
    height: 34px;
    font-size: 0.85rem;
  }

  body.shared-preview .map-stats {
    font-size: 0.55rem;
    padding: 2px 3px;
    line-height: 1.05;
    max-width: 110px;
    max-height: 80px;
  }

  .map-stats {
    font-size: 0.5rem;
    padding: 2px 3px;
    line-height: 1.05;
    max-width: 110px;
    max-height: 80px;
  }
}