:root {
  --ink: #20212b;
  --muted: #77788a;
  --subtle: #8c8993;
  --eyebrow: #9895a2;
  --paper: #faf9f6;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --line: #e9e6e0;
  --card-border: transparent;
  --card-border-hover: #cfc9ee;
  --purple: #6558b6;
  --purple-text: #493b91;
  --purple-soft: #efedfb;
  --purple-hover: #5448a3;
  --orange: #ed9a62;
  --mint: #5aa27d;
  --tip-bg: #f6f4ef;
  --tip-color: #74727b;
  --icon-bg: #ffffff;
  --icon-color: #696475;
  --icon-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --avatar-bg: #a99d87;
  --mini-week-bg: #f0eef2;
  --tag-bg: #f3f2f4;
  --input-bg: #ffffff;
  --input-border: #e7e3ea;
  --checkbox-border: #bdb9c5;
  --bar-rest: #efeef1;
  --quote-bg: #faf8f4;
  --quote-color: #77717e;
  --progress-track: #efedf1;
  --toast-bg: #2f293d;
  --shadow: 0 10px 30px rgba(47, 36, 91, 0.06);
  --shadow-hover: 0 14px 28px rgba(47, 36, 91, 0.11);
}

[data-theme="dark"] {
  --ink: #f4f2fb;
  --muted: #a6a3b8;
  --subtle: #7f7c93;
  --eyebrow: #8c889f;
  --paper: #0f0e18;
  --card-bg: #1a1829;
  --sidebar-bg: #141320;
  --line: #29263f;
  --card-border: #29263f;
  --card-border-hover: #7b6be6;
  --purple: #8676f0;
  --purple-text: #a89bf8;
  --purple-soft: #2b2649;
  --purple-hover: #9c8ef7;
  --orange: #f2a674;
  --mint: #6ec095;
  --tip-bg: #1c1a2d;
  --tip-color: #9e9ab2;
  --icon-bg: #1f1d32;
  --icon-color: #b1adcb;
  --icon-shadow: 0 2px 10px rgba(0,0,0,0.3);
  --avatar-bg: #4f4769;
  --mini-week-bg: #242239;
  --tag-bg: #24213a;
  --input-bg: #232038;
  --input-border: #353154;
  --checkbox-border: #524d77;
  --bar-rest: #25223c;
  --quote-bg: #171524;
  --quote-color: #a49fb5;
  --progress-track: #26233d;
  --toast-bg: #221f36;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 16px 36px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.sidebar {
  width: 252px;
  min-height: 100vh;
  position: fixed;
  padding: 31px 19px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, border-color 0.25s ease;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  font-size: 23px;
  margin: 0 10px 58px;
}

.brand-mark {
  font-family: 'Playfair Display';
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  border-radius: 10px;
  background: var(--purple);
  font-size: 22px;
}

.brand small {
  display: block;
  font: 600 8px 'DM Sans';
  letter-spacing: 1.4px;
  color: var(--eyebrow);
  margin-top: 2px;
}

nav { display: grid; gap: 7px; }
nav a {
  padding: 13px 15px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

nav a span {
  font-size: 19px;
  vertical-align: -2px;
  width: 29px;
  display: inline-block;
  color: var(--subtle);
  transition: color 0.2s ease;
}

nav a.active, nav a:hover {
  color: var(--purple-text);
  background: var(--purple-soft);
}

nav a.active span {
  color: var(--purple);
}

.side-tip {
  margin-top: auto;
  padding: 18px 15px;
  border-radius: 12px;
  background: var(--tip-bg);
  color: var(--tip-color);
  font-size: 11px;
  line-height: 1.6;
  transition: background-color 0.25s ease;
}

.side-tip span { color: var(--orange); font-size: 18px; }
.side-tip p { margin: 5px 0 0; }
.side-tip b { color: var(--ink); }

main {
  margin-left: 252px;
  max-width: 1400px;
  padding: 49px 6.3vw 65px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 35px;
  position: relative;
  z-index: 20;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--eyebrow);
  margin: 0 0 10px;
}

h1, h2, p { margin-top: 0; }
h1 {
  font: 800 33px/1.2 'Playfair Display';
  letter-spacing: -0.7px;
  margin-bottom: 8px;
  color: var(--ink);
}

h1 em {
  font-style: normal;
  color: var(--purple);
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

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

.icon-btn, .avatar {
  border: 0;
  background: var(--icon-bg);
  color: var(--icon-color);
  box-shadow: var(--icon-shadow);
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.icon-btn {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  font-size: 19px;
  position: relative;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  transform: translateY(-2px);
  color: var(--purple);
}

.icon-btn i {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ee8566;
  border-radius: 50%;
  right: 9px;
  top: 9px;
}

.avatar {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.25fr) minmax(200px, 1fr);
  gap: 20px;
}

.focus-card {
  padding: 29px 32px 27px;
  color: white;
  border-radius: 16px;
  background: linear-gradient(105deg, #5d51a7, #7567bd);
  box-shadow: 0 13px 23px rgba(88, 74, 162, 0.18);
}

[data-theme="dark"] .focus-card {
  background: linear-gradient(105deg, #493e8a, #6253a6);
  box-shadow: 0 13px 28px rgba(0, 0, 0, 0.4);
}

.card-kicker {
  font-size: 10px;
  letter-spacing: 1.4px;
  font-weight: bold;
  color: #ddd8fb;
}

.sun { font-size: 16px; color: #f6bd6a; margin-right: 8px; }
.focus-date { float: right; opacity: 0.8; }
.focus-card h2 { font: 700 27px 'Playfair Display'; margin: 26px 0 5px; }
.focus-card > p { font-size: 13px; color: #e1ddfb; margin-bottom: 28px; }
.focus-bottom { display: flex; align-items: end; justify-content: space-between; gap: 25px; }
.progress-label { font-size: 9px; letter-spacing: 1.2px; color: #d9d3fa; }
.progress { width: 230px; height: 5px; background: rgba(255,255,255,0.25); border-radius: 99px; margin: 7px 0; }
.progress span { height: 100%; display: block; border-radius: 99px; background: #f1b277; }
.focus-bottom b { font-size: 11px; font-weight: 500; color: #f1eefb; }

.dark-btn {
  border: 0;
  background: #373044;
  color: white;
  border-radius: 7px;
  padding: 12px 16px;
  font: 600 12px 'DM Sans';
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

[data-theme="dark"] .dark-btn {
  background: #181525;
  color: #f1eff8;
  border: 1px solid #3c365c;
}

.dark-btn span { margin-left: 8px; font-size: 17px; }

.streak-card {
  border-radius: 16px;
  background: var(--card-bg);
  padding: 23px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
}

.streak-top { display: flex; justify-content: space-between; }
.streak-top > span { font-size: 22px; color: var(--orange); }
.streak-top button { border: 0; background: none; color: var(--muted); letter-spacing: 2px; cursor: pointer; }
.streak-card strong { font: 800 39px 'Playfair Display'; display: block; margin-top: 4px; color: var(--ink); }
.streak-card p { font-size: 12px; color: var(--muted); margin: -2px 0 14px; }
.mini-week { display: flex; justify-content: space-between; margin-bottom: 11px; }
.mini-week span { font-size: 9px; color: var(--eyebrow); text-align: center; }
.mini-week i { display: block; width: 20px; height: 20px; border-radius: 50%; margin-top: 5px; background: var(--mini-week-bg); font-style: normal; line-height: 20px; color: #fff; }
.mini-week i.on { background: var(--purple); }
.streak-card small { font-size: 10px; color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0 51px;
}

.metrics article {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  padding: 16px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
}

.metric-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 18px;
}

.lavender { background: #eceafd; color: #7163b9; }
.peach { background: #fff0e7; color: #e99960; }
.mint { background: #e9f7ef; color: #5aa27d; }

[data-theme="dark"] .lavender { background: #2b254a; color: #9f91fb; }
[data-theme="dark"] .peach { background: #37231d; color: #f5a975; }
[data-theme="dark"] .mint { background: #1a3227; color: #74caa0; }

.metrics b { font-size: 16px; color: var(--ink); }
.metrics p { font-size: 10px; color: var(--muted); margin: 2px 0 0; }
.metric-change { margin-left: auto; color: var(--mint); font-size: 10px; font-weight: bold; }
.ring { margin-left: auto; border: 3px solid #b1e0ca; border-left-color: var(--line); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-size: 7px; color: var(--mint); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 20px;
}

.section-head h2, .panel-head h2 {
  font: 700 22px 'Playfair Display';
  margin: 0;
  color: var(--ink);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--purple);
  font: 600 12px 'DM Sans';
  cursor: pointer;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 50px;
}

.subject {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 19px;
  border-radius: 12px;
  transition: 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.subject:hover {
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
}

.subject-top { display: flex; justify-content: space-between; align-items: start; }
.subject-icon { height: 36px; width: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: bold; color: #fff; }
.subject h3 { font-size: 14px; margin: 16px 0 4px; color: var(--ink); }
.subject p { font-size: 11px; color: var(--muted); margin-bottom: 15px; }
.subject .progress { width: 100%; height: 4px; background: var(--progress-track); margin: 0 0 7px; }
.subject small { color: var(--muted); font-size: 10px; }
.subject small b { float: right; color: var(--ink); }

.two-col {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 20px;
}

.task-panel, .plan-panel {
  border-radius: 15px;
  background: var(--card-bg);
  padding: 25px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 17px;
}

.panel-head .eyebrow { margin-bottom: 7px; }
.panel-head > span {
  font-size: 10px;
  color: var(--muted);
  background: var(--tag-bg);
  padding: 6px 9px;
  border-radius: 20px;
}

.task-list { border-top: 1px solid var(--line); }
.task {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink);
}

.task input {
  appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--checkbox-border);
  background: var(--input-bg);
  border-radius: 5px;
  margin: 0;
  cursor: pointer;
}

.task input:checked {
  background: var(--purple);
  border-color: var(--purple);
}

.task input:checked:after {
  content: '✓';
  display: block;
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 14px;
}

.task.done span {
  text-decoration: line-through;
  color: var(--subtle);
}

.task-delete {
  border: 0;
  background: transparent;
  color: var(--subtle);
  font-size: 18px;
  cursor: pointer;
  margin-left: auto;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.task-delete:hover { color: #d9534f; }
#taskForm { display: flex; gap: 8px; margin-top: 14px; }

#taskInput {
  flex: 1;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--ink);
  border-radius: 7px;
  padding: 10px;
  font: 12px 'DM Sans';
  outline-color: var(--purple);
}

#taskForm button {
  border: 0;
  border-radius: 7px;
  width: 38px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 21px;
  cursor: pointer;
}

.week-bars {
  height: 140px;
  display: flex;
  align-items: end;
  justify-content: space-around;
  border-bottom: 1px solid var(--line);
  padding: 0 5px;
}

.day-bar {
  text-align: center;
  font-size: 9px;
  color: var(--muted);
}

.day-bar i {
  display: block;
  width: 20px;
  border-radius: 5px 5px 0 0;
  background: var(--purple-soft);
  margin: 0 auto 8px;
}

.day-bar i.done { background: var(--purple); }
.day-bar i.rest { background: var(--bar-rest); }
.legend { display: flex; gap: 13px; font-size: 9px; color: var(--muted); padding: 13px 0; }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.done-dot { background: var(--purple); }
.plan-dot { background: var(--purple-soft); }
.empty-dot { background: var(--bar-rest); }

.quote {
  font: italic 12px/1.5 'Playfair Display';
  color: var(--quote-color);
  background: var(--quote-bg);
  padding: 10px 13px;
  border-radius: 7px;
  margin: 3px 0 0;
}

.toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  padding: 12px 17px;
  color: #fff;
  background: var(--toast-bg);
  border-radius: 8px;
  font-size: 12px;
  transform: translateY(90px);
  opacity: 0;
  transition: 0.3s ease;
  z-index: 3000;
}

.toast.show { transform: none; opacity: 1; }

@media(max-width: 950px) {
  .sidebar { width: 70px; padding: 23px 10px; }
  .brand { margin: 0 auto 45px; }
  .brand > span:last-child, nav a:not(.active)::after, nav a { font-size: 0; }
  .brand small { display: none; }
  nav a { padding: 12px; text-align: center; }
  nav a span { font-size: 20px; width: auto; }
  .side-tip { display: none; }
  main { margin-left: 70px; padding: 35px 5vw; }
  .subject-grid { grid-template-columns: repeat(2, 1fr); }
}

@media(max-width: 650px) {
  main { margin: 0; padding: 25px 18px; }
  .sidebar {
    position: static;
    width: auto;
    min-height: 0;
    height: 66px;
    padding: 11px 18px;
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .brand { margin: 0 auto 0 0; font-size: 18px; }
  .brand-mark { width: 31px; height: 31px; }
  .sidebar nav { display: flex; gap: 1px; }
  .sidebar nav a { padding: 8px; }
  .sidebar nav a span { font-size: 17px; }
  header { margin-bottom: 24px; }
  h1 { font-size: 28px; }
  .hero-grid, .two-col { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; margin-bottom: 36px; }
  .subject-grid { grid-template-columns: 1fr; }
  .focus-card { padding: 24px; }
  .focus-bottom { align-items: start; flex-direction: column; }
  .progress { width: 100%; }
  .focus-bottom > div { width: 100%; }
  .focus-date { display: none; }
  .streak-card { display: none; }
}
