:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --paper-raised: #fbf9f4;
  --paper-deep: #e8e1d5;
  --ink: #1e2722;
  --muted: #6f756f;
  --line: #d6d0c5;
  --accent: #e6653f;
  --accent-dark: #b9482c;
  --green: #2f5a46;
  --green-soft: #dce7de;
  --school: #3d6d9d;
  --sport: #3b7b58;
  --development: #835da4;
  --meal: #b96f30;
  --life: #a95768;
  --other: #737773;
  --shadow: 0 18px 50px rgba(32, 38, 34, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171c19;
  --paper-raised: #202622;
  --paper-deep: #29302b;
  --ink: #f0eee7;
  --muted: #a6aca6;
  --line: #3b433d;
  --accent: #ed7754;
  --accent-dark: #ff9679;
  --green: #a8c6b2;
  --green-soft: #2c3d32;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 5%, rgba(230, 101, 63, 0.08), transparent 24rem),
    var(--paper);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 8vw, 100px);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  z-index: 1;
}

.login-card h1, .hero h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-weight: 500;
}

.login-card h1 { font-size: clamp(2.8rem, 7vw, 5rem); }
.login-intro { margin: 12px 0 42px; color: var(--muted); font-size: 1.05rem; }

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 36px;
  border-radius: 50% 50% 50% 12px;
  color: white;
  background: var(--accent);
  font-family: Georgia, serif;
  font-size: 1.45rem;
  box-shadow: 0 10px 30px rgba(230, 101, 63, 0.22);
}

.brand-mark.small { width: 38px; height: 38px; margin: 0; font-size: 1rem; }

.login-quote {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(48px, 8vw, 120px);
  background:
    linear-gradient(145deg, rgba(37, 69, 53, 0.94), rgba(24, 39, 31, 0.98)),
    repeating-linear-gradient(90deg, transparent 0 99px, rgba(255,255,255,.04) 100px);
  color: #f6f1e8;
}

.login-quote span { color: #e9997f; letter-spacing: 0.35em; font-size: 0.75rem; }
.login-quote strong { margin-top: 18px; font: 500 clamp(3.2rem, 7vw, 7rem)/0.92 Georgia, serif; }

.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  color: var(--ink);
  background: var(--paper-raised);
  transition: border-color 160ms, box-shadow 160ms;
}

input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 40%, var(--ink)); }
textarea { resize: vertical; }
.form-error { min-height: 18px; margin: -4px 0 0; color: #b23c31; font-size: 0.82rem; }

.button, .icon-button, .text-button {
  border: 0;
  transition: transform 150ms, background 150ms, color 150ms, opacity 150ms;
}

.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button { min-height: 42px; padding: 9px 16px; border-radius: 999px; font-weight: 750; }
.button.primary { color: white; background: var(--accent); box-shadow: 0 8px 18px rgba(230, 101, 63, 0.18); }
.button.primary:hover { background: var(--accent-dark); }
.button.outline { border: 1px solid var(--line); background: transparent; }
.button.subtle { background: var(--paper-deep); }
.button.wide { width: 100%; margin-top: 4px; }
.icon-button { width: 40px; height: 40px; border-radius: 50%; background: var(--paper-deep); font-size: 1.05rem; }
.text-button { padding: 7px; color: var(--accent-dark); background: transparent; font-weight: 750; }
.text-button.danger { color: #b23c31; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font: 600 1rem Georgia, serif; }
.brand small { color: var(--muted); font-size: 0.57rem; letter-spacing: .16em; }
.header-actions { display: flex; align-items: center; gap: 8px; }

main { width: min(1500px, 100%); margin: 0 auto; padding: 44px clamp(16px, 4vw, 64px) 80px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 42px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: 1.08; letter-spacing: -.035em; }
.hero-copy { margin: 15px 0 0; color: var(--muted); }
.week-score { flex: 0 0 auto; text-align: right; }
.week-score span { display: block; color: var(--green); font: 500 clamp(2.8rem, 6vw, 5rem)/1 Georgia, serif; }
.week-score small { color: var(--muted); }

.week-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}
.week-toolbar > div:nth-child(2) { text-align: center; }
.week-toolbar h2 { margin: 0; font: 500 1.35rem Georgia, serif; }
.week-toolbar > button { justify-self: end; }
.week-nav { display: flex; align-items: center; gap: 8px; }

.goal-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
}
.goal-index { color: var(--accent); font: 500 1.45rem Georgia, serif; }
.goal-card label { margin-bottom: 3px; }
.goal-card input { padding: 2px 0; border: 0; border-radius: 0; background: transparent; font-size: 1rem; font-weight: 650; }
.save-state { color: var(--muted); font-size: .72rem; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(155px, 1fr));
  gap: 10px;
}

.day-column {
  min-height: 390px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--paper-raised) 80%, transparent);
  transition: border-color 160ms, background 160ms, transform 160ms;
}
.day-column.is-today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day-column.is-selected { background: var(--paper-raised); }
.day-column.drag-over { border-color: var(--green); background: var(--green-soft); transform: translateY(-2px); }
.day-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.day-name { margin: 0; font-size: .76rem; color: var(--muted); font-weight: 800; }
.day-number { margin: 1px 0 0; font: 500 2rem/1 Georgia, serif; }
.day-header .add-day { width: 31px; height: 31px; background: transparent; border: 1px solid var(--line); }
.day-meta { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: .66rem; }
.progress-track { height: 3px; margin-bottom: 13px; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.progress-track span { display: block; height: 100%; background: var(--green); transition: width 250ms; }
.task-list { display: grid; gap: 8px; }
.empty-day { padding: 28px 4px; color: var(--muted); text-align: center; font-size: .75rem; }

.task-card {
  position: relative;
  padding: 11px 9px 11px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--category-color, var(--other));
  border-radius: 11px;
  background: var(--paper-raised);
  box-shadow: 0 4px 12px rgba(34, 39, 35, .035);
  cursor: grab;
}
.task-card:hover { border-color: color-mix(in srgb, var(--category-color) 55%, var(--line)); }
.task-card.is-done, .task-card.is-skipped { opacity: .55; }
.task-card.is-done .task-title, .task-card.is-skipped .task-title { text-decoration: line-through; }
.task-top { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 7px; }
.task-check { width: 18px; height: 18px; display: grid; place-items: center; margin-top: 1px; border: 1.5px solid var(--category-color); border-radius: 50%; padding: 0; background: transparent; color: white; font-size: .68rem; }
.is-done .task-check { background: var(--category-color); }
.task-title { margin: 0; font-size: .79rem; line-height: 1.35; font-weight: 720; word-break: break-word; }
.task-priority { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: transparent; }
.task-priority.high { background: var(--accent); }
.task-details { display: flex; flex-wrap: wrap; gap: 5px 8px; margin: 7px 0 0 25px; color: var(--muted); font-size: .64rem; }
.task-category { color: var(--category-color); font-weight: 750; }

.day-actions { display: flex; gap: 5px; margin-top: 13px; }
.day-actions button { flex: 1; padding: 6px 4px; border: 0; border-radius: 8px; color: var(--muted); background: var(--paper-deep); font-size: .68rem; }

.lower-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 18px; margin-top: 20px; }
.quick-panel, .template-panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper-raised); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font: 500 1.6rem Georgia, serif; }
.shortcut { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: .64rem; }
.quick-form { display: grid; grid-template-columns: minmax(180px, 1fr) 150px 150px auto; gap: 10px; }
.template-list { display: flex; flex-wrap: wrap; gap: 8px; }
.template-chip { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: .73rem; }
.template-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--category-color); }
.template-chip .remove-template { border: 0; padding: 0 0 0 2px; color: var(--muted); background: transparent; }
.empty-templates { color: var(--muted); font-size: .78rem; }

.mobile-day-nav { display: none; }

.modal {
  width: min(650px, calc(100% - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(16, 22, 18, .58); backdrop-filter: blur(5px); }
.modal-card { display: grid; gap: 18px; padding: clamp(22px, 5vw, 34px); background: var(--paper-raised); }
.modal-card.compact { max-width: 540px; }
.modal-header { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.modal-header h2 { margin: 0; font: 500 1.8rem Georgia, serif; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.full-field { display: grid; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 4px; }
.modal-footer > div { display: flex; gap: 6px; }
.modal-footer.right { justify-content: flex-end; }
.danger-actions { min-height: 36px; }
.rating-field { padding: 0; border: 0; }
.rating-field legend { margin-bottom: 10px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.rating-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating-buttons label { display: block; }
.rating-buttons input { position: absolute; opacity: 0; pointer-events: none; }
.rating-buttons span { display: grid; place-items: center; height: 42px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.rating-buttons input:checked + span { border-color: var(--accent); color: white; background: var(--accent); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(360px, calc(100% - 32px));
  padding: 12px 17px;
  border-radius: 12px;
  color: white;
  background: #26382e;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
  font-size: .84rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #923c31; }

@media (max-width: 1180px) {
  .week-grid { grid-template-columns: repeat(4, 1fr); }
  .day-column { min-height: 300px; }
  .lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-shell { display: block; background: var(--paper-raised); }
  .login-card { min-height: 100vh; padding: 34px 24px; box-shadow: none; }
  .login-card .brand-mark { margin-bottom: 60px; }
  .login-quote { display: none; }
  .topbar { height: 64px; padding: 0 16px; }
  main { padding: 28px 14px 60px; }
  .hero { align-items: flex-start; margin-bottom: 28px; }
  .hero h1 { font-size: 2.55rem; }
  .hero-copy { font-size: .88rem; }
  .week-score span { font-size: 2.3rem; }
  .week-toolbar { grid-template-columns: 1fr auto; }
  .week-toolbar > div:nth-child(2) { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .week-nav { grid-column: 1; grid-row: 2; }
  .week-toolbar > button { grid-column: 2; grid-row: 2; font-size: .72rem; }
  .goal-card { grid-template-columns: auto 1fr; padding: 15px; }
  .save-state { display: none; }
  .mobile-day-nav { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 18px 0 10px; }
  .mobile-day-nav button { padding: 8px 1px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: .64rem; }
  .mobile-day-nav button span { display: block; margin-top: 3px; color: var(--ink); font-size: .9rem; font-weight: 750; }
  .mobile-day-nav button.active { color: white; background: var(--green); }
  .mobile-day-nav button.active span { color: white; }
  .week-grid { display: block; }
  .day-column { display: none; min-height: 370px; }
  .day-column.is-selected { display: block; }
  .day-header .add-day { width: 38px; height: 38px; }
  .task-card { padding: 14px 12px; }
  .task-title { font-size: .9rem; }
  .task-details { font-size: .72rem; }
  .quick-panel, .template-panel { padding: 19px 15px; }
  .quick-form { grid-template-columns: 1fr 1fr; }
  .quick-form #quickTitle { grid-column: 1 / -1; }
  .quick-form button { grid-column: 1 / -1; }
  .shortcut { display: none; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-card { max-height: calc(100vh - 28px); overflow-y: auto; }
  .modal-footer { align-items: stretch; flex-direction: column-reverse; }
  .modal-footer > div { justify-content: flex-end; }
  .modal-footer .danger-actions { justify-content: flex-start; }
}

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