:root {
  --paper: #f5f2ec;
  --card: rgba(255, 254, 251, 0.92);
  --ink: #24312b;
  --muted: #7d8881;
  --line: #e5e2da;
  --moss: #687c6b;
  --moss-dark: #526556;
  --plan: #d9e6db;
  --plan-ink: #496250;
  --holiday: #e9d9cf;
  --holiday-ink: #775a4b;
  --reminder: #ddd9ea;
  --reminder-ink: #625d78;
  --shadow: 0 24px 70px rgba(57, 67, 60, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(220, 230, 216, 0.6), transparent 24rem),
    radial-gradient(circle at 88% 28%, rgba(235, 219, 208, 0.45), transparent 27rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(22px, 5vw, 76px);
  border-bottom: 1px solid rgba(111, 124, 114, 0.12);
  background: rgba(247, 244, 239, 0.75);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  position: relative;
  display: inline-block;
}

.brand-mark span {
  width: 7px;
  height: 24px;
  position: absolute;
  bottom: 3px;
  border-radius: 8px 8px 3px 3px;
  background: var(--moss);
  transform-origin: bottom;
}

.brand-mark span:nth-child(1) { left: 7px; transform: rotate(-27deg) scaleY(0.72); }
.brand-mark span:nth-child(2) { left: 14px; }
.brand-mark span:nth-child(3) { right: 6px; transform: rotate(27deg) scaleY(0.72); }

.topbar-actions,
.collaborators,
.month-controls,
.nav-group,
.legend {
  display: flex;
  align-items: center;
}

.topbar-actions { gap: 15px; }
.collaborators { gap: 0; margin-right: 5px; }

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  margin-left: -7px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  opacity: 0.38;
  transition: transform 180ms ease, opacity 180ms ease;
}

.avatar:first-child { margin-left: 0; }
.avatar:hover { transform: translateY(-2px); }
.avatar.active { opacity: 1; }
.avatar-gu { background: #809883; }
.avatar-mu { background: #b5927d; }

.pet-icon {
  width: 27px;
  height: 27px;
  overflow: visible;
  fill: none;
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pet-icon circle {
  fill: rgba(255, 255, 255, 0.96);
  stroke: none;
}

.sync-status {
  padding: 5px 8px;
  margin-left: 11px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.sync-status i {
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: #85a78d;
  box-shadow: 0 0 0 4px rgba(133, 167, 141, 0.12);
}

.sync-status.offline i { background: #c19a82; box-shadow: 0 0 0 4px rgba(193, 154, 130, 0.12); }
.sync-status.syncing i { background: #a9a3c0; animation: sync-pulse 1.2s infinite; }
.sync-status.error i { background: #b97570; }

.account-button,
.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.account-button {
  min-height: 39px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.nav-button,
.close-button {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 39px;
  height: 39px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.icon-button svg,
.nav-button svg,
.primary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button,
.secondary-button,
.today-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: var(--moss);
  box-shadow: 0 8px 20px rgba(82, 101, 86, 0.18);
}

.primary-button:hover {
  transform: translateY(-2px);
  background: var(--moss-dark);
  box-shadow: 0 12px 24px rgba(82, 101, 86, 0.23);
}

main {
  width: min(1380px, calc(100% - 44px));
  margin: 0 auto;
  padding: 64px 0 28px;
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 32px;
  padding: 0 5px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #8a998b;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.intro-copy {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.month-controls { gap: 12px; }

.today-button,
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.today-button:hover,
.secondary-button:hover {
  background: #fff;
}

.nav-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.nav-button {
  width: 43px;
  height: 42px;
}

.nav-button + .nav-button { border-left: 1px solid var(--line); }
.nav-button:hover { background: #fff; }

.calendar-card {
  overflow: hidden;
  border: 1px solid rgba(218, 216, 208, 0.86);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.agenda-panel {
  margin-top: 18px;
  padding: 24px 28px;
  border: 1px solid rgba(218, 216, 208, 0.86);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 16px 50px rgba(57, 67, 60, 0.055);
}

.agenda-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.agenda-heading .eyebrow { margin-bottom: 7px; }
.agenda-heading h3 { margin: 0; font-size: 19px; font-weight: 600; }

.agenda-list {
  display: grid;
  gap: 8px;
}

.agenda-empty {
  padding: 28px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.agenda-item {
  min-height: 58px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fffefb;
  cursor: pointer;
}

.agenda-color { width: 8px; height: 34px; border-radius: 8px; background: var(--reminder); }
.agenda-item.person-gu .agenda-color { background: #9eb3a1; }
.agenda-item.person-mu .agenda-color { background: #c7a894; }
.agenda-item.holiday { cursor: default; background: #f7f5f1; }
.agenda-main strong { display: block; margin-bottom: 3px; font-size: 13px; }
.agenda-main small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.agenda-person { color: var(--muted); font-size: 11px; }

.install-banner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 15px 18px;
  border: 1px solid #d9ded6;
  border-radius: 16px;
  background: #eef2ec;
}

.install-banner strong,
.install-banner span { display: block; }
.install-banner strong { margin-bottom: 3px; font-size: 13px; }
.install-banner span { color: var(--muted); font-size: 11px; }

.calendar-heading {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
}

.calendar-heading h2 {
  display: inline;
  margin: 0 8px 0 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.calendar-heading > div > span {
  color: var(--muted);
  font-size: 13px;
}

.legend { gap: 5px; }

.legend-item {
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
}

.dot-dog { background: #9eb3a1; }
.dot-cat { background: #c7a894; }
.dot-together { background: #a9a3c0; }

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  height: 42px;
  align-items: center;
  color: #9a9f9a;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

.calendar-grid {
  position: relative;
  background: var(--line);
  gap: 1px;
}

.day-cell {
  min-height: 128px;
  padding: 13px 10px 8px;
  position: relative;
  overflow: hidden;
  background: rgba(255, 254, 251, 0.96);
  cursor: pointer;
  transition: background 160ms ease;
  animation: cell-in 350ms both;
}

.day-cell:hover { background: #fbfaf6; }
.day-cell.outside { background: rgba(248, 246, 241, 0.72); }
.day-cell.outside .day-number { opacity: 0.32; }
.day-cell.weekend .day-number { color: #9b8173; }

.day-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
  border-radius: 50%;
  font-size: 12px;
}

.day-heading {
  min-height: 27px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.holiday-list {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: #8b918d;
  font-size: 10px;
  line-height: 1.25;
}

.holiday-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holiday-label::before {
  content: "";
  width: 3px;
  height: 3px;
  display: inline-block;
  margin: 0 5px 2px 0;
  border-radius: 50%;
  background: #a9afa9;
}

.holiday-label.tentative {
  opacity: 0.72;
}

.day-cell.today .day-number {
  color: #fff;
  background: var(--moss);
}

.day-cell.selected {
  box-shadow: inset 0 0 0 2px rgba(104, 124, 107, 0.32);
}

.events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 7px;
  position: relative;
  z-index: 1;
}

.event-chip {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 0;
  color: var(--plan-ink);
  background: var(--plan);
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  animation: event-in 300ms both;
}

.event-chip.person-gu { color: var(--plan-ink); background: var(--plan); }
.event-chip.person-mu { color: var(--holiday-ink); background: var(--holiday); }
.event-chip,
.agenda-item,
.avatar,
.icon-button,
.agenda-add {
  touch-action: manipulation;
}
.event-chip.person-both { color: var(--reminder-ink); background: var(--reminder); }
.event-chip.single { border-radius: 7px; }
.event-chip.start { margin-right: -11px; border-radius: 7px 0 0 7px; }
.event-chip.middle { margin: 0 -11px; border-radius: 0; }
.event-chip.end { margin-left: -11px; border-radius: 0 7px 7px 0; }

.event-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.event-chip.middle::before,
.event-chip.end::before { visibility: hidden; }

.event-chip:hover {
  filter: saturate(1.1) brightness(0.98);
}

.event-chip .person-tag {
  margin-left: auto;
  padding-left: 4px;
  font-size: 9px;
  opacity: 0.65;
}

.more-events {
  padding-left: 7px;
  color: var(--muted);
  font-size: 10px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 8px 0;
  color: #959c96;
  font-size: 11px;
}

footer p { margin: 0; }
footer button {
  border: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
  cursor: pointer;
}

.event-dialog {
  width: min(570px, calc(100% - 30px));
  padding: 0;
  border: 1px solid rgba(225, 222, 214, 0.9);
  border-radius: 22px;
  color: var(--ink);
  background: #fffefb;
  box-shadow: 0 30px 100px rgba(35, 45, 39, 0.2);
}

.account-dialog {
  width: min(470px, calc(100% - 30px));
  padding: 0;
  border: 1px solid rgba(225, 222, 214, 0.9);
  border-radius: 22px;
  color: var(--ink);
  background: #fffefb;
  box-shadow: 0 30px 100px rgba(35, 45, 39, 0.2);
}

.account-dialog::backdrop { background: rgba(36, 49, 43, 0.24); backdrop-filter: blur(4px); }
.account-panel { padding: 28px; }
.account-panel h3 { margin: 0; font-size: 22px; }
.account-panel label > span,
.account-panel legend { display: block; margin-bottom: 8px; color: #68726c; font-size: 12px; font-weight: 500; }
.account-panel label { display: block; margin-bottom: 18px; }
.account-panel input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fbfaf7;
}
.account-copy { color: var(--muted); font-size: 12px; line-height: 1.65; }
.full-button { width: 100%; justify-content: center; }
.two-options { grid-template-columns: 1fr 1fr; }
.signed-in-card { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 16px; padding: 12px 14px; border-radius: 11px; background: #f4f2ed; font-size: 12px; }
.signed-in-card span { color: var(--muted); }
.config-warning { padding: 10px 12px; border-radius: 9px; color: #8a6258; background: #f6eae5; font-size: 11px; }
.text-button { margin-top: 16px; color: #8b6f64; font-size: 12px; }

.event-dialog[open] { animation: dialog-in 220ms ease-out; }
.event-dialog::backdrop {
  background: rgba(36, 49, 43, 0.24);
  backdrop-filter: blur(4px);
}

.event-dialog form { padding: 28px; }

.dialog-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dialog-header h3 {
  margin: 0;
  font-size: 23px;
  font-weight: 600;
}

.close-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 26px;
}

.close-button:hover { background: #f3f1ec; }

.event-dialog label > span,
.event-dialog legend {
  display: block;
  margin-bottom: 8px;
  color: #68726c;
  font-size: 12px;
  font-weight: 500;
}

.event-dialog label { display: block; margin-bottom: 18px; }
.event-dialog small { color: #a2aaa4; font-weight: 400; }

.event-dialog input[type="text"],
.event-dialog input[type="date"],
.event-dialog input:not([type]),
.event-dialog textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fbfaf7;
  resize: vertical;
  transition: border 150ms ease, box-shadow 150ms ease;
}

.event-dialog input:focus,
.event-dialog textarea:focus {
  border-color: #9bab9d;
  box-shadow: 0 0 0 3px rgba(104, 124, 107, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.ownership-row {
  display: block;
}

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 10px;
  background: #f0eee9;
}

.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label span {
  margin: 0;
  padding: 7px 3px;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(53, 65, 57, 0.08);
}

.reminder-toggle {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.reminder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.reminder-grid .reminder-toggle {
  min-width: 0;
  margin-bottom: 0;
}

.reminder-note {
  display: block;
  margin-top: 8px;
}

.reminder-toggle span { margin: 0 !important; }
.reminder-toggle strong { display: block; margin-bottom: 2px; font-size: 12px; }
.reminder-toggle small { font-size: 10px; }
.reminder-toggle input { position: absolute; opacity: 0; }

.reminder-toggle i {
  width: 37px;
  height: 21px;
  padding: 3px;
  border-radius: 20px;
  background: #d8d8d3;
  transition: background 180ms ease;
}

.reminder-toggle i::after {
  content: "";
  width: 15px;
  height: 15px;
  display: block;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
  transition: transform 180ms ease;
}

.reminder-toggle input:checked + i { background: var(--moss); }
.reminder-toggle input:checked + i::after { transform: translateX(16px); }

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.delete-button {
  border: 0;
  color: #a36f68;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.hidden { display: none !important; }

.toast {
  min-width: 180px;
  padding: 12px 18px;
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  transform: translate(-50%, 25px);
  border-radius: 12px;
  color: #fff;
  background: rgba(51, 65, 56, 0.92);
  box-shadow: 0 12px 35px rgba(35, 45, 39, 0.2);
  font-size: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes cell-in {
  from { opacity: 0; transform: translateY(4px); }
}

@keyframes event-in {
  from { opacity: 0; transform: scaleX(0.94); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
}

@keyframes sync-pulse {
  50% { opacity: 0.35; }
}

@media (max-width: 800px) {
  .sync-status span { display: none; }
  .intro { align-items: flex-start; gap: 24px; }
  .day-cell { min-height: 105px; padding: 9px 4px 5px; }
  .event-chip { padding: 3px 4px; font-size: 9px; }
  .event-chip.start { margin-right: -5px; }
  .event-chip.middle { margin: 0 -5px; }
  .event-chip.end { margin-left: -5px; }
}

@media (max-width: 610px) {
  .topbar { min-height: 72px; height: auto; padding: 8px 12px; }
  .brand { font-size: 13px; }
  .brand-mark { transform: scale(0.88); }
  .topbar-actions { gap: 6px; }
  .collaborators { display: flex; margin: 0; }
  .avatar { width: 44px; height: 44px; min-width: 44px; }
  .sync-status { display: inline-flex; align-items: center; justify-content: center; width: 28px; min-height: 44px; padding: 0; margin-left: 5px; overflow: hidden; }
  .sync-status i { margin: 0; }
  .icon-button { width: 44px; height: 44px; min-width: 44px; }
  .account-button { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .primary-button { width: 40px; min-width: 40px; padding: 0; justify-content: center; font-size: 0; }
  .primary-button { padding: 0 13px; font-size: 12px; }
  main { width: calc(100% - 20px); padding-top: 32px; }
  .intro { display: block; }
  .month-controls { justify-content: space-between; margin-top: 24px; }
  .calendar-heading { min-height: 76px; padding: 16px; }
  .legend-item { padding: 6px 4px; }
  .legend-item .dot { margin-right: 2px; }
  .weekday-row { height: 34px; font-size: 9px; }
  .day-cell { min-height: 88px; }
  .day-number { width: 23px; height: 23px; font-size: 10px; }
  .day-heading { min-height: 23px; gap: 2px; }
  .holiday-list { font-size: 10px; }
  .holiday-label::before { display: none; }
  .events { margin-top: 4px; gap: 3px; }
  .event-chip { min-height: 20px; }
  .event-chip .person-tag { display: none; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .reminder-grid { grid-template-columns: 1fr; }
  .event-dialog form { padding: 21px; }
  .agenda-panel { padding: 18px 14px; border-radius: 18px; }
  .agenda-add { min-height: 44px; padding: 0 12px; font-size: 11px; }
  .agenda-item { min-height: 64px; }
  .install-banner { grid-template-columns: 1fr auto; }
  .install-banner .close-button { display: none; }
}

@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
