:root {
  color-scheme: light;
  --bg: #edf7ff;
  --panel: #ffffff;
  --ink: #223142;
  --muted: #6b7b8c;
  --line: #d7e9fb;
  --primary: #3d8bff;
  --primary-dark: #1769df;
  --primary-soft: #eaf4ff;
  --cyan: #34c6d3;
  --yellow: #ffd166;
  --gold: #d99a00;
  --red: #ef476f;
  --shadow: 0 18px 45px rgba(61, 139, 255, 0.16);
  font-family: KaiTi, STKaiti, "KaiTi_GB2312", "Microsoft YaHei", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 16%, rgba(86, 178, 255, 0.28), transparent 24%),
    radial-gradient(circle at 88% 12%, rgba(52, 198, 211, 0.25), transparent 28%),
    linear-gradient(135deg, #edf7ff 0%, #f7fcff 48%, #eaf4ff 100%);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 100vh;
  padding: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  justify-content: stretch;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.brand-title {
  text-align: center;
}

.brand-title p {
  margin: 5px 0 0;
  color: var(--primary-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.22rem;
  letter-spacing: 0;
}

h3 {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.range-area {
  position: relative;
  display: flex;
  justify-content: flex-start;
}

.range-button {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 16px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-align: left;
  box-shadow: 0 10px 24px rgba(61, 139, 255, 0.12);
}

.range-button span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.range-button strong {
  font-size: 1.12rem;
  line-height: 1;
}

.range-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.range-popover h2,
.user-popover h2 {
  font-size: 1rem;
}

.range-popover label,
.user-popover label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
}

.range-popover p,
.user-popover p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.user-area {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.avatar-button {
  min-width: 86px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: white;
  font-size: 0.95rem;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(61, 139, 255, 0.22);
}

.user-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  width: max-content;
  min-width: 260px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.user-popover p {
  white-space: nowrap;
}

.reward-title {
  color: var(--primary-dark) !important;
  font-size: 0.95rem !important;
  font-weight: 900;
}

.reward-image {
  width: min(260px, calc(100vw - 56px));
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 14px;
  object-fit: contain;
  background: #ffffff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(560px, 2.35fr) minmax(260px, 0.95fr);
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0 auto;
}

.side-panel,
.content-panel,
.editor,
.calendar-panel .content-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.side-panel {
  align-self: stretch;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 12px;
  min-height: calc(100vh - 96px);
  max-height: none;
  padding: 16px;
  overflow: visible;
}

.calendar-panel {
  align-self: stretch;
  min-width: 0;
}

.calendar-panel .content-panel {
  min-height: calc(100vh - 96px);
  max-height: none;
  overflow: visible;
}

.main {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 12px;
  min-width: 0;
  min-height: calc(100vh - 96px);
  align-content: start;
}

.panel-block {
  display: grid;
  gap: 10px;
}

.results-block {
  min-height: 0;
  align-self: start;
}

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

.side-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 12px;
  background: #f2f8ff;
}

.search-wrap span {
  color: var(--primary-dark);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--ink);
  outline-color: var(--primary);
}

.search-wrap input {
  border: 0;
  padding: 10px 0;
  background: transparent;
  outline: 0;
}

textarea {
  resize: vertical;
}

.group-list,
.people-list,
.people-group {
  display: grid;
  align-content: start;
  gap: 8px;
}

.group-pill,
.person-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.group-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  font-weight: 900;
}

.group-pill strong {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.group-pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.person-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  height: 58px;
  min-height: 58px;
  padding: 8px 10px;
}

.person-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.person-card.due {
  background: #fff7dd;
  border-color: #f2c94c;
}

.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}

.person-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.person-copy strong,
.person-copy small,
.calendar-event span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tiny-dot {
  margin: 0 4px;
  color: var(--muted);
}

.person-copy small,
.muted {
  color: var(--muted);
}

.content-panel,
.editor {
  padding: 18px;
}

.upcoming-panel {
  min-height: 0;
  max-height: none;
  overflow: visible;
}

.upcoming-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.people-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 4px 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}

.people-group-head:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.people-group-head strong {
  font-size: 0.82rem;
}

.missed-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.upcoming-card {
  display: grid;
  grid-template-columns: 88px minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
}

.upcoming-card.blessed {
  opacity: 0.72;
}

.upcoming-date {
  display: flex;
  align-items: center;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 900;
}

.upcoming-date span {
  font-size: 1rem;
  font-weight: 900;
}

.upcoming-person {
  min-width: 0;
}

.upcoming-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.birthday-distance {
  display: inline-flex;
  justify-content: center;
  gap: 4px;
  justify-self: center;
  color: var(--primary-dark);
  font-size: clamp(1rem, 1.35vw, 1.28rem);
  line-height: 1.1;
  white-space: nowrap;
}

.distance-hot {
  color: var(--red);
}

.badge {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.today {
  background: #ffe9ef;
  color: var(--red);
}

.card-side {
  display: grid;
  justify-items: end;
  gap: 0;
}

.bless-button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--primary);
  color: white;
  font-size: 0.76rem;
  font-weight: 900;
}

.upcoming-card.blessed .bless-button {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.editor {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(138px, 1fr) minmax(154px, 1.1fr) minmax(134px, 1fr) minmax(180px, 1.3fr) auto;
  gap: 14px;
  align-items: end;
}

.form-heading {
  grid-column: 1 / -1;
  align-self: stretch;
}

.form-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.editor label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.field-hint {
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.group-combo {
  position: relative;
  display: block;
}

.group-combo input {
  min-width: 0;
  padding-right: 42px;
}

.group-combo select {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 9px;
  background-color: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0;
  font-weight: 900;
  outline-color: var(--primary);
}

.group-combo select:hover {
  background-color: #dbeeff;
}

.group-combo select option {
  color: var(--ink);
  font-size: 0.9rem;
}

.save-button {
  min-width: 104px;
}

.primary,
.ghost,
.danger,
.text-button,
.icon-button {
  border: 0;
  border-radius: 14px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 900;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.ghost:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.danger {
  background: #ffe9ef;
  color: var(--red);
}

.compact {
  min-height: 36px;
}

.text-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--primary-dark);
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 1.45rem;
}

.hidden {
  display: none !important;
}

.file-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: #f8fcff;
}

.empty.small {
  padding: 18px 12px;
  font-size: 0.9rem;
}

.template-body {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.template-body p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 900;
}

.template-body pre {
  margin: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #f8fcff;
  color: var(--ink);
  line-height: 1.7;
  white-space: pre-wrap;
}

.calendar-head {
  display: grid;
  grid-template-columns: 36px 36px minmax(0, 1fr) 36px 36px;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.calendar-head .icon-button {
  width: 36px;
  min-height: 36px;
  font-size: 1.12rem;
}

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

.calendar-weekdays {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.calendar-grid {
  margin-top: 8px;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
}

.calendar-day.today {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.calendar-day.has-birthday {
  border: 3px solid var(--red);
  background: #fffdf0;
  color: var(--gold);
  box-shadow: 0 0 0 3px rgba(239, 71, 111, 0.1);
}

.calendar-day.has-birthday span {
  color: var(--gold);
}

.muted-day {
  pointer-events: none;
}

.calendar-events {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.calendar-event {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  min-height: 76px;
  padding: 12px 18px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.calendar-event:hover {
  border-color: var(--red);
  background: #fff5f7;
}

.calendar-event-date {
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 900;
}

.calendar-event-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.calendar-event-copy b {
  overflow: hidden;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-copy small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog {
  width: min(640px, calc(100vw - 32px));
  border: 0;
  border-radius: 22px;
  padding: 22px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(24, 55, 91, 0.32);
}

.detail-body,
.reminder-items,
.batch-delete-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

#importTextInput,
#exportTextOutput {
  min-height: 220px;
  line-height: 1.6;
  resize: vertical;
}

.batch-delete-tools {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
}

.check-row,
.delete-row {
  cursor: pointer;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

.check-row input,
.delete-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.delete-row {
  display: grid;
  grid-template-columns: 20px 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
  background: #ffffff;
}

.delete-row:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.delete-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.delete-copy strong,
.delete-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-copy small {
  color: var(--muted);
}

.reminder-items .upcoming-card {
  grid-template-columns: 88px minmax(150px, 1fr) minmax(130px, 0.8fr) auto;
  width: 100%;
}

.detail-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #f2f8ff;
}

.detail-row span {
  color: var(--muted);
  font-weight: 900;
}

.detail-row strong {
  overflow-wrap: anywhere;
}

.dialog-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: #223142;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .calendar-panel {
    grid-column: 1 / -1;
  }

  .side-panel,
  .main,
  .calendar-panel .content-panel {
    min-height: auto;
    max-height: none;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .calendar-panel {
    order: 1;
  }

  .main {
    order: 2;
  }

  .side-panel {
    order: 3;
  }

  .editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-heading,
  .notes-field,
  .save-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    justify-content: stretch;
    gap: 10px;
    padding: 10px;
  }

  .brand-title {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .range-area {
    grid-column: 1;
    grid-row: 2;
    justify-content: stretch;
  }

  .user-area {
    grid-column: 2;
    grid-row: 2;
  }

  .range-button {
    width: 100%;
    min-width: 0;
    padding: 9px 12px;
  }

  .avatar-button {
    min-width: 76px;
    height: 40px;
    padding: 0 12px;
    font-size: 0.84rem;
  }

  .user-popover {
    width: max-content;
    max-width: calc(100vw - 20px);
    min-width: 250px;
  }

  .content-panel,
  .editor,
  .side-panel {
    padding: 14px;
  }

  .editor,
  .upcoming-list,
  .missed-list {
    grid-template-columns: 1fr;
  }

  .upcoming-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .birthday-distance {
    justify-self: start;
  }

  .calendar-event {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }
}
