:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #66717e;
  --line: #dfe4ea;
  --accent: #21645a;
  --accent-soft: #e4f2ef;
  --excellent: #166c5a;
  --good: #21775f;
  --limited: #9a6819;
  --closed: #6b7280;
  --danger: #b33b4a;
  --warning: #a36516;
  --shadow: 0 12px 32px rgb(32 45 58 / 7%);
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); min-width: 320px; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid #79a9ff; outline-offset: 3px; }

.app-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgb(223 228 234 / 85%); background: rgb(245 247 250 / 92%); backdrop-filter: blur(14px); }
.header-inner { width: min(1180px, 100%); margin: auto; padding: 10px 16px; }
.brand { min-height: 48px; display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--accent); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .96rem; letter-spacing: -.015em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 99px; background: var(--closed); }
.status-dot.success { background: #1d8d68; }
.status-dot.warning { background: #d18a24; }
.status-dot.danger { background: var(--danger); }

.app-shell { width: min(1180px, 100%); margin: auto; padding: 24px 14px 64px; }
.page-heading { margin: 4px 2px 20px; display: flex; justify-content: space-between; align-items: end; }
.page-heading h1 { margin: 3px 0 5px; font-size: clamp(1.65rem, 6vw, 2.4rem); line-height: 1.2; letter-spacing: -.04em; }
.page-heading p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.65; }
.eyebrow { color: var(--accent) !important; text-transform: uppercase; letter-spacing: .09em; font-size: .69rem !important; font-weight: 800; }
.card { border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }

.health-banner { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 12px 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); }
.health-banner strong, .health-banner small { display: block; }
.health-banner strong { font-size: .84rem; }
.health-banner small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.health-banner.warning { border-color: #ead4ad; background: #fffbf2; }
.health-banner.danger { border-color: #ebc4ca; background: #fff7f8; }

.filter-bar { position: sticky; top: 69px; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgb(255 255 255 / 94%); box-shadow: 0 6px 20px rgb(32 45 58 / 6%); backdrop-filter: blur(12px); }
.filter-button { min-height: 44px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer; }
.filter-button.active { color: var(--accent); background: var(--accent-soft); }

.mobile-overview { display: grid; gap: 12px; }
.day-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.day-card-heading { min-height: 51px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); text-decoration: none; }
.day-card-heading h2 { margin: 0; font-size: .98rem; letter-spacing: -.02em; }
.day-card-heading span { color: var(--muted); font-size: 1.45rem; }
.day-spaces { padding: 3px 15px; }
.overview-space-row { padding: 13px 0 11px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 10px; }
.overview-space-row + .overview-space-row { border-top: 1px solid var(--line); }
.space-name-link { overflow-wrap: anywhere; font-size: .85rem; font-weight: 760; text-decoration: none; }
.rating { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; white-space: nowrap; font-size: .74rem; font-weight: 750; }
.rating b { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 99px; background: #eef1f4; font-size: .8rem; }
.rating.excellent { color: var(--excellent); }.rating.excellent b { background: #dff2ed; }
.rating.good { color: var(--good); }.rating.good b { background: #e3f2ed; }
.rating.limited { color: var(--limited); }.rating.limited b { background: #fbefd9; }
.rating.closed { color: var(--closed); }.rating.error { color: var(--danger); }.rating.error b { background: #f9e5e8; }

.timeline-wrap { margin-top: 16px; }
.overview-space-row .timeline-wrap { grid-column: 1 / -1; margin-top: 0; }
.timeline { position: relative; height: 14px; overflow: hidden; border-radius: 99px; background: repeating-linear-gradient(90deg, #e5e9ed 0, #e5e9ed calc(25% - 1px), #ccd3da calc(25% - 1px), #ccd3da 25%); }
.timeline::after { content: ""; position: absolute; inset: 0; border: 1px solid rgb(87 101 114 / 12%); border-radius: inherit; pointer-events: none; }
.available-segment { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, #49a98d, #267962); }
.timeline-labels { display: flex; justify-content: space-between; margin-top: 6px; color: #7b8590; font-size: .65rem; }
.timeline-wrap.compact .timeline { height: 9px; }
.timeline-wrap.compact .timeline-labels { display: none; }

.desktop-overview { display: none; overflow: hidden; }
.back-nav { margin: 2px 0 18px; }
.back-nav a { min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); font-size: .85rem; font-weight: 750; text-decoration: none; }
.detail-card { margin-bottom: 14px; padding: 16px; }
.detail-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.space-title { overflow-wrap: anywhere; font-size: 1rem; font-weight: 800; text-decoration: none; }
.detail-card-header small { display: block; margin-top: 4px; color: var(--muted); font-size: .64rem; letter-spacing: .06em; }
.interval-list { margin: 13px 0 0; padding: 0; list-style: none; }
.interval-list li { display: grid; grid-template-columns: 46px 12px 46px 1fr; gap: 4px; align-items: baseline; padding: 4px 0; font-variant-numeric: tabular-nums; font-size: .82rem; }
.interval-list small { color: var(--muted); text-align: right; }
.empty-copy { margin: 13px 0 0; color: var(--muted); font-size: .8rem; }
.error-copy { color: var(--danger); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 15px 0; }
.metrics div { padding: 10px 11px; border-radius: 11px; background: #f5f7f8; }
.metrics dt { color: var(--muted); font-size: .68rem; }
.metrics dd { margin: 3px 0 0; font-size: .87rem; font-weight: 800; }
.external-button { min-height: 46px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid #b7c7c3; border-radius: 11px; color: var(--accent); background: white; font-size: .8rem; font-weight: 780; text-decoration: none; }
.space-detail-actions { margin: -6px 0 16px; }
.space-day-list { display: grid; gap: 12px; }
.space-day { padding: 15px; }
.space-day-heading { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-decoration: none; }
.space-day-heading h2 { margin: 2px 0 0; font-size: .96rem; }
.space-day-heading small { color: var(--accent); font-size: .68rem; font-weight: 800; }
.filter-empty { padding: 18px 0; color: var(--muted); text-align: center; font-size: .8rem; }
.empty-state { padding: 42px 20px; text-align: center; }
.empty-state > span { display: grid; width: 42px; height: 42px; margin: auto; place-items: center; border-radius: 99px; color: var(--muted); background: #edf0f3; }
.empty-state h2 { margin: 14px 0 6px; font-size: 1rem; }.empty-state p { margin: 0; color: var(--muted); font-size: .8rem; }

.loading-state { display: grid; gap: 13px; }
.skeleton, .skeleton-card { border-radius: 12px; background: linear-gradient(100deg, #e8ebee 25%, #f4f6f7 45%, #e8ebee 65%); background-size: 220% 100%; animation: shimmer 1.3s infinite; }
.skeleton-title { width: 54%; height: 34px; }.skeleton-control { height: 50px; }.skeleton-card { height: 170px; }
@keyframes shimmer { to { background-position-x: -220%; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .skeleton-card { animation: none; } }

@media (min-width: 760px) {
  .app-shell { padding: 36px 24px 80px; }
  .header-inner { padding-inline: 24px; }
  .detail-card { padding: 22px; }
  .space-day-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .mobile-overview { display: none; }
  .desktop-overview { display: block; }
  .health-banner { max-width: 580px; }
  .filter-bar { position: static; width: 340px; margin-bottom: 22px; }
  .matrix { display: grid; grid-template-columns: minmax(180px, 1.4fr) repeat(var(--date-count), minmax(92px, 1fr)); }
  .matrix > * { min-width: 0; min-height: 78px; padding: 12px 9px; display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none; }
  .matrix-corner { justify-content: flex-start; color: var(--muted); font-size: .72rem; font-weight: 700; }
  .matrix-date { flex-direction: column; gap: 2px; }
  .matrix-date small { min-height: 13px; color: var(--accent); font-size: .62rem; font-weight: 800; }
  .matrix-date strong { font-size: .9rem; }.matrix-date span { color: var(--muted); font-size: .65rem; }
  .matrix-space { justify-content: flex-start; overflow-wrap: anywhere; font-size: .82rem; font-weight: 800; }
  .matrix-cell { flex-direction: column; gap: 3px; }
  .matrix-cell b { font-size: 1.2rem; }.matrix-cell small { color: var(--muted); font-size: .63rem; }
  .matrix-cell.excellent, .matrix-cell.good { color: var(--good); background: #f0f8f5; }
  .matrix-cell.limited { color: var(--limited); background: #fffaf0; }
  .matrix-cell.closed { color: var(--closed); }.matrix-cell.error { color: var(--danger); background: #fff6f7; }
  .matrix-cell.muted { color: #aeb5bc; background: #f8f9fa; }
  .legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 13px 18px; color: var(--muted); font-size: .68rem; }
  .legend span { display: flex; gap: 4px; }.legend b { color: var(--ink); }
  .detail-card { display: grid; grid-template-columns: minmax(220px, .9fr) minmax(360px, 1.5fr); gap: 12px 28px; }
  .detail-card-header, .detail-card .interval-list, .detail-card .empty-copy { grid-column: 1; }
  .detail-card .timeline-wrap, .detail-card .metrics { grid-column: 2; }
  .detail-card .timeline-wrap { grid-row: 1 / span 2; margin-top: 4px; }
  .detail-card .metrics { align-self: end; margin: 0; }
  .detail-card .external-button { grid-column: 1; justify-self: start; }
  .space-day-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
