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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.10);
  padding: 2rem;
}

/* ── Header ── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.cal-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  min-width: 220px;
  text-align: center;
  letter-spacing: -0.5px;
}

.nav-btn {
  background: none;
  border: 2px solid #4a5568;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #4a5568;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: #4a5568;
  color: #fff;
}

/* ── Legend ── */
.legend {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: #4a5568;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-box {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.even-box {
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
}

.legend-icon {
  font-size: 1rem;
}

/* ── Table wrapper ── */
.table-wrapper {
  overflow-x: auto;
}

#calendar {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Column widths */
#calendar .kw-col { width: 3rem; }
#calendar .so-col { width: 14%; }
#calendar th,
#calendar th.kw-col,
#calendar th.so-col {
  background: #2d3748;
  color: #fff;
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

#calendar th.kw-col {
  background: #4a5568;
  font-size: 0.75rem;
}

#calendar th.so-col {
  color: #fca5a5;
}

/* Cells */
#calendar td {
  border: 1px solid #e2e8f0;
  padding: 0.45rem 0.5rem;
  vertical-align: top;
  text-align: center;
  cursor: default;
}

.kw-cell {
  background: #f7fafc;
  color: #718096;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

/* Even weeks */
tr.even-week td {
  background-color: #fffbeb;
}

tr.even-week .kw-cell {
  background-color: #fef3c7;
  color: #92400e;
}

/* Other-month days */
td.other-month .day-number {
  color: #cbd5e0;
}

/* Today highlight */
td.today .day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #3b82f6;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-weight: 700;
}

.day-number {
  display: inline-block;
  font-size: 0.9rem;
  line-height: 28px;
  width: 28px;
  text-align: center;
}

/* Sunday cells */
td.so-col {
  text-align: left;
}

/* Flea market */
tr.even-week td.has-fleamarket {
  background-color: #f0fdf8;
}

td.has-fleamarket {
  background-color: #f0fdf4;
}

.fm-tag {
  display: block;
  font-size: 0.7rem;
  color: #16a34a;
  font-weight: 500;
  margin-top: 0.2rem;
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
}

/* Error hint */
.hint {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #9a3412;
}

.hint code {
  background: #ffedd5;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}
