:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6c7485;
  --accent: #2e6df6;
  --on-week: #d6f5d6;
  --off-week: #fddddd;
  --exchange: #ffe9c5;
  --border: #d9dde7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1220px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

h1 {
  margin: 0;
  font-size: 28px;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

button.secondary {
  background: white;
  border-color: var(--border);
  color: var(--text);
}

button.icon {
  padding: 6px 10px;
  border-radius: 6px;
  background: white;
  border: 1px solid var(--border);
  font-size: 18px;
}

.icon-arrow {
  width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-arrow svg {
  width: 16px;
  height: 16px;
}

button.small {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.calendar-panel {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(19, 31, 64, 0.08);
  flex: 1 1 720px;
  min-width: 0;
}

.calendar-shell {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.notes-panel {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(19, 31, 64, 0.08);
  flex: 0 0 260px;
}

.notes-title {
  margin: 0 0 12px;
  font-size: 16px;
}

.notes-summary {
  display: grid;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

.notes-summary.scroll {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 6px;
}

.notes-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.notes-item-highlight {
  background: #e7f0ff;
  border-color: #9bb7f5;
}

.notes-item-date {
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.notes-item-text {
  margin-top: 4px;
  font-size: 13px;
}

.calendar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-display {
  font-size: 20px;
  font-weight: 600;
  min-width: 180px;
}

.jump-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.jump-controls input {
  margin-left: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.calendar-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 14px;
}

.legend-item {
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.legend-item.on-week {
  background: var(--on-week);
}

.legend-item.off-week {
  background: var(--off-week);
}

.legend-item.exchange {
  background: var(--exchange);
}

.legend-item.swapped {
  background: #e6e6ff;
  border: 1px dashed #6b6bff;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekday-row div {
  text-align: center;
  font-weight: 600;
  padding: 8px 0;
  color: var(--muted);
}

.calendar-grid {
  gap: 8px;
}

.day-cell {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px;
  height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.day-cell.inactive {
  background: #f1f3f9;
  color: var(--muted);
}

.day-cell.on-week {
  background: var(--on-week);
}

.day-cell.off-week {
  background: var(--off-week);
}

.day-cell.exchange-day {
  box-shadow: inset 0 0 0 2px #f7b500;
  background: var(--exchange);
}

.day-cell.swapped-week {
  border: 2px dashed #6b6bff;
}

.day-cell.note-highlight {
  box-shadow: inset 0 0 0 2px #3d7bff;
}

.day-number {
  font-weight: 700;
}

.day-label {
  font-size: 12px;
  color: var(--muted);
}

.day-labels {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  max-height: 44px;
  overflow: hidden;
}

.holiday-label {
  font-size: 11px;
  font-weight: 600;
  color: #2457c6;
}

.note-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #333;
  cursor: default;
  max-width: 100%;
}

.note-icon::before {
  content: "";
}

.note-label {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-tooltip {
  position: absolute;
  left: 0;
  top: 18px;
  min-width: 160px;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1d2330;
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.note-icon:hover .note-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.month-edge {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.dismiss {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dismiss::before {
  content: "X";
  font-size: 12px;
  font-weight: 700;
}

.dismiss.icon::before {
  content: "";
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: min(520px, 100%);
  box-shadow: 0 20px 40px rgba(15, 20, 35, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 6px;
}

.form-row input,
.form-row select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.form-row textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  resize: vertical;
}

.form-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.swap-history {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.swap-history h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.swap-list {
  display: grid;
  gap: 10px;
}

.swap-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f8fc;
  border: 1px solid var(--border);
}

.swap-meta {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.swap-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 720px) {
  .calendar-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    align-items: stretch;
  }

  .calendar-shell {
    flex-direction: column;
  }

  .day-cell {
    min-height: 72px;
  }
}
