:root {
  color-scheme: light;
  --canvas: #f5f4ee;
  --surface: #fff;
  --forest-900: #15382b;
  --forest-700: #29513e;
  --moss: #6b7d52;
  --text: #1e2a24;
  --text-muted: #657069;
  --border: #d9ded7;
  --amber: #b66a1b;
  --unavailable: #9b3a2d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--canvas);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 24px;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: var(--forest-700);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 40px;
}

h2 {
  font-size: 24px;
  line-height: 32px;
}

.site-header-shell {
  height: 72px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 32px);
  max-width: 1248px;
  height: 72px;
  margin: 0 auto;
  padding: 0 24px;
  border-radius: 0 0 12px 12px;
  background: var(--forest-900);
}

.site-brand,
.site-header nav a {
  color: var(--surface);
  font-weight: 700;
  text-decoration: none;
}

.site-brand {
  display: flex;
  min-height: 44px;
  align-items: center;
  font-size: 18px;
  line-height: 26px;
}

.site-header nav {
  display: flex;
  gap: 8px;
}

.site-header nav a {
  position: relative;
  display: grid;
  min-width: 48px;
  min-height: 44px;
  place-items: center;
  font-size: 14px;
  font-weight: 500;
}

.site-header nav a::after {
  position: absolute;
  bottom: 0;
  width: 32px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
  content: "";
}

.site-header nav a[aria-current="page"]::after {
  background: var(--moss);
}

.view {
  width: calc(100% - 48px);
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 0;
}

.view--list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.view-heading {
  display: grid;
  gap: 8px;
}

.view-heading > p:last-child,
.camera-area,
.camera-source,
.camera-card time,
.map-preview__content > p,
.breadcrumb,
.detail-heading p {
  color: var(--text-muted);
}

.eyebrow,
.filter-summary,
.mobile-map-heading {
  display: none;
}

.filters {
  display: grid;
  gap: 16px;
}

.filter-row,
.filter-track {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-row {
  min-height: 48px;
  gap: 16px;
}

.filter-label {
  flex: 0 0 72px;
  font-size: 13px;
  line-height: 20px;
}

.desktop-count {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 20px;
}

.filter-chip {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}

.filter-chip.is-selected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--moss);
  color: var(--surface);
  background: var(--forest-700);
}

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

.camera-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.camera-card:hover {
  border-color: var(--moss);
}

.camera-card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
}

.camera-card__body {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.camera-card h2 {
  font-size: 18px;
  line-height: 26px;
}

.camera-card__body p,
.camera-card__body time,
.camera-status {
  font-size: 13px;
  line-height: 20px;
}

.camera-type-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 3px 11px;
  border: 1px solid var(--moss);
  border-radius: 8px;
  color: var(--surface);
  background: var(--forest-700);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
}

.camera-type-badge > span {
  color: #a8b795;
  font-size: 10px;
}

.camera-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--forest-700);
}

.camera-status--delayed {
  color: var(--text);
}

.camera-status--delayed > span {
  color: var(--amber);
}

.camera-status--failed,
.camera-status--unavailable {
  color: var(--unavailable);
}

.camera-status--initial {
  color: var(--text-muted);
}

.image-frame {
  position: relative;
  overflow: hidden;
  background: var(--canvas);
}

.image-frame > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-state {
  position: absolute;
  inset: 0;
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  background: var(--canvas);
  text-align: center;
}

.image-state--unavailable {
  border-color: var(--unavailable);
  color: var(--unavailable);
  font-weight: 700;
}

.image-state--initial {
  font-weight: 700;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  background: var(--surface);
  text-align: center;
}

.empty-state button {
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--moss);
  border-radius: 8px;
  color: var(--surface);
  background: var(--forest-700);
  font-weight: 700;
  cursor: pointer;
}

.service-state,
.history-state {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  background: var(--surface);
  text-align: center;
}

.service-state--error,
.history-state--error {
  color: var(--unavailable);
}

.retry-action {
  min-height: 44px;
  padding: 0 20px;
  border: 2px solid var(--moss);
  border-radius: 8px;
  color: var(--surface);
  background: var(--forest-700);
  cursor: pointer;
  font-weight: 700;
}

.view--map {
  padding: 44px 0;
}

.map-surface,
.location-map {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--surface);
  background-image:
    linear-gradient(82deg, transparent 0 43%, rgb(217 222 215 / 90%) 43.2% 43.7%, transparent 44%),
    linear-gradient(11deg, transparent 0 31%, rgb(217 222 215 / 90%) 31.2% 31.8%, transparent 32%),
    radial-gradient(ellipse at 18% 30%, var(--moss) 0 17%, transparent 17.2%),
    radial-gradient(ellipse at 56% 58%, var(--moss) 0 21%, transparent 21.2%),
    radial-gradient(ellipse at 88% 24%, var(--forest-700) 0 14%, transparent 14.2%);
}

.map-surface {
  width: 100%;
  height: min(800px, calc(100vh - 116px));
  min-height: 620px;
}

.map-provider-label,
.map-attribution {
  position: absolute;
  z-index: 3;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 20px;
}

.map-provider-label {
  top: 23px;
  left: 84px;
}

.map-attribution {
  right: 24px;
  bottom: 16px;
  font-size: 11px;
  line-height: 16px;
}

.map-controls {
  position: absolute;
  z-index: 5;
  top: 16px;
  left: 16px;
  display: grid;
  gap: 8px;
}

.map-controls span {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 24px;
  font-weight: 700;
}

.map-surface > .empty-state {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100% - 32px));
  transform: translate(-50%, -50%);
}

.map-pin {
  position: absolute;
  z-index: 2;
  top: var(--pin-y);
  left: var(--pin-x);
  width: 48px;
  min-width: 48px;
  height: 56px;
  padding: 0;
  border: 0;
  color: transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0;
  transform: translate(-50%, -50%);
}

.map-pin::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  border: 10px solid var(--forest-700);
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.map-pin::after {
  position: absolute;
  top: 28px;
  left: 0;
  border-width: 8px 9px 0 0;
  border-style: solid;
  border-color: var(--forest-700) transparent transparent;
  content: "";
}

.map-pin.is-selected::before {
  border-color: var(--moss);
  box-shadow: 0 0 0 2px var(--forest-900);
}

.map-preview {
  position: absolute;
  z-index: 4;
  top: 16px;
  right: 16px;
  display: flex;
  width: 360px;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.map-preview__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
}

.map-preview__content {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.map-preview__content h2 {
  font-size: 18px;
  line-height: 26px;
}

.map-preview__content > p,
.map-preview__content time,
.map-preview__content .camera-status {
  font-size: 13px;
  line-height: 20px;
}

.map-preview__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.map-preview a {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  padding: 0 24px;
  border-radius: 8px;
  color: var(--surface);
  background: var(--forest-900);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.view--detail {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.breadcrumb {
  font-size: 13px;
  line-height: 20px;
}

.breadcrumb a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.breadcrumb--mobile {
  display: none;
}

.detail-heading {
  display: grid;
  gap: 12px;
}

.detail-heading > div,
.detail-metadata,
.detail-metadata > div {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-latest {
  display: grid;
  gap: 16px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
}

.detail-metadata {
  min-height: 44px;
  justify-content: space-between;
}

.detail-metadata time,
.detail-metadata > div > span:first-child {
  font-size: 16px;
}

.source-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
  font-size: 14px;
}

.source-details > span,
.parking-visibility {
  color: var(--text-muted);
}

.detail-unavailable {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--unavailable);
  font-size: 13px;
}

.history-section,
.location-section {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

.history-controls {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.date-field {
  display: grid;
  width: 320px;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 20px;
}

input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}

.capture-pager {
  display: grid;
  grid-template-columns: repeat(2, 120px);
  gap: 8px;
}

.capture-pager button {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.capture-history {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.history-item {
  display: flex;
  min-width: 0;
  height: 112px;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.history-item[aria-pressed="true"] {
  border: 2px solid var(--moss);
}

.history-item__thumbnail {
  width: 64px;
  min-width: 64px;
  height: 36px;
  border-radius: 4px;
}

.history-item__thumbnail .image-state {
  overflow: hidden;
  padding: 2px;
  font-size: 8px;
  line-height: 10px;
}

.history-item__content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  line-height: 16px;
}

.history-item__state {
  color: var(--forest-700);
}

.history-item__selected {
  color: var(--moss);
  font-weight: 700;
}

.location-section {
  gap: 16px;
}

.location-map {
  height: 320px;
}

.location-map > p,
.location-map > small,
.location-label {
  position: absolute;
  z-index: 2;
  color: var(--text-muted);
}

.location-map > p {
  top: 24px;
  left: 24px;
  font-size: 13px;
}

.location-map > small {
  right: 24px;
  bottom: 16px;
}

.location-pin {
  position: absolute;
  z-index: 2;
  top: 44%;
  left: 46%;
  width: 38px;
  height: 38px;
  border: 10px solid var(--forest-700);
  border-radius: 50%;
  background: var(--surface);
}

.location-label {
  top: calc(44% - 1px);
  left: calc(46% + 48px);
  min-width: 184px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 14px;
}

.bottom-nav {
  display: none;
}

#app > main[aria-busy="true"] {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--text-muted);
}

@media (max-width: 900px) and (min-width: 701px) {
  .camera-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .capture-history {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .site-header-shell {
    display: none;
  }

  .view {
    width: 100%;
    padding: 28px 16px 132px;
  }

  .view--list {
    gap: 16px;
  }

  .eyebrow {
    display: block;
    color: var(--forest-700);
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: 0.12em;
  }

  .view-heading > p:last-child {
    font-size: 13px;
    line-height: 20px;
  }

  .filter-summary {
    display: flex;
    height: 24px;
    align-items: center;
    justify-content: space-between;
    padding-right: 16px;
    font-size: 13px;
    font-weight: 500;
  }

  .filters {
    width: calc(100% + 16px);
    gap: 8px;
    overflow: hidden;
  }

  .filter-row {
    width: 100%;
    min-height: 48px;
    gap: 8px;
    overflow-x: auto;
    padding-right: 16px;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .filter-label {
    position: sticky;
    z-index: 2;
    left: 0;
    flex-basis: 44px;
    padding: 14px 0;
    color: var(--text-muted);
    background: var(--canvas);
    font-weight: 500;
    text-align: center;
  }

  .filter-track {
    flex: none;
  }

  .desktop-count {
    display: none;
  }

  .camera-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0 3px;
  }

  .camera-card {
    width: 100%;
  }

  .camera-card__image {
    aspect-ratio: 16 / 9;
  }

  .bottom-nav {
    position: fixed;
    z-index: 10;
    right: 16px;
    bottom: 16px;
    left: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: 64px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 -4px 12px rgb(21 56 43 / 16%);
  }

  .bottom-nav a {
    display: flex;
    min-width: 0;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
  }

  .bottom-nav a[aria-current="page"] {
    border-color: var(--moss);
    color: var(--surface);
    background: var(--forest-700);
  }

  .nav-icon {
    width: 16px;
    height: 16px;
    background: currentColor;
  }

  .nav-icon--list {
    border-radius: 2px;
  }

  .nav-icon--map {
    border-radius: 50%;
  }

  .view--map {
    padding: 0;
  }

  .mobile-map-heading {
    display: grid;
    height: 72px;
    align-content: center;
    gap: 0;
    padding: 8px 16px 4px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .mobile-map-heading h1 {
    font-size: 22px;
    line-height: 32px;
  }

  .map-surface {
    height: calc(100dvh - 72px);
    min-height: 496px;
    border: 0;
    border-radius: 0;
    background-image:
      linear-gradient(90deg, rgb(209 214 204 / 55%) 1px, transparent 1px),
      linear-gradient(rgb(209 214 204 / 55%) 1px, transparent 1px),
      radial-gradient(ellipse at 24% 22%, rgb(107 125 82 / 24%) 0 27%, transparent 27.3%),
      radial-gradient(ellipse at 75% 17%, rgb(107 125 82 / 18%) 0 26%, transparent 26.3%);
    background-size: 160px 160px, 160px 160px, auto, auto;
  }

  .map-provider-label {
    top: 20px;
    left: 16px;
  }

  .map-attribution {
    top: 210px;
    right: 16px;
    bottom: auto;
    z-index: 6;
    padding: 0 2px;
    background: rgb(245 244 238 / 82%);
  }

  .map-controls {
    top: 20px;
    right: 16px;
    left: auto;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
  }

  .map-controls span {
    border: 0;
    border-radius: 0;
  }

  .map-pin {
    left: auto;
  }

  .map-pin:nth-of-type(1) { top: 64px; left: 15%; }
  .map-pin:nth-of-type(2) { top: 104px; left: 38%; }
  .map-pin:nth-of-type(3) { top: 54px; left: 70%; }
  .map-pin:nth-of-type(4) { top: 160px; left: 22%; }
  .map-pin:nth-of-type(5) { top: 150px; left: 52%; }
  .map-pin:nth-of-type(6) { top: 132px; left: 82%; }

  .map-preview {
    top: 240px;
    right: auto;
    left: 50%;
    width: min(320px, calc(100% - 32px));
    min-height: 432px;
    gap: 0;
    padding: 0;
    transform: translateX(-50%);
  }

  .map-preview__image {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px 12px 0 0;
  }

  .map-preview__content {
    flex: 1;
    justify-content: center;
    padding: 16px;
  }

  .view--detail {
    gap: 24px;
  }

  .breadcrumb {
    min-height: 44px;
  }

  .breadcrumb a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
  }

  .breadcrumb--desktop {
    display: none;
  }

  .breadcrumb--mobile {
    display: inline;
  }

  .detail-heading h1 {
    font-size: 32px;
    line-height: 40px;
  }

  .detail-heading > div {
    gap: 12px;
  }

  .detail-image {
    aspect-ratio: 16 / 9;
  }

  .detail-metadata {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .detail-metadata > div {
    gap: 12px;
  }

  .source-details {
    width: 100%;
    justify-content: flex-start;
  }

  .history-section,
  .location-section {
    gap: 16px;
    margin-top: 0;
  }

  .history-section h2,
  .location-section h2 {
    font-size: 24px;
    line-height: 32px;
  }

  .history-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .date-field {
    width: 100%;
  }

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

  .capture-history {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .history-item {
    width: 100%;
    height: 112px;
  }

  .history-item__content {
    gap: 6px;
  }

  .location-map {
    height: 240px;
  }

  .location-pin {
    top: 42%;
    left: calc(50% - 19px);
  }

  .location-label {
    top: calc(42% + 48px);
    left: 50%;
    min-width: 0;
    transform: translateX(-50%);
    white-space: nowrap;
  }
}

@media (max-width: 700px) and (max-height: 620px) {
  .map-attribution {
    top: 184px;
  }

  .map-pin:nth-of-type(1) { top: 48px; }
  .map-pin:nth-of-type(2) { top: 84px; }
  .map-pin:nth-of-type(3) { top: 42px; }
  .map-pin:nth-of-type(4) { top: 120px; }
  .map-pin:nth-of-type(5) { top: 112px; }
  .map-pin:nth-of-type(6) { top: 100px; }

  .map-preview {
    position: fixed;
    top: auto;
    right: auto;
    bottom: 96px;
    display: grid;
    width: calc(100% - 16px);
    min-height: 0;
    grid-template-columns: 88px minmax(0, 1fr);
    padding: 8px;
  }

  .map-preview__image {
    align-self: center;
    width: 88px;
    height: 88px;
    aspect-ratio: 1;
    border-radius: 8px;
  }

  .map-preview__content {
    min-width: 0;
    gap: 3px;
    padding: 0 0 0 8px;
  }

  .map-preview__content h2 {
    font-size: 15px;
    line-height: 20px;
  }

  .map-preview__content > p,
  .map-preview__content time,
  .map-preview__content .camera-status,
  .map-preview__content .camera-type-badge {
    font-size: 10px;
    line-height: 14px;
  }

  .map-preview__content .camera-type-badge {
    min-height: 20px;
    padding: 2px 6px;
  }

  .map-preview__meta {
    gap: 2px 6px;
  }

  .map-preview a {
    min-height: 44px;
    padding: 0 12px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
