:root {
  --bg-top: #6f8190;
  --bg-bottom: #b8c0c5;
  --surface: #ffffff;
  --text: #050505;
  --muted: #8b8b8f;
  --line: #e8e8ed;
  --accent: #ff3b4f;
  --accent-dark: #d93045;
  --sheet-shadow: 0 22px 60px rgb(24 35 45 / 28%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgb(255 255 255 / 26%), transparent 28%),
    linear-gradient(150deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  backdrop-filter: blur(18px);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 24px 16px;
}

.calendar-card {
  width: min(520px, calc(100vw - 28px));
  min-height: min(520px, calc(100vw - 28px));
  padding: clamp(28px, 7vw, 54px) clamp(26px, 7vw, 56px) clamp(28px, 7vw, 48px);
  border-radius: clamp(44px, 12vw, 72px);
  background: var(--surface);
  box-shadow: var(--sheet-shadow);
  touch-action: pan-y;
  transform-origin: center center;
  user-select: none;
}

.calendar-card.view-transitioning {
  transition: transform 320ms cubic-bezier(0.2, 0.85, 0.2, 1);
  will-change: transform;
}

.calendar-card.year-mode {
  width: min(560px, calc(100vw - 28px));
  min-height: auto;
}

.calendar-card.kanban-mode {
  width: min(1280px, calc(100vw - 28px));
  min-height: min(720px, calc(100vh - 48px));
  padding: clamp(26px, 4vw, 44px);
  border-radius: clamp(32px, 6vw, 52px);
}

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

h1 {
  margin: 0;
  color: var(--accent-dark);
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: min(220px, 100%);
  margin: -6px 0 22px;
  padding: 3px;
  border-radius: 999px;
  background: #eeeef3;
}

.section-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: min(260px, 100%);
  margin: -8px 0 22px;
  padding: 3px;
  border-radius: 999px;
  background: #eeeef3;
}

.view-option {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #6f7077;
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
}

.view-option.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
}

.icon-button,
.plain-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 30px;
  line-height: 1;
}

.icon-button:active,
.plain-button:active {
  background: #f1f1f5;
}

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

.weekdays {
  margin-bottom: 14px;
  color: var(--text);
  text-align: center;
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 760;
  line-height: 1;
}

.weekdays span:nth-child(6),
.weekdays span:nth-child(7) {
  color: var(--muted);
}

.calendar {
  row-gap: clamp(12px, 3vw, 18px);
}

.calendar.period-animating-next {
  animation: monthNext 210ms ease-out;
}

.calendar.period-animating-prev {
  animation: monthPrev 210ms ease-out;
}

.calendar.content-exit {
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.calendar.content-enter-next,
.calendar.content-enter-prev {
  animation: contentEnter 300ms cubic-bezier(0.2, 0.85, 0.2, 1);
}

.calendar.year-calendar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 14px;
}

.year-month {
  appearance: none;
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.year-month-title {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 820;
  line-height: 1;
  text-transform: uppercase;
}

.mini-weekdays,
.mini-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.mini-weekdays {
  color: var(--muted);
  font-size: 7px;
  font-weight: 760;
  line-height: 1;
  text-align: center;
}

.mini-days {
  gap: 2px 0;
}

.mini-day {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 999px;
  color: var(--text);
  font-size: 8px;
  font-weight: 720;
  line-height: 1;
}

.mini-day.weekend {
  color: var(--muted);
}

.mini-day.blank {
  visibility: hidden;
}

.mini-day.event-day:not(.today) {
  background: var(--event-color);
}

.mini-day.today {
  background: var(--accent);
  color: #fff;
}

.mini-day.today.event-day {
  outline: 2px solid var(--event-color);
  outline-offset: 1px;
}

.login {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 260px;
  text-align: center;
}

.login p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
}

.day {
  appearance: none;
  position: relative;
  display: grid;
  place-items: start center;
  min-width: 0;
  min-height: clamp(38px, 9vw, 54px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.day:disabled {
  color: inherit;
  opacity: 1;
}

.day.blank {
  visibility: hidden;
}

.day.weekend {
  color: var(--muted);
}

.day.clickable {
  cursor: pointer;
}

.date-number {
  display: inline-grid;
  place-items: center;
  width: clamp(38px, 9vw, 54px);
  height: clamp(38px, 9vw, 54px);
  border-radius: 999px;
  font-size: clamp(27px, 6.6vw, 37px);
  font-weight: 760;
  line-height: 1;
}

.day.today .date-number {
  background: var(--accent);
  color: #fff;
}

.day.event-day:not(.today) .date-number {
  background: var(--event-color);
  color: var(--text);
  box-shadow: 0 2px 7px rgb(0 0 0 / 8%);
}

.day.today.event-day .date-number {
  outline: 4px solid var(--event-color);
  outline-offset: 3px;
}

.event-dot {
  display: none;
}

.kanban-panel {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.kanban-board {
  display: grid;
  grid-auto-columns: minmax(250px, 1fr);
  grid-auto-flow: column;
  gap: 14px;
  min-height: 420px;
  max-height: calc(100vh - 260px);
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
}

.kanban-column {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-width: 230px;
  border-radius: 26px;
  padding: 14px;
  background: #f5f5f8;
  scroll-snap-align: start;
  transition:
    background 140ms ease,
    transform 140ms ease;
}

.kanban-column.drag-over {
  background: #ececf2;
  transform: translateY(-2px);
}

.kanban-column-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.kanban-column-header h2 {
  font-size: 18px;
}

.column-owner {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.2;
}

.column-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.tiny-icon-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #6f7077;
  cursor: pointer;
  font-size: 15px;
  font-weight: 760;
  line-height: 1;
  box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}

.tiny-icon-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.kanban-lane {
  display: grid;
  align-content: start;
  gap: 10px;
}

.kanban-card {
  appearance: none;
  display: grid;
  gap: 8px;
  width: 100%;
  border: 0;
  border-left: 8px solid var(--card-color);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
  color: var(--text);
  cursor: grab;
  text-align: left;
  box-shadow: 0 8px 22px rgb(24 35 45 / 10%);
}

.kanban-card:disabled {
  cursor: default;
  opacity: 1;
}

.kanban-card:active {
  cursor: grabbing;
  transform: scale(0.99);
}

.kanban-card strong {
  font-size: 16px;
  font-weight: 780;
  line-height: 1.15;
}

.kanban-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-column {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

.manage-columns-button {
  justify-self: start;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #111;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
}

.kanban-error:empty {
  display: none;
}

dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  margin: 0;
  border: 0;
  border-radius: 28px;
  padding: 0;
  background: var(--surface);
  box-shadow: 0 22px 70px rgb(24 35 45 / 34%);
  transform: translate(-50%, -50%);
}

dialog[open] {
  animation: modalIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

dialog.wide-dialog {
  width: min(560px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgb(15 24 34 / 36%);
  backdrop-filter: blur(8px);
}

dialog[open]::backdrop {
  animation: backdropIn 180ms ease-out;
}

form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.1;
}

.dialog-date {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.plain-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #f0f0f4;
  color: #5f6066;
  font-size: 24px;
  line-height: 1;
}

.date-field {
  display: none;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  border: 0;
  margin: 0;
  padding: 0;
  color: #6f7077;
  font-size: 13px;
  font-weight: 720;
}

.format-toolbar {
  display: flex;
  gap: 6px;
}

.format-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: 9px;
  background: #eeeef3;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
}

.format-button.italic {
  font-style: italic;
}

.columns-manager-list {
  display: grid;
  gap: 10px;
  max-height: min(440px, 52vh);
  overflow-y: auto;
  padding-right: 2px;
}

.manager-column-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 18px;
  padding: 12px;
  background: #f5f5f8;
}

.manager-column-meta {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.manager-column-meta strong {
  font-size: 16px;
  font-weight: 780;
  line-height: 1.15;
}

.manager-column-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.manager-column-meta em {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  font-style: normal;
  font-weight: 780;
}

.manager-column-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  flex: 0 0 auto;
  max-width: 118px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f8fb;
  color: var(--text);
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 104px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.35;
}

input:read-only {
  color: #4f5057;
}

.hint {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-choice {
  width: 34px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 5%);
}

.color-choice.selected {
  border-color: var(--text);
}

.primary-button,
.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  padding: 0 16px;
  color: #fff;
  cursor: pointer;
  font-weight: 760;
}

.primary-button {
  background: #111;
}

.danger-button {
  background: var(--accent);
}

.single-action {
  justify-content: flex-end;
}

.error {
  min-height: 18px;
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1.3;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes backdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes contentEnter {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes monthNext {
  from {
    opacity: 0;
    transform: translateX(26px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes monthPrev {
  from {
    opacity: 0;
    transform: translateX(-26px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

[hidden] {
  display: none !important;
}

@media (max-width: 420px) {
  .app {
    padding: 14px;
  }

  .calendar-card {
    min-height: calc(100vw - 28px);
  }

  .calendar-card.year-mode {
    min-height: auto;
    padding-inline: 22px;
  }

  .calendar-card.kanban-mode {
    width: calc(100vw - 28px);
    min-height: calc(100vh - 28px);
    padding: 22px;
    border-radius: 36px;
  }

  .topbar {
    margin-bottom: 18px;
  }

  .calendar {
    row-gap: 10px;
  }

  .icon-button {
    width: 30px;
    height: 30px;
    font-size: 26px;
  }

  .calendar.year-calendar {
    gap: 14px 10px;
  }

  .kanban-board {
    grid-auto-columns: minmax(220px, 82vw);
    min-height: 380px;
    max-height: calc(100vh - 240px);
  }

  .year-month-title {
    font-size: 11px;
  }

  .mini-day {
    font-size: 7px;
  }
}

@media (min-width: 900px) {
  .app {
    padding: 18px;
  }

  .calendar-card.kanban-mode {
    width: calc(100vw - 36px);
    min-height: calc(100vh - 36px);
  }

  .calendar-card.kanban-mode .kanban-board {
    max-height: calc(100vh - 245px);
  }
}

@media (orientation: landscape) and (min-width: 640px), (min-width: 760px) {
  .calendar-card.year-mode {
    width: min(760px, calc(100vw - 40px));
    padding-inline: clamp(34px, 5vw, 54px);
  }

  .calendar.year-calendar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px 18px;
  }

  .year-month-title {
    font-size: 14px;
  }

  .mini-weekdays {
    font-size: 8px;
  }

  .mini-day {
    font-size: 9px;
  }
}

@media (min-width: 1120px) {
  .calendar-card.year-mode {
    width: min(1040px, calc(100vw - 56px));
  }

  .calendar.year-calendar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 24px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
