:root {
  --bg: #edf4ff;
  --bg-2: #f9fbff;
  --card: rgba(255, 255, 255, 0.94);
  --card-strong: #ffffff;
  --text: #12233d;
  --muted: #64748b;
  --line: #d8e3f1;
  --accent: #315efb;
  --accent-dark: #2447c9;
  --accent-soft: #e8eeff;
  --success: #15803d;
  --danger: #dc2626;
  --shadow: 0 22px 55px rgba(19, 34, 56, 0.10);
  --radius: 28px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(49, 94, 251, 0.15), transparent 26%),
    radial-gradient(circle at top right, rgba(236, 72, 153, 0.10), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
}
body {
  min-height: 100vh;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
code {
  background: #eef2ff;
  padding: .16rem .4rem;
  border-radius: .45rem;
}

.screen {
  width: min(1300px, 100%);
  margin: 0 auto;
  padding: 20px 16px 110px;
}
.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.card {
  background: var(--card);
  border: 1px solid rgba(216, 227, 241, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.narrow { width: min(100%, 470px); }
.login-card,
.install-wrap .card { padding: 30px; }

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}
.brand-badge {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: linear-gradient(135deg, #dbeafe 0%, #eef2ff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .86);
}

.stack { display: flex; flex-direction: column; }
.gap-12 { gap: 12px; }
.gap-14 { gap: 14px; }

label,
.field-group {
  display: grid;
  gap: 7px;
  font-weight: 700;
}
.field-label { font-size: .95rem; }

input,
textarea,
button {
  font: inherit;
  touch-action: manipulation;
}
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(19, 34, 56, 0.02);
}
input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(49, 94, 251, .55);
  box-shadow: 0 0 0 4px rgba(49, 94, 251, .12);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(49, 94, 251, 0.22);
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, border-color .16s ease, background .16s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}
button.icon-btn,
button.icon-like {
  min-width: 46px;
  padding-inline: 14px;
}
button.icon-btn {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
button.compact {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .93rem;
}
button.hidden { display: none; }
button:disabled { opacity: .65; cursor: not-allowed; }

.small { font-size: .92rem; }
.muted { color: var(--muted); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: 6px;
}
.alert {
  border-radius: 18px;
  padding: 14px 16px;
  margin: 0 0 15px;
}
.alert.error {
  background: #fee2e2;
  color: #991b1b;
}
.alert.success {
  background: #dcfce7;
  color: #166534;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  padding: 24px;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.95rem, 4vw, 2.8rem);
  line-height: 1.03;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
}
.hero-copy {
  display: grid;
  gap: 14px;
}
.hero-actions {
  display: grid;
  gap: 14px;
  align-content: center;
}
.hero-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.year-switch {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.year-badge {
  min-width: 110px;
  padding: 16px 18px;
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(135deg, #eff4ff 0%, #ffffff 100%);
  border: 1px solid var(--line);
  font-size: 1.4rem;
  font-weight: 900;
}
.header-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.month-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px;
  margin-bottom: 16px;
  position: sticky;
  top: 10px;
  z-index: 16;
}
.month-strip::-webkit-scrollbar { height: 8px; }
.month-strip::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.25);
  border-radius: 999px;
}
.month-tab {
  white-space: nowrap;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  border-radius: 999px;
  padding: 11px 16px;
}
.month-tab.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 22px rgba(49, 94, 251, 0.18);
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: start;
}
.calendar-card {
  padding: 22px;
}
.calendar-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.calendar-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
}
.month-controls {
  display: flex;
  gap: 10px;
}
.month-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-pill {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  display: grid;
  gap: 6px;
  align-content: center;
}
.stat-pill strong {
  font-size: 1.5rem;
  line-height: 1;
}
.next-stat strong { font-size: 1rem; }
.next-inline {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.weekdays div {
  text-align: center;
  font-size: .84rem;
  color: var(--muted);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
.calendar-cell {
  min-height: 140px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(245, 249, 255, 0.95));
  border: 1px solid var(--line);
  box-shadow: none;
  color: inherit;
}
.calendar-cell:hover {
  box-shadow: 0 16px 30px rgba(19, 34, 56, 0.08);
}
.calendar-cell.outside {
  opacity: .55;
}
.calendar-cell.today {
  border-color: rgba(49, 94, 251, 0.55);
  box-shadow: inset 0 0 0 1px rgba(49, 94, 251, 0.15);
}
.calendar-cell.selected {
  border-color: rgba(49, 94, 251, 0.75);
  box-shadow: inset 0 0 0 2px rgba(49, 94, 251, 0.18);
}
.calendar-cell.drag-over {
  border-style: dashed;
  border-color: rgba(49, 94, 251, 0.8);
  background: rgba(232, 238, 255, 0.9);
}
.cell-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.cell-number {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1rem;
  background: rgba(49, 94, 251, 0.08);
}
.calendar-cell.today .cell-number {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
}
.cell-counter {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(19, 34, 56, 0.06);
  color: var(--muted);
  font-weight: 900;
  font-size: .84rem;
}
.cell-events {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 0;
}
.mini-event,
.more-chip {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(216, 227, 241, 0.95);
  box-shadow: inset 4px 0 0 var(--event, #64748B);
  overflow: hidden;
}
.mini-event {
  cursor: pointer;
}
.mini-event-time {
  font-size: .73rem;
  font-weight: 900;
  color: var(--muted);
}
.mini-event-title {
  display: block;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}
.more-chip {
  box-shadow: none;
  color: var(--muted);
  font-weight: 800;
  align-items: center;
}

.sidebar-stack {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 86px;
}
.detail-card,
.legend-card {
  padding: 22px;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.detail-head h2,
.legend-card h2 {
  margin: 0;
}
.detail-list {
  display: grid;
  gap: 12px;
}
.move-banner {
  display: grid;
  gap: 10px;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(232, 238, 255, 0.95);
  border: 1px solid #d7e3ff;
}
.empty-detail {
  border: 1px dashed #c5d5ea;
  border-radius: 22px;
  padding: 22px;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}
.empty-detail p { margin: 0; }
.empty-detail-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--accent);
  background: rgba(49, 94, 251, 0.10);
}

.detail-event {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: inset 5px 0 0 var(--event);
}
.detail-event-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.detail-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  font-weight: 900;
  color: var(--muted);
}
.detail-event h3 {
  margin: 4px 0 0;
  font-size: 1.06rem;
  line-height: 1.25;
}
.detail-time {
  font-weight: 900;
  font-size: .92rem;
  white-space: nowrap;
}
.detail-note {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}
.detail-meta {
  color: var(--muted);
  font-size: .86rem;
}
.detail-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-head {
  margin-bottom: 14px;
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
  font-weight: 700;
}
.legend-swatch {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--swatch);
  display: inline-block;
  flex: 0 0 auto;
}
.install-hint {
  margin: 14px 0 0;
}

.dialog {
  width: min(100% - 24px, 760px);
  padding: 0;
  border: 0;
  border-radius: 30px;
  background: var(--card-strong);
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.24);
}
.dialog::backdrop { background: rgba(15, 23, 42, 0.48); }
.dialog form { padding: 24px; }
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dialog-head h2 { margin: 0; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.preset-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
  justify-content: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.preset-btn.active {
  border-color: var(--preset);
  box-shadow: inset 0 0 0 2px var(--preset);
  background: #fff;
}
.preset-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--preset);
  flex: 0 0 auto;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input { width: auto; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 999px;
  font-size: 1.8rem;
  line-height: 1;
  display: none;
  place-items: center;
  z-index: 20;
}

.install-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.install-wrap {
  width: min(100%, 760px);
  padding: 24px;
}
.install-form { display: grid; gap: 14px; }

@media (max-width: 1180px) {
  .planner-layout {
    grid-template-columns: 1fr;
  }
  .sidebar-stack {
    position: static;
  }
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .header-buttons {
    justify-content: flex-start;
  }
  .month-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root { --radius: 24px; }
  .screen { padding: 12px 10px 94px; }
  .login-card,
  .calendar-card,
  .detail-card,
  .legend-card {
    padding: 18px;
  }
  .month-strip {
    top: 6px;
    padding: 10px;
  }
  .year-switch {
    grid-template-columns: 1fr;
  }
  .year-badge {
    width: 100%;
  }
  .calendar-head,
  .detail-head,
  .detail-event-top {
    flex-direction: column;
    align-items: stretch;
  }
  .calendar-grid {
    gap: 6px;
  }
  .weekdays {
    gap: 6px;
  }
  .calendar-cell {
    min-height: 92px;
    padding: 8px;
    border-radius: 18px;
  }
  .mini-event-title {
    display: none;
  }
  .mini-event {
    padding: 7px 8px;
  }
  .cell-number {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: .95rem;
  }
  .legend-grid,
  .preset-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
  .dialog-actions {
    flex-direction: column;
  }
  .fab {
    display: grid;
  }
  .header-buttons button:nth-child(2) {
    display: none;
  }
}

@media (max-width: 520px) {
  .hero h1 {
    font-size: 1.8rem;
  }
  .weekdays div {
    font-size: .72rem;
  }
  .calendar-cell {
    min-height: 84px;
  }
  .mini-event-time {
    font-size: .68rem;
  }
  .cell-counter {
    min-width: 24px;
    height: 24px;
    font-size: .76rem;
  }
}