:root {
  --bg: #f3f8f4;
  --bg-accent: #e4f4eb;
  --bg-work: #fbf4e9;
  --bg-work-accent: #f4dcc0;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-border: rgba(82, 122, 99, 0.14);
  --text: #203126;
  --text-soft: #6f8374;
  --primary: #2f8f68;
  --primary-deep: #236f51;
  --danger: #d9485f;
  --shadow: 0 22px 64px rgba(34, 86, 58, 0.11);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font:
    "SF Pro Display", "PingFang SC", "Helvetica Neue", "Noto Sans SC",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(146, 219, 177, 0.35), transparent 32%),
    linear-gradient(180deg, #f9fcfa 0%, var(--bg) 100%);
  min-height: 100vh;
}

body.mode-work {
  background:
    radial-gradient(circle at top left, rgba(244, 188, 126, 0.26), transparent 34%),
    linear-gradient(180deg, #fffaf5 0%, var(--bg-work) 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 20px 36px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-top: 48px;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4.2vw, 48px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero p {
  max-width: 560px;
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
  font-size: 14px;
}

.eyebrow,
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sync-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -10px);
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  max-width: min(92vw, 720px);
  padding: 0 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(82, 122, 99, 0.14);
  box-shadow: 0 18px 44px rgba(53, 85, 65, 0.16);
  color: var(--text-soft);
  animation: toast-in 170ms ease-out forwards, toast-out 220ms ease-in forwards 780ms;
}

.sync-toast strong {
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.sync-toast span:last-child {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7d3cc;
  flex-shrink: 0;
}

.sync-toast.synced .sync-dot {
  background: #2f8f68;
  box-shadow: 0 0 0 6px rgba(47, 143, 104, 0.14);
}

.sync-toast.connecting .sync-dot,
.sync-toast.saving .sync-dot {
  background: #d69b58;
  box-shadow: 0 0 0 6px rgba(214, 155, 88, 0.14);
}

.sync-toast.offline .sync-dot,
.sync-toast.error .sync-dot {
  background: #d9485f;
  box-shadow: 0 0 0 6px rgba(217, 72, 95, 0.14);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -18px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(67, 110, 84, 0.08);
}

.mode-button {
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-soft);
  transition: all 180ms ease;
}

.mode-button.active {
  color: white;
  background: linear-gradient(135deg, var(--primary) 0%, #56b68e 100%);
  box-shadow: 0 10px 24px rgba(47, 143, 104, 0.25);
}

.mode-work .mode-button.active {
  background: linear-gradient(135deg, #e8a257 0%, #f0bc78 100%);
  box-shadow: 0 10px 24px rgba(226, 152, 82, 0.25);
}

.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
}

.mode-work .card {
  border-color: rgba(210, 165, 114, 0.18);
  box-shadow: 0 22px 64px rgba(169, 111, 53, 0.12);
}

.toolbar {
  padding: 18px 20px;
  margin-bottom: 18px;
}

.toolbar-top {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: center;
}

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

.person-chip {
  display: block;
  padding: 12px 10px 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(94, 129, 110, 0.15);
  box-shadow: 0 8px 20px rgba(73, 111, 89, 0.08);
  position: relative;
  width: 124px;
  min-height: 132px;
}

.mode-work .person-chip {
  border-color: rgba(208, 163, 111, 0.18);
  box-shadow: 0 8px 20px rgba(175, 123, 63, 0.1);
}

.person-chip.active {
  background: rgba(244, 247, 244, 0.98);
  border-color: var(--person-color);
  box-shadow: 0 12px 28px rgba(73, 111, 89, 0.12);
}

.mode-work .person-chip.active {
  background: rgba(255, 251, 246, 0.98);
  box-shadow: 0 12px 28px rgba(175, 123, 63, 0.14);
}

.person-chip-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  width: 100%;
  text-align: center;
  min-height: 108px;
}

.person-chip-avatar-wrap {
  display: grid;
  place-items: center;
}

.person-chip-text strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  display: block;
  word-break: break-all;
}

.person-chip-edit {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #6c8074;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  background: rgba(244, 247, 244, 0.95);
  position: absolute;
  top: 10px;
  right: 10px;
}

.person-chip-edit svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.person-chip-edit:hover {
  background: rgba(58, 88, 72, 0.08);
}

.add-person-card {
  width: 124px;
  min-height: 132px;
  border-radius: 22px;
  padding: 14px 10px;
  background: linear-gradient(135deg, rgba(228, 244, 235, 0.9), rgba(255, 255, 255, 0.95));
  border: 1px dashed rgba(56, 126, 92, 0.35);
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--primary-deep);
  align-content: center;
}

.mode-work .add-person-card {
  background: linear-gradient(135deg, rgba(250, 238, 223, 0.95), rgba(255, 255, 255, 0.96));
  border-color: rgba(223, 164, 98, 0.36);
  color: #b26d2f;
}

.add-person-card span {
  font-size: 18px;
  line-height: 1;
}

.add-person-card strong {
  font-size: 13px;
}

.person-chip-order {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--person-color);
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 6px 12px rgba(42, 58, 48, 0.18);
}

.toolbar-side,
.modal-actions-right,
.month-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-side {
  align-self: center;
  padding-top: 10px;
}

.toolbar-bottom {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(245, 249, 245, 0.98);
  color: #7a8f84;
  border: 1px solid rgba(188, 209, 196, 0.34);
  box-shadow: inset 0 -1px 0 rgba(224, 234, 228, 0.7);
  font-weight: 700;
}

.mode-work .status-pill {
  background: rgba(255, 248, 241, 0.98);
  color: #99785a;
  border-color: rgba(227, 192, 154, 0.42);
  box-shadow: inset 0 -1px 0 rgba(244, 225, 204, 0.76);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cad5cd;
}

.status-dot.rest {
  background: #4cbc87;
}

.status-dot.work {
  background: #4f7cff;
}

.highlight-pill {
  color: var(--primary-deep);
  border-color: rgba(75, 145, 115, 0.2);
  background: rgba(245, 249, 245, 0.98);
}

.mode-work .status-dot.work {
  background: #eb9d53;
}

.mode-work .highlight-pill {
  color: #a66a2f;
  border-color: rgba(222, 159, 86, 0.24);
  background: rgba(255, 248, 241, 0.98);
}

.mode-work .hero-copy h1,
.mode-work .calendar-header h2,
.mode-work .section-label,
.mode-work .eyebrow {
  color: #c57b34;
}

.mode-work .ghost-button,
.mode-work .secondary-button,
.mode-work .icon-button {
  border-color: rgba(196, 145, 90, 0.18);
}

.success-pill {
  color: #1d7f52;
}

.error-pill,
.error-text {
  color: #b43c4f;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--primary) 0%, #54b98f 100%);
  box-shadow: 0 12px 24px rgba(47, 143, 104, 0.22);
}

.secondary-button,
.ghost-button,
.icon-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(82, 122, 99, 0.14);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-button {
  color: white;
  background: linear-gradient(135deg, #dd6678 0%, var(--danger) 100%);
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 26px;
}

.calendar {
  padding: 20px;
}

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

.calendar-header h2 {
  margin: 10px 0 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.calendar-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-status {
  margin-top: 2px;
}

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

.week-header {
  margin-bottom: 8px;
  color: var(--text-soft);
  font-weight: 700;
  font-size: 13px;
}

.week-header > div {
  padding: 0 10px 10px;
}

.week-header > .weekend {
  color: #62806f;
}

.calendar-grid {
  gap: 8px;
}

.day-card {
  position: relative;
  min-height: 118px;
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(96, 127, 110, 0.12);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.day-card,
.day-card * {
  cursor: pointer;
}

.day-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(44, 83, 59, 0.1);
}

.day-card.weekend {
  background: linear-gradient(180deg, rgba(236, 248, 241, 0.96), rgba(255, 255, 255, 0.92));
}

.mode-work .day-card.weekend {
  background: linear-gradient(180deg, rgba(252, 241, 229, 0.98), rgba(255, 255, 255, 0.93));
}

.day-card.adjacent-month {
  opacity: 0.42;
}

.day-card.today {
  border-color: rgba(47, 143, 104, 0.38);
}

.day-card.filtered-match {
  border-color: transparent;
  box-shadow: none;
}

.day-card.filtered-match::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: 18px;
  background: var(--highlight-gradient);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.day-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.44);
  pointer-events: none;
}

.day-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.day-number {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.day-weeknote {
  font-size: 10px;
  color: var(--text-soft);
}

.day-badges {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 8px;
  align-items: center;
  margin-top: auto;
  align-content: end;
  grid-auto-rows: 28px;
}

.day-hint,
.more-badge {
  font-size: 12px;
  color: #c6d4cc;
}

.mode-work .day-hint,
.mode-work .more-badge {
  color: #d8c2aa;
}

.more-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(237, 244, 239, 0.95);
}

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar.fallback {
  color: white;
  font-weight: 800;
  background: var(--avatar-color);
}

.avatar.small {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar.medium {
  width: 38px;
  height: 38px;
  font-size: 16px;
  align-self: center;
}

.avatar.large {
  width: 58px;
  height: 58px;
  font-size: 32px;
}

.person-chip .avatar.large {
  box-shadow: 0 12px 30px rgba(111, 130, 120, 0.12);
}

.more-avatar {
  background: rgba(240, 245, 240, 0.98);
  color: #b8c7bd;
  font-weight: 800;
}

.mode-work .more-avatar {
  background: rgba(250, 241, 233, 0.98);
  color: #d4b89d;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 29, 23, 0.28);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: min(680px, 100%);
  max-height: min(82vh, 920px);
  overflow: auto;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(96, 127, 110, 0.15);
  box-shadow: 0 28px 80px rgba(29, 62, 44, 0.18);
  padding: 24px;
}

.modal-card.narrow {
  width: min(520px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 10px 0 0;
  font-size: 28px;
}

.search-field,
.form-grid label {
  display: grid;
  gap: 8px;
}

.search-field input,
.form-grid input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(96, 127, 110, 0.18);
  background: #f9fcfa;
  padding: 0 14px;
  color: var(--text);
}

.person-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.person-select-row {
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(96, 127, 110, 0.12);
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.person-select-row.selected {
  background: rgba(245, 250, 247, 0.98);
  border-color: var(--row-color);
}

.row-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-main > div {
  display: flex;
  align-items: center;
}

.row-main strong {
  display: block;
  font-size: 15px;
  line-height: 1;
}

.checkbox-pill {
  min-width: 68px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  background: rgba(244, 249, 245, 0.96);
}

.person-select-row.selected .checkbox-pill {
  color: var(--row-color);
  font-weight: 700;
}

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

.color-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--swatch-color);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(93, 124, 108, 0.16);
  display: inline-grid;
  place-items: center;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.color-swatch:hover {
  transform: translateY(-1px);
}

.color-swatch.active {
  box-shadow:
    0 0 0 3px rgba(47, 143, 104, 0.34),
    0 6px 12px rgba(63, 98, 78, 0.12);
}

.color-swatch.custom {
  background: linear-gradient(135deg, #7c9ff0 0%, #76c7b7 25%, #f0b35e 55%, #f28ab2 100%);
  color: white;
  font-size: 14px;
}

.file-input-shell {
  display: flex;
  align-items: center;
}

#person-avatar-input {
  width: 100%;
  min-height: 48px;
  line-height: 48px;
  padding: 0 10px;
  border-radius: 14px;
  border: 1px solid rgba(96, 127, 110, 0.18);
  background: #f9fcfa;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
}

.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-soft);
}

.avatar-preview-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-preview-content strong {
  color: var(--text);
  font-size: 16px;
}

.avatar-preview-row .avatar.large {
  width: 78px;
  height: 78px;
  font-size: 36px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.fatal-error {
  max-width: 720px;
  margin: 64px auto;
  padding: 32px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(96, 127, 110, 0.14);
  box-shadow: var(--shadow);
}

.fatal-error h1 {
  margin: 0 0 12px;
}

.fatal-error p {
  color: var(--text-soft);
}

.fatal-error pre {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 14px;
  border-radius: 14px;
  background: #f7faf8;
  color: #b43c4f;
}

@media (max-width: 1080px) {
  .hero,
  .toolbar-top,
  .calendar-header {
    flex-direction: column;
    align-items: stretch;
  }

  .calendar-grid {
    gap: 8px;
  }

  .day-card {
    min-height: 112px;
  }

  .person-chip,
  .add-person-card {
    width: min(100%, 124px);
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 14px 28px;
  }

  .hero h1 {
    font-size: 36px;
  }

  .mode-switch {
    width: 100%;
  }

  .week-header {
    font-size: 12px;
  }

  .day-card {
    min-height: 106px;
    padding: 12px;
  }

  .day-number {
    font-size: 16px;
  }

  .avatar.small {
    width: 26px;
    height: 26px;
  }

  .day-badges {
    grid-template-columns: repeat(4, 26px);
  }
}
