:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --line: #dfe5dc;
  --line-strong: #cfd8ce;
  --ink: #1d2927;
  --muted: #69736f;
  --brand: #176b5b;
  --brand-dark: #0f5549;
  --brand-soft: #e1f1eb;
  --coral: #d9644d;
  --coral-soft: #fae8e4;
  --amber: #c98a1c;
  --amber-soft: #faefd9;
  --blue: #4c6fb0;
  --blue-soft: #e7edf8;
  --purple: #77589c;
  --purple-soft: #f0eaf7;
  --green: #2e7d5b;
  --green-soft: #e4f3ea;
  --danger: #b83f3b;
  --shadow: 0 12px 30px rgba(35, 50, 43, 0.06);
  --sidebar-width: 246px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

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

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

button {
  color: inherit;
}

button,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(23, 107, 91, 0.18);
  outline-offset: 1px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 22px 18px;
  background: #fbfcf9;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
  font-family: "STSong", "SimSun", serif;
  font-size: 21px;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  color: #58625e;
  background: transparent;
  border: 0;
  border-radius: 7px;
  text-align: left;
  transition: 150ms ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  color: var(--ink);
  background: #f0f4ef;
}

.nav-item.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 700;
}

.sidebar-target {
  margin-top: auto;
  padding: 16px;
  background: #f2f5ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.eyebrow {
  display: block;
  margin: 0 0 5px;
  color: #8a928e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.sidebar-target strong {
  display: block;
  font-size: 14px;
}

.sidebar-target p {
  margin: 4px 0 15px;
  color: var(--muted);
  font-size: 12px;
}

.target-countdown {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.target-countdown span {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.target-countdown b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.sidebar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 6px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 11px;
}

.sidebar-action:hover {
  color: var(--ink);
  background: #f3f5f1;
  border-color: var(--line);
}

.sidebar-action svg {
  width: 14px;
  height: 14px;
}

.main {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 15px 34px;
  background: rgba(244, 246, 242, 0.92);
  border-bottom: 1px solid rgba(223, 229, 220, 0.75);
  backdrop-filter: blur(13px);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.topbar-kicker {
  color: #88918d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 13px;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
  padding: 6px 9px;
  color: #68736e;
  background: #f7f9f6;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-chip:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: #fff;
}

.sync-chip svg {
  width: 14px;
  height: 14px;
}

.sync-chip.syncing svg {
  animation: syncPulse 900ms ease-in-out infinite alternate;
}

.sync-chip.online {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-color: #c8e3d9;
}

.sync-chip.error {
  color: var(--danger);
  background: #faeae8;
  border-color: #f0cdc9;
}

@keyframes syncPulse {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

.today-label {
  color: var(--muted);
  font-size: 13px;
}

.mobile-menu {
  display: none !important;
}

.view-stack {
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px 34px 50px;
}

.view {
  display: none;
  animation: viewIn 220ms ease both;
}

.view.active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-intro,
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.dashboard-intro h2,
.section-heading h2 {
  margin: 0 0 7px;
  font-family: "STSong", "SimSun", serif;
  font-size: clamp(25px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.dashboard-intro p:not(.eyebrow),
.section-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.primary-btn,
.secondary-btn,
.text-btn,
.danger-text-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 7px;
  transition: 150ms ease;
  white-space: nowrap;
}

.primary-btn {
  min-height: 39px;
  padding: 9px 15px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 5px 14px rgba(23, 107, 91, 0.16);
  font-size: 13px;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.primary-btn.full {
  width: 100%;
}

.secondary-btn {
  min-height: 37px;
  padding: 8px 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 700;
}

.secondary-btn:hover {
  border-color: #aab7ae;
  background: #fafcf9;
}

.text-btn {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--brand);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.text-btn:hover {
  background: var(--brand-soft);
}

.danger-text-btn {
  min-height: 35px;
  padding: 7px 9px;
  color: var(--danger);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.danger-text-btn:hover {
  background: #faeae8;
}

.icon-btn {
  width: 37px;
  height: 37px;
  color: #65706b;
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: #fafcf9;
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn.small svg {
  width: 15px;
  height: 15px;
}

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

.metric-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 91px;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(28, 42, 36, 0.02);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--metric-color, var(--brand));
  background: var(--metric-bg, var(--brand-soft));
  border-radius: 7px;
}

.metric-icon svg {
  width: 20px;
  height: 20px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric-card strong {
  display: block;
  margin-top: 3px;
  font-size: 21px;
  letter-spacing: -0.03em;
}

.metric-card small {
  align-self: start;
  padding: 4px 6px;
  color: var(--muted);
  background: #f3f5f2;
  border-radius: 5px;
  font-size: 10px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(290px, 0.78fr);
  gap: 17px;
}

.right-column {
  display: grid;
  align-content: start;
  gap: 17px;
}

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(28, 42, 36, 0.02);
}

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

.panel-head.compact {
  margin-bottom: 15px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.panel-icon {
  color: var(--coral);
}

.date-navigator,
.date-picker-inline {
  display: flex;
  align-items: center;
  gap: 5px;
}

.task-timeline {
  display: grid;
  gap: 9px;
}

.task-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 75px;
  padding: 11px 10px 11px 12px;
  background: var(--surface-soft);
  border: 1px solid #e8ece7;
  border-left: 3px solid var(--subject-color, var(--brand));
  border-radius: 7px;
  transition: 150ms ease;
}

.task-item:hover {
  border-color: #d9e0d8;
  box-shadow: 0 7px 18px rgba(35, 50, 43, 0.05);
}

.task-item.completed {
  opacity: 0.7;
}

.task-check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: transparent;
  background: #fff;
  border: 1.5px solid #bcc8bf;
  border-radius: 50%;
}

.task-check svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.task-item.completed .task-check {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

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

.task-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.subject-badge {
  flex: 0 0 auto;
  padding: 3px 6px;
  color: var(--subject-color, var(--brand));
  background: var(--subject-bg, var(--brand-soft));
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.task-title {
  overflow: hidden;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  text-decoration-color: #9ea9a3;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  color: #7b8580;
  font-size: 11px;
}

.task-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.task-meta svg {
  width: 13px;
  height: 13px;
}

.task-actions {
  display: flex;
  align-items: center;
}

.task-actions button {
  width: 30px;
  height: 30px;
  color: #88918d;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.task-actions button:hover {
  color: var(--ink);
  background: #edf1ec;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 30px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  color: #9aa59f;
}

.empty-state h4 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 14px;
}

.empty-state p {
  max-width: 350px;
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.65;
}

.progress-ring-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}

.progress-ring {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  background: conic-gradient(var(--brand) var(--progress, 0%), #e9ede8 0);
  border-radius: 50%;
}

.progress-ring::before {
  position: absolute;
  width: 82px;
  height: 82px;
  content: "";
  background: var(--surface);
  border-radius: 50%;
}

.progress-ring > div {
  position: relative;
  z-index: 1;
  text-align: center;
}

.progress-ring strong,
.progress-ring span {
  display: block;
}

.progress-ring strong {
  font-size: 22px;
  letter-spacing: -0.04em;
}

.progress-ring span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.daily-facts {
  display: grid;
  gap: 11px;
  width: 100%;
}

.daily-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf0ec;
}

.daily-facts > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.daily-facts span {
  color: var(--muted);
  font-size: 11px;
}

.daily-facts strong {
  font-size: 13px;
}

.week-total {
  color: var(--brand);
  font-size: 17px;
}

.mini-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 9px;
  height: 116px;
  padding-top: 6px;
}

.mini-bar-wrap {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  height: 100%;
  text-align: center;
}

.mini-bar-track {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  height: 86px;
}

.mini-bar {
  width: 18px;
  min-height: 4px;
  background: var(--brand);
  border-radius: 4px 4px 2px 2px;
  transition: height 260ms ease;
}

.mini-bar-wrap.is-today .mini-bar {
  background: var(--coral);
}

.mini-bar-wrap span {
  margin-top: 7px;
  color: #8a938e;
  font-size: 9px;
}

.mini-bar-value {
  position: absolute;
  top: -3px;
  left: 50%;
  color: var(--muted);
  font-size: 8px;
  transform: translateX(-50%);
}

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

.planner-form-panel {
  position: sticky;
  top: 99px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span {
  color: #58625e;
  font-size: 11px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
.date-picker-inline input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fbfcfa;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  font-size: 13px;
  transition: 150ms ease;
}

.field textarea {
  line-height: 1.65;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.date-picker-inline input:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.09);
}

.planner-date-head {
  align-items: flex-end;
}

.date-picker-inline input {
  width: auto;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 11px;
}

.day-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 17px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.day-summary-item {
  padding: 12px;
  background: var(--surface-soft);
}

.day-summary-item span,
.day-summary-item strong {
  display: block;
}

.day-summary-item span {
  color: var(--muted);
  font-size: 10px;
}

.day-summary-item strong {
  margin-top: 3px;
  font-size: 14px;
}

.planner-timeline .task-item {
  min-height: 82px;
}

.legend-inline {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.legend-inline span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-dot.education {
  background: var(--coral);
}

.legend-dot.politics {
  background: var(--amber);
}

.legend-dot.english {
  background: var(--blue);
}

.legend-dot.writing {
  background: var(--purple);
}

.subject-progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.subject-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.subject-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  content: "";
  background: var(--subject-color);
}

.subject-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.subject-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-monogram {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--subject-color);
  background: var(--subject-bg);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.subject-title h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.subject-title p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.subject-percent {
  color: var(--subject-color);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.subject-total-bar {
  height: 7px;
  margin-bottom: 20px;
  overflow: hidden;
  background: #edf0ec;
  border-radius: 5px;
}

.subject-total-bar span {
  display: block;
  height: 100%;
  background: var(--subject-color);
  border-radius: inherit;
  transition: width 220ms ease;
}

.stage-list {
  display: grid;
  gap: 13px;
}

.stage-row {
  display: grid;
  grid-template-columns: minmax(105px, 1fr) 90px 118px 38px 28px;
  align-items: center;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid #edf0ec;
}

.stage-name,
.stage-total {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
}

.stage-name:hover,
.stage-total:hover {
  background: #f7f9f6;
  border-color: var(--line);
}

.stage-name:focus,
.stage-total:focus {
  background: #fff;
  border-color: var(--brand);
  outline: 0;
}

.stage-total-wrap {
  position: relative;
}

.stage-total {
  padding-right: 35px;
  text-align: right;
}

.stage-total-wrap span {
  position: absolute;
  top: 50%;
  right: 8px;
  color: #9aa29e;
  font-size: 10px;
  transform: translateY(-50%);
}

.stage-quantity {
  display: grid;
  grid-template-columns: 27px 44px 27px;
  align-items: center;
  gap: 4px;
}

.stage-quantity button {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  color: var(--subject-color);
  background: var(--subject-bg);
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.stage-quantity button:hover {
  border-color: var(--subject-color);
}

.stage-quantity button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.stage-quantity strong {
  font-size: 14px;
  text-align: center;
}

.stage-percent {
  color: var(--subject-color);
  font-size: 11px;
  text-align: right;
}

.stage-delete {
  width: 28px;
  height: 28px;
  color: #9aa29e;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.stage-delete:hover {
  color: var(--danger);
  background: #faeeec;
}

.stage-delete svg {
  width: 14px;
  height: 14px;
}

.add-stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding: 7px 9px;
  color: var(--subject-color);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.add-stage-btn:hover {
  background: var(--subject-bg);
  border-color: var(--subject-color);
}

.add-stage-btn svg {
  width: 13px;
  height: 13px;
}

.essay-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.92fr);
  align-items: start;
  gap: 17px;
}

.essay-editor-panel,
.report-panel {
  min-height: 680px;
}

.essay-editor-panel .panel-head {
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #eef1ed;
  border-radius: 6px;
}

.essay-mode-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.essay-subtype-control {
  background: var(--purple-soft);
}

.essay-subtype-control button.active {
  color: var(--purple);
}

.essay-subtype-control[hidden] {
  display: none;
}

.segmented button {
  min-width: 63px;
  padding: 6px 9px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(35, 50, 43, 0.1);
}

.essay-textarea {
  min-height: 340px !important;
  font-family: "Georgia", "Times New Roman", serif !important;
  font-size: 14px !important;
  line-height: 1.8 !important;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.writing-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  color: var(--muted);
  font-size: 10px;
}

.writing-counts strong {
  color: var(--ink);
}

.empty-report {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 600px;
  padding: 30px;
  text-align: center;
}

.empty-report-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  color: var(--purple);
  background: var(--purple-soft);
  border-radius: 50%;
}

.empty-report-icon svg {
  width: 23px;
  height: 23px;
}

.empty-report h3 {
  margin: 0 0 7px;
}

.empty-report p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.report-header {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  background: conic-gradient(var(--score-color, var(--brand)) var(--score, 0%), #e7ece7 0);
  border-radius: 50%;
}

.score-ring::before {
  position: absolute;
  width: 82px;
  height: 82px;
  content: "";
  background: #fff;
  border-radius: 50%;
}

.score-ring > div {
  position: relative;
  z-index: 1;
  text-align: center;
}

.score-ring strong {
  display: block;
  font-size: 27px;
  letter-spacing: -0.05em;
}

.score-ring span {
  color: var(--muted);
  font-size: 9px;
}

.report-summary h3 {
  margin: 0 0 7px;
  font-size: 18px;
}

.report-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.report-meta span {
  padding: 4px 7px;
  color: #5d6863;
  background: #f2f5f1;
  border-radius: 4px;
  font-size: 9px;
}

.dimension-list {
  display: grid;
  gap: 12px;
  margin: 19px 0;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.dimension-row {
  display: grid;
  grid-template-columns: 89px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.dimension-row > span {
  color: #5b6560;
  font-size: 11px;
}

.dimension-track {
  height: 6px;
  overflow: hidden;
  background: #e9ede8;
  border-radius: 5px;
}

.dimension-track span {
  display: block;
  height: 100%;
  background: var(--bar-color, var(--brand));
  border-radius: inherit;
}

.dimension-row b {
  font-size: 11px;
  text-align: right;
}

.report-section {
  margin-top: 20px;
}

.report-section h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 11px;
  font-size: 13px;
}

.report-section h4 span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.issue-list {
  display: grid;
  gap: 8px;
}

.issue-item {
  padding: 10px 11px;
  background: var(--surface-soft);
  border-left: 3px solid var(--issue-color, var(--amber));
  border-radius: 5px;
}

.issue-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 5px;
}

.issue-item-head strong {
  font-size: 11px;
}

.issue-level {
  padding: 2px 5px;
  color: var(--issue-color, var(--amber));
  background: #fff;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 800;
}

.issue-item p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.issue-quote {
  color: #414b47 !important;
  font-family: Georgia, serif;
}

.advice-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.advice-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  color: #4d5753;
  font-size: 11px;
  line-height: 1.6;
}

.advice-list b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 50%;
  font-size: 9px;
}

.history-panel {
  display: none;
  margin-top: 17px;
}

.history-panel.open {
  display: block;
}

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

.history-card {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid #e7ece6;
  border-radius: 7px;
}

.history-score {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  color: var(--history-color, var(--brand));
  background: #fff;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
}

.history-card h4 {
  overflow: hidden;
  margin: 0 0 4px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.history-actions {
  display: flex;
  gap: 2px;
}

.history-actions button {
  width: 27px;
  height: 27px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.history-actions button:hover {
  color: var(--ink);
  background: #e9eee8;
}

.history-actions button.delete:hover {
  color: var(--danger);
  background: #fae9e7;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  gap: 17px;
}

.big-chart {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  align-items: end;
  gap: 8px;
  height: 245px;
  padding-top: 10px;
}

.big-bar-wrap {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  height: 100%;
  min-width: 0;
  text-align: center;
}

.big-bar-track {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  height: 205px;
}

.big-bar {
  width: min(28px, 68%);
  min-height: 4px;
  background: #86b5a6;
  border-radius: 4px 4px 2px 2px;
}

.big-bar-wrap.today .big-bar {
  background: var(--coral);
}

.big-bar-track span {
  position: absolute;
  top: -1px;
  left: 50%;
  color: var(--muted);
  font-size: 8px;
  transform: translateX(-50%);
}

.big-bar-wrap > span {
  overflow: hidden;
  margin-top: 8px;
  color: #8a938e;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-mix {
  display: grid;
  gap: 13px;
}

.mix-row {
  display: grid;
  gap: 7px;
}

.mix-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.mix-row-head span:last-child {
  color: var(--muted);
}

.mix-track {
  height: 7px;
  overflow: hidden;
  background: #ebefea;
  border-radius: 5px;
}

.mix-track span {
  display: block;
  height: 100%;
  background: var(--mix-color);
  border-radius: inherit;
}

.records-table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.records-table th,
.records-table td {
  padding: 10px 9px;
  border-bottom: 1px solid #edf0ec;
  text-align: left;
  white-space: nowrap;
}

.records-table th {
  color: #89918d;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.records-table td {
  color: #4e5954;
}

.records-table td:first-child {
  color: var(--ink);
  font-weight: 700;
}

.completion-pill {
  display: inline-block;
  padding: 3px 6px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 4px;
  font-weight: 700;
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-item {
  padding: 11px;
  background: var(--surface-soft);
  border-left: 3px solid var(--brand);
  border-radius: 5px;
}

.insight-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.insight-item p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  visibility: hidden;
  background: rgba(28, 39, 35, 0.38);
  opacity: 0;
  transition: 160ms ease;
}

.modal-backdrop.open {
  visibility: visible;
  opacity: 1;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(28, 39, 35, 0.2);
  transform: translateY(8px) scale(0.99);
  transition: 160ms ease;
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 20px;
}

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

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}

.modal-actions > div {
  display: flex;
  gap: 7px;
}

.settings-actions {
  justify-content: flex-end;
}

.cloud-account-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.cloud-account-box span,
.cloud-account-box strong {
  display: block;
}

.cloud-account-box span {
  color: var(--muted);
  font-size: 10px;
}

.cloud-account-box strong {
  margin-top: 3px;
  font-size: 12px;
}

.cloud-account-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cloud-auth-note,
.cloud-auth-message {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.cloud-auth-actions {
  display: flex;
  gap: 8px;
}

.cloud-auth-actions > button {
  flex: 1;
}

.cloud-auth-message:not(:empty) {
  padding: 9px 10px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 150;
  max-width: 340px;
  padding: 11px 14px;
  color: #fff;
  background: #223630;
  border-radius: 7px;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 180ms ease;
}

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

@media (max-width: 1180px) {
  .dashboard-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .right-column {
    grid-template-columns: 1fr 1fr;
  }

  .subject-progress-grid {
    grid-template-columns: 1fr;
  }

  .essay-layout {
    grid-template-columns: 1fr;
  }

  .essay-editor-panel,
  .report-panel {
    min-height: auto;
  }

  .empty-report {
    min-height: 300px;
  }
}

@media (max-width: 920px) {
  :root {
    --sidebar-width: 230px;
  }

  .planner-layout {
    grid-template-columns: 1fr;
  }

  .planner-form-panel {
    position: static;
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 18px 0 45px rgba(28, 39, 35, 0.12);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    grid-column: auto;
  }

  .mobile-menu {
    display: inline-flex !important;
    flex: 0 0 auto;
  }

  .topbar {
    justify-content: flex-start;
    gap: 11px;
    padding: 13px 16px;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .sync-chip {
    width: 33px;
    padding: 0;
    justify-content: center;
  }

  .sync-chip span {
    display: none;
  }

  .today-label,
  .topbar-kicker {
    display: none;
  }

  .view-stack {
    padding: 22px 16px 40px;
  }

  .dashboard-intro,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 18px;
  }

  .dashboard-intro h2,
  .section-heading h2 {
    font-size: 27px;
  }

  .metric-grid,
  .right-column,
  .day-summary-strip,
  .history-list {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 81px;
  }

  .panel {
    padding: 16px;
  }

  .progress-ring-wrap {
    align-items: flex-start;
  }

  .stage-row {
    grid-template-columns: minmax(90px, 1fr) 90px 28px;
    gap: 7px;
  }

  .stage-name {
    grid-column: 1 / 2;
    grid-row: 1;
  }

  .stage-total-wrap {
    grid-column: 2 / 3;
    grid-row: 1;
  }

  .stage-quantity {
    grid-column: 1 / 2;
    grid-row: 2;
  }

  .stage-percent {
    grid-column: 2 / 3;
    grid-row: 2;
  }

  .stage-delete {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    justify-self: end;
  }

  .report-header {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .score-ring {
    width: 87px;
    height: 87px;
  }

  .score-ring::before {
    width: 66px;
    height: 66px;
  }

  .score-ring strong {
    font-size: 22px;
  }

  .big-chart {
    gap: 4px;
  }

  .big-bar {
    width: 56%;
  }
}

@media (max-width: 480px) {
  .panel-head {
    align-items: flex-start;
  }

  .essay-mode-controls {
    align-items: flex-end;
    flex-direction: column;
  }

  .date-navigator {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

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

  .editor-footer,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-footer .primary-btn {
    width: 100%;
  }

  .modal-actions > div {
    justify-content: flex-end;
  }

  .progress-ring-wrap {
    display: grid;
    justify-items: center;
  }

  .task-item {
    grid-template-columns: 26px minmax(0, 1fr) 28px;
    gap: 8px;
  }

  .task-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .task-title {
    white-space: normal;
  }

  .report-header {
    grid-template-columns: 1fr;
  }
}

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