:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --card-soft: #fbfaf7;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #111827;
  --accent-soft: #f3f0e8;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #047857;
  --green-soft: #ecfdf5;
  --yellow: #a16207;
  --yellow-soft: #fff7d6;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(214, 211, 203, 0.5), transparent 28%),
    linear-gradient(180deg, #f9f6ef 0%, var(--bg) 100%);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  color: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(17, 24, 39, 0.12);
  outline-offset: 1px;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 12px 96px;
}

.topbar,
.calendar-card,
.view-panel,
.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.view-nav {
  display: inline-flex;
  justify-self: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.nav-btn,
.seg-btn,
.mini-btn,
.text-btn,
.action-link,
.icon-btn,
.period-btn,
.cal-day {
  cursor: pointer;
}

.nav-btn,
.seg-btn,
.mini-btn,
.period-btn,
.cal-day {
  border: 1px solid var(--line-strong);
  background: #fff;
}

.nav-btn,
.seg-btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.nav-btn.active,
.seg-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.top-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: #374151;
  font-size: 13px;
}

.file-btn {
  position: relative;
}

.calendar-card {
  margin-top: 10px;
  border-radius: 16px;
  padding: 10px;
}

.calendar-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.calendar-title {
  font-size: 15px;
  font-weight: 700;
}

.calendar-legend {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-btn,
.period-btn,
.cal-day {
  border-radius: 10px;
}

.mini-btn {
  min-height: 34px;
  padding: 6px 12px;
  background: #fff;
  font-size: 12px;
}

.mini-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.icon-mini-btn {
  width: 34px;
  padding: 0;
  font-weight: 700;
}

.calendar-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

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

.cal-weekday {
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
}

.cal-day {
  position: relative;
  min-height: 94px;
  padding: 10px 12px 28px;
  text-align: left;
  transition: 0.18s ease;
}

.cal-day:hover,
.period-btn:hover,
.mini-btn:hover,
.nav-btn:hover,
.seg-btn:hover {
  transform: translateY(-1px);
}

.cal-day.muted {
  color: #9ca3af;
  background: #fcfcfd;
}

.cal-day-empty {
  background: #fff;
}

.cal-day.tone-complete {
  background: var(--green-soft);
  border-color: #a7f3d0;
}

.cal-day.tone-active {
  background: var(--yellow-soft);
  border-color: #f3d26a;
}

.cal-day.tone-overdue {
  background: var(--red-soft);
  border-color: #f4b4b4;
}

.cal-day.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.cal-day-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.cal-day-stats {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  color: var(--muted);
}

.period-btn {
  min-height: 84px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
}

.period-btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.period-complete {
  background: var(--green-soft);
  border-color: #a7f3d0;
}

.period-active {
  background: var(--yellow-soft);
  border-color: #f3d26a;
}

.period-overdue {
  background: var(--red-soft);
  border-color: #f4b4b4;
}

.period-empty {
  background: #fff;
}

.period-label {
  font-size: 14px;
  font-weight: 700;
}

.period-stats {
  align-self: flex-end;
  font-size: 11px;
  color: var(--muted);
}

.view-panel {
  margin-top: 10px;
  border-radius: 16px;
  padding: 12px;
}

.today-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.today-head h2,
.section-head h3 {
  margin: 0;
}

.today-head h2 {
  font-size: 20px;
}

.section-head h3 {
  font-size: 15px;
}

.today-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 12px;
  color: #374151;
}

.stat-chip-alert {
  color: var(--red);
  background: #fff1f1;
  border: 1px solid #fecaca;
  font-weight: 700;
}

.stat-chip-soft {
  border: 1px solid var(--line);
}

.today-columns {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 10px;
}

.compact-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--card-soft);
}

.task-list,
.project-summary,
.timeline {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.task-card.task-complete {
  border-color: #b7ead6;
  background: #f8fffb;
}

.task-card.task-active {
  border-color: #f3d26a;
  background: #fffdf4;
}

.task-card.task-overdue {
  border-color: #efb3b3;
  background: #fff9f9;
}

.task-card-summary {
  grid-template-columns: 1fr;
}

.task-card-summary .task-actions {
  display: none;
}

.task-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.task-meta,
.task-dates {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.task-actions,
.batch-actions,
.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.action-link {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
  color: var(--blue);
}

.action-link.delete {
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  line-height: 1;
}

.badge-project,
.badge-category,
.badge-date {
  background: #f3f4f6;
  color: #374151;
}

.badge-due {
  background: #fff8e7;
  color: var(--yellow);
  border-color: #f9d97b;
}

.badge-completed {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f3d0;
}

.badge-overdue-tag {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fecaca;
  font-weight: 700;
}

.badge-status-done {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f3d0;
}

.badge-status-pending {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #bfdbfe;
}

.badge-status-planned {
  background: #fff8e7;
  color: var(--yellow);
  border-color: #fde68a;
}

.badge-status-delayed {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fecaca;
  font-weight: 700;
}

.badge-status-paused {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.badge-status-abandoned {
  background: #111827;
  color: #fff;
}

.badge-priority-high {
  background: #fff4e8;
  color: #c2410c;
  border-color: #fed7aa;
}

.badge-priority-mid {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.badge-priority-normal {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.summary-tools {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) repeat(3, minmax(120px, auto)) auto;
  gap: 8px;
  align-items: center;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-output {
  margin-top: 10px;
  display: block;
  max-width: 100%;
  width: 100%;
  min-height: 86px;
  overflow: auto;
  overflow-wrap: anywhere;
}

.project-card,
.group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-soft);
}

.project-card {
  padding: 12px;
}

.project-card-head,
.group-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.project-name {
  font-size: 15px;
  font-weight: 700;
}

.project-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.project-card-body {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.project-day {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.project-day-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.project-day-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.project-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.project-line:first-child {
  padding-top: 0;
  border-top: 0;
}

.project-line-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
}

.project-line-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.group {
  overflow: hidden;
}

.group-head {
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.group-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
  background: #fff;
}

.fab-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 16px 30px rgba(17, 24, 39, 0.22);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.48);
}

.modal-card {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 20px;
}

.settings-card {
  width: min(980px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 20px;
}

.modal-subtitle,
.settings-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.icon-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.modal-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--card-soft);
}

.section-title {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.quick-row,
.entry-form,
.settings-form {
  display: grid;
  gap: 8px;
}

.quick-row {
  grid-template-columns: 1fr auto auto auto;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-actions {
  grid-column: span 4;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  min-width: 220px;
  max-width: min(90vw, 560px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.22);
}

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

  .view-nav,
  .top-actions {
    justify-self: flex-start;
  }

  .summary-tools,
  .entry-form,
  .settings-form {
    grid-template-columns: 1fr 1fr;
  }

  .summary-tools {
    grid-template-columns: 1fr 1fr;
  }

  .entry-actions {
    grid-column: span 2;
  }

  .today-columns,
  .task-card,
  .calendar-top {
    grid-template-columns: 1fr;
  }

  .task-card {
    display: grid;
  }

  .project-line {
    flex-direction: column;
  }

  .task-actions,
  .batch-actions,
  .entry-actions,
  .today-stats,
  .project-stats {
    justify-content: flex-start;
  }
}

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

  .calendar-grid,
  .calendar-grid.period-grid,
  .calendar-grid.year-grid,
  .summary-tools,
  .quick-row,
  .entry-form,
  .settings-form,
  .today-columns {
    grid-template-columns: 1fr;
  }

  .entry-actions {
    grid-column: span 1;
  }

  .calendar-actions,
  .top-actions,
  .view-nav,
  .today-head,
  .section-head,
  .group-head,
  .project-card-head,
  .task-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .fab-btn {
    right: 16px;
    bottom: 16px;
  }
}
