:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --text: #1f2933;
  --muted: #687582;
  --line: #d8dee4;
  --surface: #ffffff;
  --accent: #1769aa;
  --accent-strong: #0f4f83;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  scroll-behavior: smooth;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px clamp(12px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.detail-header {
  display: grid;
  gap: 10px;
  width: 100%;
}

.detail-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.page-title {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
  white-space: nowrap;
}

.top-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  margin-left: auto;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.top-link-button:hover {
  background: var(--accent-strong);
}

.today-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  margin-left: auto;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.today-button:hover {
  background: var(--accent-strong);
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 14px;
  color: var(--accent-strong);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.logout-link:hover {
  background: #eef4f8;
}

.day-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.day-nav a {
  color: var(--accent-strong);
  text-decoration: none;
}

.day-nav a:hover {
  text-decoration: underline;
}

.day-nav-separator {
  color: var(--muted);
}

.date-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.date-control label {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

input[type="date"] {
  min-width: 150px;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.segments {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.segment {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.segment:last-child {
  border-right: 0;
}

.segment:hover {
  background: #eef4f8;
}

.segment.active {
  background: var(--accent);
  color: #ffffff;
}

main {
  width: min(100%, 1520px);
  margin: 0 auto;
  padding: 18px clamp(10px, 2.5vw, 24px) 40px;
}

.status {
  min-height: 24px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 600;
}

.status[data-tone="error"] {
  color: var(--danger);
}

.hours {
  display: grid;
  gap: 18px;
}

.top-days {
  display: grid;
  gap: 28px;
}

.top-day {
  scroll-margin-top: 86px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.top-day h2 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0;
}

.top-day h2 a {
  color: var(--accent-strong);
  text-decoration: none;
}

.top-day h2 a:hover {
  text-decoration: underline;
}

.top-hour-rows {
  display: grid;
  gap: 8px;
}

.hour-row {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.hour-row h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.image-item {
  min-width: 0;
  margin: 0;
}

.image-item img,
.missing-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.top-image-item img {
  cursor: zoom-in;
}

.missing-image {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
}

.image-item figcaption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.top-image-item figcaption {
  display: none;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 50%;
  text-decoration: none;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.22);
}

.back-to-top:hover {
  background: var(--accent-strong);
}

.image-modal[hidden] {
  display: none;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(31, 41, 51, 0.58);
}

.image-modal-content {
  width: min(33.333vw, 720px);
  min-width: 280px;
}

.image-modal-content img {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.login-page {
  min-height: 100vh;
  background: #eef2f5;
}

.login-main {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(100%, 380px);
  padding: 26px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(31, 41, 51, 0.12);
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.login-panel input {
  height: 40px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.login-button {
  height: 40px;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-button:hover {
  background: var(--accent-strong);
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.empty-hour {
  min-height: 56px;
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 4px;
}

@media (max-width: 760px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .date-control,
  input[type="date"],
  .segments {
    width: 100%;
  }

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

  .top-link-button {
    width: 100%;
    margin-left: 0;
  }

  .today-button {
    width: 100%;
    margin-left: 0;
  }

  .logout-link {
    width: 100%;
  }

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

  .segment {
    padding: 0 8px;
  }

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

  .image-modal-content {
    width: min(86vw, 420px);
  }
}

@media (max-width: 420px) {
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
