:root {
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --bg: #ffffff;
  --card: #f9fafb;
  --today: #111827;
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --cal-text: clamp(9px, 0.6vw + 8px, 13px);
  --cal-header: clamp(10px, 0.7vw + 8px, 14px);
  --cal-emph: clamp(10px, 0.6vw + 8px, 13px);
  --cal-label: clamp(9px, 0.55vw + 7px, 12px);
  --cal-muted: clamp(8px, 0.5vw + 7px, 11px);
}

@media (min-width: 769px) {
  :root {
    --cal-text: clamp(10px, 0.65vw + 9px, 14px);
    --cal-header: clamp(11px, 0.75vw + 9px, 15px);
    --cal-emph: clamp(11px, 0.65vw + 9px, 14px);
    --cal-label: clamp(10px, 0.6vw + 8px, 13px);
    --cal-muted: clamp(9px, 0.55vw + 8px, 12px);
  }

  .cal th,
  .cal td {
    line-height: 1.3;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
}

.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.top { display: flex; align-items: center; gap: 16px; }
.top h1 {
  flex-shrink: 0;
  margin: 0;
}
.meta {
  color: var(--muted);
  flex: 1;
  text-align: center;
}

.meta--button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.meta--button:hover {
  color: var(--text);
}
.github-link {
  flex-shrink: 0;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.github-link:hover {
  color: var(--text);
}

.blocks { display: grid; gap: 24px; margin-top: 16px; }

.block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.block__title { margin: 0 0 12px 0; font-size: 18px; }

.cal {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

.cal th, .cal td {
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: clamp(4px, 0.6vw + 3px, 10px);
  vertical-align: top;
  overflow-wrap: break-word;
  hyphens: auto;
  font-family: var(--font-mono);
  font-size: var(--cal-text);
  line-height: 1.2;
  text-align: center;
}

.cal tr th:first-child,
.cal tr td:first-child {
  border-left: 1px solid var(--border);
}

.cal thead tr:first-child th {
  border-top: 1px solid var(--border);
}

.cal th {
  background: #f3f4f6;
  font-weight: 600;
  font-size: var(--cal-header);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.cal__head-short {
  display: none;
}

.day__emph {
  font-weight: 600;
  font-size: var(--cal-emph);
  overflow-wrap: break-word;
}
.day__label {
  font-family: var(--font-sans);
  font-size: var(--cal-label);
  white-space: nowrap;
}
.day__date {
  color: var(--muted);
  font-size: var(--cal-muted);
  margin-top: 4px;
  overflow-wrap: break-word;
}
.day__sun {
  color: var(--muted);
  font-size: var(--cal-muted);
  margin-top: 4px;
  overflow-wrap: break-word;
}

.day__sun-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.day__sun-icon {
  width: 1.2em;
  text-align: center;
  flex: 0 0 1.2em;
}

.day__sun-time {
  font-variant-numeric: tabular-nums;
}

.day--empty > * {
  visibility: hidden;
}

@media (max-width: 520px) {
  :root {
    --cal-text: clamp(7px, 1.4vw + 5px, 10px);
    --cal-header: clamp(8px, 1.6vw + 5px, 11px);
    --cal-emph: clamp(7px, 1.4vw + 5px, 10px);
    --cal-label: clamp(7px, 1.3vw + 5px, 9px);
    --cal-muted: clamp(6px, 1.2vw + 5px, 9px);
  }

  .day__date,
  .day__sun {
    white-space: normal;
    line-height: 1.15;
    overflow-wrap: anywhere;
    letter-spacing: -0.01em;
  }

  .day__date {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  .day__sun {
    display: grid;
    gap: 2px;
    justify-items: center;
    line-height: 1.1;
    width: 100%;
  }

  .day__sun-item {
    display: flex;
    align-items: center;
    gap: 1px;
    white-space: normal;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
  }

  .day__sun-icon {
    width: 1em;
    flex: 0 0 1em;
  }

  .day__label {
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
  }

  .cal th {
    letter-spacing: .02em;
  }

  .cal th, .cal td {
    padding: clamp(2px, 0.4vw + 2px, 5px);
  }

  .cal__head-full {
    display: none;
  }

  .cal__head-short {
    display: inline;
  }

  .page {
    padding: 12px;
  }

  .blocks {
    gap: 16px;
  }

  .block {
    border-radius: 10px;
    padding: 8px;
  }
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  .page {
    padding: 16px;
  }

  .block {
    padding: 10px;
    overflow-x: auto;
  }

  .cal {
    min-width: 100%;
  }
}

.day--today {
  outline: 3px solid var(--today);
  outline-offset: -3px;
}

.settings {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  display: grid;
  gap: 16px;
}

.settings.is-hidden {
  display: none;
}

.settings__copy h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.settings__copy p {
  margin: 0;
  color: var(--muted);
}

.settings__panel {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 320px);
  align-items: stretch;
}

.map {
  width: 100%;
  min-height: 240px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #e5e7eb;
}

.settings__form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

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

.settings__actions button {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.settings__actions button:hover {
  border-color: var(--text);
}

.settings__actions .secondary {
  background: #f3f4f6;
}

.settings__actions .tertiary {
  background: transparent;
}

.settings__status {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.settings__status[data-tone="warn"] {
  color: #b91c1c;
}

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

  .map {
    min-height: 220px;
  }
}
