:root {
  --ink: #1f2933;
  --muted: #697586;
  --paper: #fffdf7;
  --wash: #f5f1e8;
  --line: #d9d1c3;
  --dark: #10201f;
  --teal: #0f766e;
  --blue: #2f80ed;
  --amber: #f2a900;
  --coral: #df6b57;
  --green: #2f8f61;
  --shadow: 0 18px 45px rgba(35, 42, 52, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(16, 32, 31, 0.08), transparent 260px),
    var(--wash);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px;
  border-radius: 8px;
  background: var(--dark);
  color: #f8f5ec;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: #a7d4cb;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.topbar-actions,
.section-title-row,
.tabs,
.subject-row,
.mini-stats {
  display: flex;
  align-items: center;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.planner-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.plan-panel,
.subject-panel,
.work-section,
.metric,
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.95);
  box-shadow: 0 12px 30px rgba(35, 42, 52, 0.06);
}

.plan-panel,
.subject-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
}

.panel-section,
.progress-panel,
.work-section {
  padding: 18px;
  min-width: 0;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.section-title-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.save-state,
.subtle {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c9c0b2;
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efe7da;
}

.segmented button,
.tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active,
.tabs button.active {
  background: var(--dark);
  color: #fffaf0;
}

.progress-panel {
  display: grid;
  gap: 16px;
}

.progress-ring {
  --progress: 0%;
  width: 170px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--paper) 0 58%, transparent 59%),
    conic-gradient(var(--teal) var(--progress), #e5dccf 0);
}

.progress-ring div {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.progress-ring strong {
  font-size: 1.85rem;
  line-height: 1;
}

.progress-ring span,
.mini-stats span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.mini-stats {
  justify-content: space-between;
  gap: 10px;
}

.mini-stats div {
  min-width: 0;
}

.mini-stats strong {
  display: block;
  margin-top: 2px;
  font-size: 0.98rem;
}

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

.metric {
  min-height: 92px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 5px;
}

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

.metric strong {
  font-size: 2rem;
  line-height: 1;
}

.tabs {
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #efe7da;
}

.tabs button {
  padding: 0 12px;
}

.task-form,
.milestone-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.milestone-form {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto;
}

.task-form .task-title {
  grid-column: span 2;
}

.task-form .field,
.milestone-form .field,
.subject-form .field {
  margin-bottom: 0;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 850;
  letter-spacing: 0;
}

.primary-button {
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: #0b5f59;
}

.ghost-button {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.danger-button {
  border-color: rgba(223, 107, 87, 0.45);
  background: rgba(223, 107, 87, 0.12);
  color: #ffe5dc;
}

.danger-button:hover {
  background: rgba(223, 107, 87, 0.22);
}

.full {
  width: 100%;
}

.task-list,
.milestone-list,
.subject-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-item,
.milestone-item,
.subject-card {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid #ddd3c5;
  border-radius: 8px;
  background: #fffbf3;
}

.task-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  padding: 14px;
}

.task-item.done {
  opacity: 0.68;
}

.task-item.done .task-name {
  text-decoration: line-through;
}

.check {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.task-main {
  min-width: 0;
}

.task-name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.task-meta,
.milestone-meta,
.subject-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  background: #efe7da;
  padding: 2px 8px;
  color: var(--ink);
  font-weight: 800;
}

.color-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: currentColor;
}

.priority-high {
  color: var(--coral);
}

.priority-normal {
  color: var(--amber);
}

.priority-low {
  color: var(--green);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: #d8cec0;
  background: #fff6e7;
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.schedule-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

.schedule-grid {
  min-width: 900px;
  display: grid;
  grid-template-columns: 92px repeat(7, minmax(112px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffaf0;
}

.schedule-cell,
.schedule-head,
.slot-head {
  min-height: 86px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.schedule-head,
.slot-head {
  min-height: 48px;
  display: grid;
  align-items: center;
  background: #efe7da;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.schedule-head:last-child,
.schedule-cell:last-child {
  border-right: 0;
}

.schedule-cell {
  display: grid;
  gap: 8px;
  align-content: start;
}

.schedule-cell select,
.schedule-cell input {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.84rem;
}

.slot-time {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.subject-form {
  display: grid;
  gap: 12px;
}

.subject-row {
  gap: 10px;
}

.color-field {
  width: 84px;
}

.hours-field {
  flex: 1;
}

input[type="color"] {
  padding: 5px;
}

.subject-card {
  overflow: hidden;
  padding: 14px 42px 14px 14px;
}

.subject-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--subject-color, var(--blue));
}

.subject-card strong {
  overflow-wrap: anywhere;
}

.subject-card .icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
}

.milestone-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px 14px;
}

.milestone-item.done strong {
  text-decoration: line-through;
}

.milestone-main {
  min-width: 0;
}

.milestone-main strong {
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  min-height: 74px;
  place-items: center;
  border: 1px dashed #cfc3b3;
  border-radius: 8px;
  color: var(--muted);
  background: #fffaf0;
}

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

  .subject-panel {
    position: static;
    grid-column: 1 / -1;
  }

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

  .task-form {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 30%;
  }

  .planner-layout,
  .metric-grid,
  .subject-list {
    grid-template-columns: 1fr;
  }

  .plan-panel {
    position: static;
  }

  .task-form,
  .milestone-form {
    grid-template-columns: 1fr;
  }

  .task-title,
  .task-form .primary-button {
    grid-column: auto;
  }

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tabs button {
    flex: 1;
  }
}
