:root {
  color-scheme: light;
  --canvas: #f3f0e9;
  --surface: #fffdf9;
  --surface-subtle: #f0eef5;
  --ink: #17172d;
  --muted: #69677a;
  --line: #ddd9e2;
  --line-strong: #b9b8c9;
  --accent: #252459;
  --accent-strong: #17172d;
  --accent-soft: #e9e8f2;
  --on-accent: #fffdf9;
  --ornament: #b89b5a;
  --focus-ring: rgba(110, 219, 232, 0.52);
  --morning: #3b7881;
  --morning-soft: #e5f1f2;
  --noon: #8a672f;
  --noon-soft: #f4eddf;
  --afternoon: #5f72a4;
  --afternoon-soft: #e9edf6;
  --evening: #7d5f92;
  --evening-soft: #f0eaf4;
  --danger: #a34f60;
  --danger-soft: #f8e9ed;
  --shadow: 0 12px 34px rgba(23, 23, 45, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  min-width: 320px;
  overflow-x: clip;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  overflow-x: clip;
}

.dashboard-page[data-profile="planner"] [data-view-button="scratchpad"],
.dashboard-page[data-profile="planner"] [data-view-button="research"],
.dashboard-page[data-profile="planner"] [data-view-panel="scratchpad"],
.dashboard-page[data-profile="planner"] [data-view-panel="research"] {
  display: none !important;
}

.dashboard-page[data-profile="planner"] .view-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button,
input,
select {
  font: inherit;
}

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

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.calendar-scroller:focus-visible,
.english-archive-scroller:focus-visible,
.research-source-link:focus-visible,
.research-title a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100% - 32px, 760px);
  margin-inline: auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(16px);
}

.header-inner {
  padding-top: 16px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.title-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.mitya-emblem {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  filter: drop-shadow(0 5px 10px rgba(23, 23, 45, 0.1));
}

.date-kicker,
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: uppercase;
}

.title-row h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.12;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 36px;
}

.planner-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.completed-visibility-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.completed-visibility-control input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.auto-sync-note {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sync-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sync-status[data-tone="working"] {
  color: var(--afternoon);
}

.sync-status[data-tone="success"] {
  color: var(--morning);
}

.sync-status[data-tone="error"] {
  color: var(--danger);
}

.quiet-button,
.icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.quiet-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

.quiet-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 15px;
}

.view-tabs button {
  position: relative;
  min-height: 43px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.view-tabs button::after {
  position: absolute;
  bottom: -4px;
  left: 50%;
  display: none;
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface);
  border-radius: 1px;
  background: transparent;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.view-tabs button:hover {
  color: var(--ink);
  background: var(--surface-subtle);
}

.view-tabs button[aria-selected="true"] {
  border-bottom-color: var(--ornament);
  color: var(--accent-strong);
}

.view-tabs button[aria-selected="true"]::after {
  display: block;
  background: var(--ornament);
}

.app-main {
  padding-block: 28px 72px;
}

.view-panel {
  min-width: 0;
}

.section-heading,
.agenda-heading,
.scratch-heading,
.english-heading,
.english-archive-heading,
.research-source-row,
.calendar-toolbar,
.period-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2,
.agenda-heading h3,
.scratch-heading h3,
.english-heading h3,
.english-archive-heading h3,
.research-source-row h3,
.calendar-toolbar h3,
.period-heading h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 21px;
  line-height: 1.25;
}

.section-subtitle,
.section-meta,
.agenda-date {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-meta {
  white-space: nowrap;
}

.schedule-surface,
.agenda-surface,
.calendar-surface,
.scratch-surface,
.english-surface,
.english-archive-surface,
.research-surface {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mitya-corner-surface {
  position: relative;
  isolation: isolate;
}

.mitya-corner-surface::after {
  position: absolute;
  bottom: -8px;
  right: -8px;
  z-index: 0;
  width: 150px;
  height: 82px;
  background: url("/assets/mitya-corner.svg") top right / contain no-repeat;
  content: "";
  opacity: 0.18;
  pointer-events: none;
}

.mitya-corner-surface > * {
  position: relative;
  z-index: 1;
}

.period-band {
  --period-color: var(--morning);
  --period-soft: var(--morning-soft);
  position: relative;
  padding: 18px 18px 20px;
  border-left: 4px solid var(--period-color);
}

.period-band + .period-band {
  border-top: 1px solid var(--line);
}

.period-band[data-period-band="noon"] {
  --period-color: var(--noon);
  --period-soft: var(--noon-soft);
}

.period-band[data-period-band="afternoon"] {
  --period-color: var(--afternoon);
  --period-soft: var(--afternoon-soft);
}

.period-band[data-period-band="evening"] {
  --period-color: var(--evening);
  --period-soft: var(--evening-soft);
}

.period-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--period-color);
}

.period-heading h3 {
  font-size: 16px;
}

.period-count {
  color: var(--muted);
  font-size: 12px;
}

.task-add-form,
.week-task-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.task-add-form {
  margin-top: 13px;
}

input[type="text"],
input[type="password"],
input[type="month"],
select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

input[type="text"],
input[type="password"] {
  padding: 9px 11px;
}

input::placeholder {
  color: #858394;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="month"]:focus,
select:focus {
  border-color: var(--accent);
}

.task-add-form button,
.week-task-input-row button,
.access-form button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 750;
}

.task-add-form button:hover,
.week-task-input-row button:hover,
.access-form button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.task-list {
  margin-top: 10px;
}

.task-list.is-task-reordering {
  position: relative;
}

.task-item {
  display: grid;
  grid-template-columns: 24px 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 43px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.task-list .task-item:first-child {
  border-top: 0;
}

.task-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.task-drag-handle {
  display: inline-grid;
  width: 24px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: grab;
  font-size: 17px;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.task-drag-handle:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.task-drag-handle:disabled {
  color: var(--line-strong);
  background: transparent;
  cursor: default;
}

.task-item.is-dragging {
  z-index: 90;
  border-color: var(--line-strong);
  border-radius: 6px;
  background: var(--surface-subtle);
  box-shadow: 0 8px 22px rgba(23, 23, 45, 0.14);
  will-change: transform;
}

.task-item.is-dragging .task-drag-handle {
  color: var(--accent-strong);
  cursor: grabbing;
}

.task-item.is-reorder-saving {
  opacity: 0.68;
}

.task-drag-placeholder {
  width: 100%;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
}

body.is-task-dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

.task-content {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.task-text {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 4px;
  padding: 4px 3px;
  color: inherit;
  background: transparent;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}

.task-text:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.task-edit-input {
  min-height: 34px !important;
  padding: 6px 8px !important;
  background: var(--surface) !important;
}

.task-item.is-editing .task-drag-handle {
  opacity: 0.42;
}

.task-item.is-done .task-text {
  color: var(--muted);
  text-decoration: line-through;
}

.task-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-row-actions .icon-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 5px;
  padding: 0;
  font-size: 14px;
}

.add-subtask-button {
  border-color: var(--line-strong);
  color: var(--accent);
  background: var(--surface);
}

.task-subtasks {
  grid-column: 3 / -1;
  min-width: 0;
  margin: 1px 0 3px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

.subtask-list:empty {
  display: none;
}

.subtask-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 0;
}

.subtask-item + .subtask-item {
  border-top: 1px solid var(--line);
}

.subtask-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.subtask-text {
  min-width: 0;
  border: 0;
  border-radius: 4px;
  padding: 4px 3px;
  color: var(--ink);
  background: transparent;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.subtask-text:hover {
  background: var(--accent-soft);
}

.subtask-item.is-done .subtask-text {
  color: var(--muted);
  text-decoration: line-through;
}

.subtask-delete-button {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
}

.subtask-delete-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.subtask-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin-top: 6px;
}

.subtask-add-form input,
.subtask-edit-input {
  min-height: 34px !important;
  padding: 6px 8px !important;
  font-size: 13px;
}

.subtask-add-form button {
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 5px 10px;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.delete-button {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.delete-button:hover {
  border-color: #e5bfc8;
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.week-heading {
  align-items: center;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 14px;
}

.week-day {
  display: grid;
  min-width: 0;
  min-height: 72px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 2px;
  color: var(--ink);
  background: var(--surface);
}

.week-day:hover {
  border-color: var(--accent);
}

.week-day-name {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.week-day strong {
  font-size: 17px;
  line-height: 1.15;
}

.week-day-marker {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  font-size: 9px;
  line-height: 1;
}

.week-day-marker.has-tasks {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.week-day.is-today strong {
  color: var(--accent);
}

.week-day.is-selected {
  border-color: var(--accent);
  color: var(--on-accent);
  background: var(--accent);
}

.week-day.is-selected .week-day-name,
.week-day.is-selected strong {
  color: var(--on-accent);
}

.week-day.is-selected .week-day-marker.has-tasks {
  color: var(--accent-strong);
  background: var(--surface);
}

.agenda-surface,
.calendar-surface,
.scratch-surface,
.english-surface,
.english-archive-surface,
.research-surface {
  padding: 20px;
}

.agenda-surface {
  scroll-margin-top: 132px;
}

.agenda-heading,
.scratch-heading,
.english-heading,
.english-archive-heading,
.research-source-row,
.calendar-toolbar {
  align-items: center;
}

.agenda-heading h3,
.scratch-heading h3,
.english-heading h3,
.english-archive-heading h3,
.research-source-row h3,
.calendar-toolbar h3 {
  font-size: 17px;
}

.agenda-date {
  margin: 0 0 3px;
}

.week-task-form {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 7px 10px;
  margin-top: 17px;
}

.field-label {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.week-task-form select {
  padding: 8px 30px 8px 10px;
}

.agenda-list {
  margin-top: 16px;
}

.period-tag {
  flex: 0 0 auto;
  border-radius: 4px;
  padding: 3px 6px;
  color: var(--morning);
  background: var(--morning-soft);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.period-tag.period-noon {
  color: var(--noon);
  background: var(--noon-soft);
}

.period-tag.period-afternoon {
  color: var(--afternoon);
  background: var(--afternoon-soft);
}

.period-tag.period-evening {
  color: var(--evening);
  background: var(--evening-soft);
}

.calendar-surface {
  margin-top: 14px;
  padding-bottom: 12px;
}

.month-jump {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.month-jump input {
  min-height: 36px;
  padding: 5px 8px;
  font-size: 12px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-top: 16px;
  border-block: 1px solid var(--line);
  background: var(--surface-subtle);
}

.calendar-weekdays span {
  padding: 8px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

.calendar-weekdays span:nth-child(n + 6) {
  color: var(--evening);
}

.calendar-scroller {
  height: min(64vh, 620px);
  min-height: 430px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.calendar-month {
  padding-bottom: 22px;
  scroll-margin-top: 8px;
}

.calendar-month h4 {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 14px 2px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 253, 249, 0.96);
  font-size: 14px;
  letter-spacing: 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding-top: 6px;
}

.calendar-blank,
.calendar-day {
  height: 52px;
  min-width: 0;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
}

.calendar-day:hover {
  border-color: var(--line-strong);
  background: var(--surface-subtle);
}

.calendar-day-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 650;
}

.calendar-day.is-weekend .calendar-day-number {
  color: var(--evening);
}

.calendar-day.is-today .calendar-day-number {
  color: var(--on-accent);
  background: var(--accent);
}

.calendar-day.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-day.is-selected:not(.is-today) .calendar-day-number {
  color: var(--accent-strong);
  font-weight: 800;
}

.calendar-day.is-detail-open {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.calendar-task-count {
  position: absolute;
  right: 4px;
  bottom: 3px;
  display: grid;
  min-width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 8px;
  padding-inline: 4px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 800;
}

.calendar-day-detail {
  margin-top: 20px;
  scroll-margin-top: 132px;
}

.calendar-detail-heading {
  align-items: center;
}

.calendar-detail-heading h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.scratch-surface + .english-surface {
  margin-top: 14px;
}

.english-surface + .english-archive-surface {
  margin-top: 14px;
}

.scratch-task-list {
  margin-top: 14px;
}

.word-count {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.english-heading-actions {
  display: grid;
  justify-items: end;
  gap: 5px;
  flex: 0 0 auto;
}

.english-learned-button {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--accent-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.english-learned-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.english-learned-button.is-learned {
  border-color: var(--morning);
  color: var(--morning);
  background: var(--morning-soft);
}

.english-learning-status {
  min-height: 14px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.english-learning-status[data-tone="working"] {
  color: var(--afternoon);
}

.english-learning-status[data-tone="success"] {
  color: var(--morning);
}

.english-learning-status[data-tone="error"] {
  color: var(--danger);
}

.english-word-list {
  margin-top: 17px;
  border-top: 1px solid var(--line);
}

.english-word {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.english-word-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.english-word-head h4 {
  margin: 0;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: 0;
}

.english-word-head span {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-style: italic;
}

.pronunciation-button {
  min-height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 3px 7px;
  color: var(--accent);
  background: var(--surface);
  font-family: inherit;
  font-size: 11px;
  font-style: normal;
  font-weight: 750;
}

.pronunciation-button:hover,
.pronunciation-button.is-speaking {
  border-color: var(--accent);
  color: var(--on-accent);
  background: var(--accent);
}

.pronunciation-button.is-compact {
  min-height: 23px;
  padding: 2px 6px;
  font-size: 10px;
}

.word-phonetic {
  margin: 3px 0 7px;
  color: var(--afternoon);
  font-family: "Times New Roman", Georgia, serif;
  font-size: 14px;
  line-height: 1.4;
}

.word-definition-zh,
.word-definition-en {
  margin: 0;
  line-height: 1.55;
}

.word-definition-zh {
  font-size: 14px;
  font-weight: 650;
}

.word-definition-en {
  margin-top: 3px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
}

.english-passage {
  margin-top: 22px;
  padding: 18px;
  border-left: 4px solid var(--afternoon);
  background: var(--afternoon-soft);
}

.english-passage h4 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: 0;
}

.english-passage > p:last-child,
.english-translation p {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  line-height: 1.75;
}

.english-archive-scroller {
  max-height: min(60vh, 560px);
  margin-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.english-history-day + .english-history-day {
  border-top: 2px solid var(--line-strong);
}

.english-history-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.97);
}

.english-history-heading h4,
.english-history-word-heading h5 {
  margin: 0;
  letter-spacing: 0;
}

.english-history-heading h4 {
  margin-top: 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
}

.english-history-date {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.english-history-word {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.english-history-word-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 8px;
}

.english-history-word-heading h5 {
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.english-history-word-heading > span {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-style: italic;
}

.english-history-word-heading .english-history-phonetic {
  color: var(--afternoon);
  font-family: "Times New Roman", Georgia, serif;
  font-size: 13px;
  font-style: normal;
}

.english-history-definition-zh,
.english-history-definition-en {
  margin: 4px 0 0;
  line-height: 1.5;
}

.english-history-definition-zh {
  font-size: 13px;
  font-weight: 650;
}

.english-history-definition-en {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
}

.english-passage > p:last-child {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
}

.english-translation {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.english-translation summary {
  width: fit-content;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.english-translation p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.research-source-row {
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.research-source-row .eyebrow {
  margin-bottom: 4px;
}

.research-source-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  text-align: right;
  text-decoration-color: var(--ornament);
  text-underline-offset: 4px;
}

.research-source-link::after {
  content: " ↗";
}

.research-groups {
  min-width: 0;
}

.research-group {
  padding-top: 21px;
}

.research-group + .research-group {
  margin-top: 8px;
  border-top: 2px solid var(--line-strong);
}

.research-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
}

.research-group-heading h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.research-group-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.research-item {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-block: 20px 21px;
}

.research-experiment {
  margin: 0 0 6px;
  color: var(--afternoon);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.research-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
  letter-spacing: 0;
}

.research-title a {
  color: var(--ink);
  overflow-wrap: anywhere;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.research-title a:hover {
  color: var(--accent);
  text-decoration-color: var(--ornament);
}

.research-title a::after {
  color: var(--ornament);
  content: " ↗";
  font-size: 0.74em;
}

.research-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.research-tags span {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--accent-strong);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.research-publication {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
  border-left: 3px solid var(--ornament);
  padding: 9px 11px;
  background: var(--accent-soft);
  font-size: 12px;
  line-height: 1.5;
}

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

.research-publication strong {
  min-width: 0;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.research-item h5 {
  margin: 18px 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  letter-spacing: 0;
}

.research-summary,
.research-evaluation-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
}

.research-evaluation {
  margin-top: 15px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 12px;
}

.research-evaluation summary {
  width: fit-content;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.research-evaluation-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
}

.research-notes {
  display: grid;
  gap: 7px;
  border-top: 2px solid var(--line-strong);
  padding-top: 16px;
}

.research-notes p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.research-notes p::before {
  color: var(--ornament);
  content: "◆";
  margin-right: 7px;
  font-size: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 11px 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 12px 35px rgba(23, 23, 45, 0.17);
  font-size: 13px;
}

.toast[data-tone="error"] {
  border-color: #e4bbc5;
  color: var(--danger);
  background: #fff7f9;
}

.access-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.access-shell {
  width: min(100%, 390px);
}

.access-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.access-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--ornament);
  color: var(--on-accent);
  background: var(--accent);
  font-size: 13px;
  font-weight: 850;
}

.access-panel h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0;
}

.access-form {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

.access-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.access-form button {
  margin-top: 3px;
}

.access-error {
  min-height: 19px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.access-domain {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 760px);
  }

  .header-inner {
    padding-top: 12px;
  }

  .title-row {
    gap: 9px;
  }

  .title-row h1 {
    font-size: 23px;
  }

  .title-identity {
    gap: 8px;
  }

  .mitya-emblem {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: auto;
    gap: 4px;
  }

  .sync-status {
    grid-column: 1 / -1;
    text-align: right;
  }

  .quiet-button {
    min-height: 32px;
    padding: 6px 8px;
  }

  .view-tabs {
    margin-top: 10px;
  }

  .app-main {
    padding-block: 21px 56px;
  }

  .period-band,
  .agenda-surface,
  .calendar-surface,
  .scratch-surface,
  .english-surface,
  .english-archive-surface,
  .research-surface {
    padding-inline: 14px;
  }

  .task-add-form {
    gap: 6px;
  }

  .task-add-form button,
  .week-task-input-row button {
    padding-inline: 11px;
  }

  .week-strip {
    gap: 3px;
  }

  .week-day {
    min-height: 68px;
  }

  .week-day-name {
    font-size: 9px;
  }

  .week-day strong {
    font-size: 16px;
  }

  .week-task-form {
    grid-template-columns: 72px minmax(0, 1fr);
  }

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

  .calendar-toolbar {
    gap: 8px;
  }

  .calendar-blank,
  .calendar-day {
    height: 48px;
  }

  .calendar-grid {
    gap: 2px;
  }

  .calendar-day-number {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .calendar-task-count {
    right: 1px;
    bottom: 2px;
  }

  .calendar-scroller {
    min-height: 390px;
  }

  .english-passage {
    padding: 15px;
  }

  .english-archive-scroller {
    max-height: 56vh;
  }

  .research-source-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .research-source-link {
    text-align: left;
  }

  .research-title {
    font-size: 17px;
  }

  .research-publication {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .mitya-corner-surface::after {
    bottom: -5px;
    right: -12px;
    width: 94px;
    height: 52px;
    opacity: 0.14;
  }
}

@media (max-width: 360px) {
  .app-shell {
    width: min(100% - 14px, 760px);
  }

  .sync-status {
    display: none;
  }

  .header-actions {
    align-self: start;
  }

  .title-identity {
    gap: 6px;
  }

  .mitya-emblem {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .week-day-marker {
    width: 14px;
    height: 14px;
  }

  .agenda-surface,
  .calendar-surface,
  .scratch-surface,
  .english-surface,
  .english-archive-surface,
  .research-surface,
  .period-band {
    padding-inline: 11px;
  }

  .english-heading {
    gap: 8px;
  }

  .english-learned-button {
    padding-inline: 8px;
    font-size: 11px;
  }
}

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