:root {
  --bg: #f5f6f3;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --ink: #202621;
  --muted: #68726a;
  --line: #dbe2dd;
  --green: #23785f;
  --green-dark: #165744;
  --blue: #2f5f95;
  --red: #b34848;
  --amber: #b1731f;
  --shadow: 0 16px 35px rgba(23, 42, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #1f332e;
  color: #f5fbf7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: #d7eadc;
  color: #17362e;
  font-size: 22px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.side-panel p {
  margin: 5px 0 0;
  color: rgba(245, 251, 247, 0.72);
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  background: transparent;
  color: rgba(245, 251, 247, 0.76);
  text-align: left;
}

.tab.active,
.tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.side-panel {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.mini-label,
.eyebrow,
.pill {
  font-size: 13px;
  color: var(--muted);
}

.progress-ring {
  display: grid;
  width: 118px;
  height: 118px;
  margin: 18px auto;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#d7eadc var(--progress, 0%), rgba(255, 255, 255, 0.15) 0);
}

.progress-ring span {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border-radius: 50%;
  background: #1f332e;
  font-size: 24px;
  font-weight: 800;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

#progressBar {
  width: 0%;
  height: 100%;
  background: #d7eadc;
  transition: width 180ms ease;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin: 5px 0 0;
  font-size: 30px;
}

.top-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary,
.secondary,
.ghost,
.danger,
.task-action {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.primary {
  background: var(--green);
  color: #ffffff;
}

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

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

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metrics article,
.task-card,
.day-card,
.library-card,
.settings-form,
.note-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.task-list,
.library-list,
.timeline {
  display: grid;
  gap: 10px;
}

.task-card,
.library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.task-card.done {
  background: #f3faf6;
}

.task-title,
.library-card h4 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.task-meta,
.library-card p,
.day-card p,
.empty {
  color: var(--muted);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.task-meta span,
.pill,
.interval-preview span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: #36544a;
  font-size: 13px;
}

.task-meta .overdue {
  background: #f8e9db;
  color: var(--amber);
}

.task-action {
  background: var(--blue);
  color: #ffffff;
}

.task-card.done .task-action {
  background: #dfe8e2;
  color: #315345;
}

.open-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.open-link:hover {
  text-decoration: underline;
}

.timeline-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-date {
  color: var(--muted);
  font-weight: 700;
}

.timeline-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-items span {
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.day-card {
  min-height: 150px;
  padding: 14px;
}

.day-card h4 {
  margin: 0 0 10px;
}

.day-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.day-card li {
  font-size: 14px;
  line-height: 1.4;
}

.library-card p {
  margin: 7px 0 0;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(260px, 1fr);
  gap: 16px;
}

.settings-form,
.note-panel {
  padding: 18px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.settings-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.note-panel h3 {
  margin-top: 0;
}

.note-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.interval-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 16px;
  border-radius: 8px;
  background: #1f332e;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .side-panel {
    display: none;
  }

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

  .tab {
    text-align: center;
  }

  .main {
    padding: 20px;
  }

  .topbar,
  .task-card,
  .library-card,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .form-actions button {
    flex: 1;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

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

@media print {
  .sidebar,
  .topbar,
  .section-head button,
  .toast {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .view {
    display: none;
  }

  #view-calendar {
    display: block;
  }
}
