:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --soft-primary: #eff6ff;
  --ok-bg: #f7fee7;
  --ok-border: #bef264;
  --ok-text: #3f6212;
  --x-bg: #fff1f2;
  --x-border: #fda4af;
  --x-text: #be123c;
  --locked-bg: #f2f4f7;
  --locked-border: #d0d5dd;
  --locked-text: #98a2b3;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand::before {
  content: "○×";
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--text);
  color: white;
  font-size: 0.9rem;
  letter-spacing: -0.12em;
}

.topnav {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topnav a,
.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-weight: 700;
}

.user-pill {
  background: var(--soft-primary);
  color: var(--primary-dark);
}

.login-layout {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 130px);
}

.login-card,
.panel {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(228, 231, 236, 0.95);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-card {
  max-width: 440px;
  padding: 34px;
}

.login-mark {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 22px;
  background: var(--soft-primary);
  color: var(--primary);
  font-weight: 900;
  letter-spacing: -0.12em;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  letter-spacing: -0.04em;
}

.muted,
.hint {
  color: var(--muted);
  line-height: 1.7;
}

.compact {
  margin-bottom: 0;
}

.left {
  text-align: left;
}

.alert {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--x-bg);
  border: 1px solid var(--x-border);
  color: var(--x-text);
  font-weight: 700;
}

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

.login-form label,
.month-jump {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.login-form input,
.month-jump select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--text);
  outline: none;
}

.login-form input:focus,
.month-jump select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.primary-button,
.month-jump button,
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.primary-button:hover,
.month-jump button:hover,
.nav-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.20);
}

.nav-button.is-disabled,
.nav-button.is-disabled:hover {
  background: #eef2f7;
  color: #98a2b3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.calendar-layout {
  display: grid;
  gap: 20px;
}

.calendar-panel {
  padding: clamp(18px, 3vw, 30px);
}

.calendar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}

.legend b {
  font-size: 1.2rem;
}

.legend-o {
  color: var(--ok-text);
}

.legend-x {
  color: var(--x-text);
}

.legend-locked {
  color: var(--locked-text);
}

.month-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 14px;
  margin-bottom: 22px;
}

.month-nav .nav-button:first-child {
  justify-self: start;
}

.month-nav .nav-button:last-child {
  justify-self: end;
}

.month-jump {
  grid-template-columns: auto auto;
  align-items: end;
}

.month-jump label {
  grid-column: 1 / -1;
  font-size: 0.86rem;
}

.month-jump button,
.nav-button {
  background: var(--text);
}

.month-jump button:hover,
.nav-button:hover {
  background: #0f172a;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.weekdays {
  margin-bottom: 10px;
}

.weekday {
  padding: 10px 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.weekday.is-editable-weekday {
  color: var(--primary-dark);
}

.day-button,
.empty-day {
  min-height: 96px;
  border-radius: 20px;
}

.empty-day {
  border: 1px dashed rgba(228, 231, 236, 0.75);
  background: rgba(255, 255, 255, 0.35);
}

.day-button {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.day-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.day-button:focus-visible {
  outline: 4px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.day-button:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.day-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.day-number {
  display: inline-flex;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 900;
}

.changed-by {
  display: inline-block;
  min-width: 0;
  max-width: calc(100% - 34px);
  overflow: hidden;
  color: var(--x-text);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.changed-by.is-hidden {
  display: none;
}

.day-mark {
  align-self: center;
  justify-self: center;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  font-weight: 900;
}

.day-button.is-o {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.day-button.is-o .day-mark {
  color: var(--ok-text);
}

.day-button.is-x {
  background: var(--x-bg);
  border-color: var(--x-border);
}

.day-button.is-x .day-mark {
  color: var(--x-text);
}

.day-button.is-locked,
.day-button.is-locked:hover {
  background: var(--locked-bg);
  border-color: var(--locked-border);
  color: var(--locked-text);
  transform: none;
  box-shadow: none;
}

.day-button.is-locked .day-number,
.day-button.is-locked .day-mark {
  color: var(--locked-text);
}

.day-button.is-today .day-number {
  background: var(--text);
  color: white;
}

.day-button.is-locked.is-today .day-number {
  background: #98a2b3;
  color: white;
}

.day-button.is-loading {
  cursor: wait;
  opacity: 0.72;
}

.day-button.is-loading::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  border: 2px solid rgba(15, 23, 42, 0.10);
  border-top-color: rgba(15, 23, 42, 0.55);
  animation: spin 0.8s linear infinite;
  pointer-events: none;
}

.hint {
  margin: 18px 0 0;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  color: white;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.20);
  transition: transform 0.18s ease, opacity 0.18s ease;
  z-index: 20;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 18px, 1120px);
    padding-top: 14px;
  }

  .calendar-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav,
  .legend {
    justify-content: flex-start;
  }

  .month-nav {
    grid-template-columns: 1fr 1fr;
  }

  .month-jump {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .month-nav .nav-button:first-child,
  .month-nav .nav-button:last-child {
    justify-self: stretch;
  }

  .calendar-grid {
    gap: 6px;
  }

  .weekday {
    font-size: 0.82rem;
  }

  .day-button,
  .empty-day {
    min-height: 68px;
    border-radius: 14px;
  }

  .day-button {
    padding: 7px;
  }

  .day-heading {
    align-items: flex-start;
    gap: 3px;
  }

  .day-number {
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
  }

  .changed-by {
    max-width: calc(100% - 25px);
    font-size: 0.58rem;
  }

  .day-mark {
    font-size: 1.9rem;
  }
}

@media (max-width: 420px) {
  .calendar-panel,
  .login-card {
    border-radius: 20px;
  }

  .day-button,
  .empty-day {
    min-height: 58px;
  }

  .changed-by {
    font-size: 0.5rem;
  }

  .day-mark {
    font-size: 1.55rem;
  }
}
