:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #63716c;
  --paper: #edf3ef;
  --panel: #fbfdf9;
  --line: #d4ded7;
  --study: #0d8f68;
  --rest: #d36a3b;
  --night: #23312f;
  --blue: #2f68b8;
  --focus: #f4c95d;
  --shadow: 0 18px 50px rgba(24, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 104, 184, 0.32);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.executor-shell {
  width: min(860px, calc(100% - 32px));
}

.focus-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: stretch;
  gap: 18px;
  min-height: 360px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
}

.executor-hero {
  grid-template-columns: minmax(0, 1fr) 220px;
  min-height: 420px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.role-chip,
.eyebrow {
  margin: 0 0 14px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 0.94;
  font-weight: 700;
}

h2 {
  font-size: 24px;
  line-height: 1.1;
}

.hero-clock {
  margin-top: 28px;
}

.hero-clock span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.hero-clock strong {
  display: block;
  font-family: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  font-size: clamp(56px, 12vw, 124px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--night);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.lamp-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.lamp-panel p,
.subtle,
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
  min-width: 0;
}

.timeline-panel {
  grid-column: 1 / -1;
}

.home-sync-panel {
  grid-column: 1 / -1;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(47, 104, 184, 0.06), transparent 42%),
    var(--panel);
}

.home-sync-head {
  align-items: center;
}

.home-sync-head .text-link {
  white-space: nowrap;
}

.home-sync-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--night);
}

.home-sync-summary div {
  min-width: 0;
  padding: 15px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.13);
}

.home-sync-summary div:last-child {
  border-right: 0;
}

.home-sync-summary span,
.home-sync-summary strong {
  display: block;
}

.home-sync-summary span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 800;
}

.home-sync-summary strong {
  margin-top: 7px;
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(17px, 2.4vw, 24px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-sync-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
  margin-top: 16px;
}

.home-sync-record {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding: 14px 2px;
}

.home-sync-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--study);
  font-size: 10px;
  box-shadow: 0 0 0 5px rgba(13, 143, 104, 0.1);
}

.home-sync-record.is-rest .home-sync-mark {
  background: var(--rest);
  box-shadow: 0 0 0 5px rgba(211, 106, 59, 0.1);
}

.home-sync-copy {
  min-width: 0;
}

.home-sync-copy strong,
.home-sync-copy p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-sync-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.home-sync-source {
  border-radius: 999px;
  padding: 5px 9px;
  color: #315e98;
  background: #e3ecf8;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.home-sync-duration {
  min-width: 66px;
  color: var(--night);
  text-align: right;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home-sync-empty {
  grid-column: 1 / -1;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 24px 4px 8px;
  color: var(--muted);
  text-align: center;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats div {
  min-height: 112px;
  padding: 18px;
  background: rgba(237, 243, 239, 0.62);
}

.stats span,
.details span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stats strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.details {
  margin: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.details ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.range-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(237, 243, 239, 0.72);
}

.range-toggle button {
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

.range-toggle button.is-active {
  color: #ffffff;
  background: var(--night);
}

.study-timeline {
  display: flex;
  gap: 12px;
  min-height: 560px;
  overflow-x: auto;
  padding-bottom: 4px;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.timeline-day {
  display: grid;
  grid-template-rows: auto minmax(480px, 1fr);
  gap: 10px;
  min-width: 132px;
  flex: 1 0 132px;
}

.timeline-date {
  color: var(--night);
  font-size: 14px;
  font-weight: 900;
}

.calendar-day {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(24, 33, 31, 0.07) 1px, transparent 1px) 0 0 / 100% 12.5%,
    rgba(237, 243, 239, 0.64);
}

.calendar-day[data-empty="true"]::after {
  content: "没有学习记录";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.calendar-hour {
  position: absolute;
  left: 8px;
  transform: translateY(-50%);
  color: rgba(99, 113, 108, 0.72);
  font-family: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  font-size: 11px;
  z-index: 1;
}

.calendar-block {
  position: absolute;
  left: 46px;
  right: 10px;
  min-height: 4px;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--study), #48b98f);
  box-shadow: 0 8px 18px rgba(13, 143, 104, 0.2);
}

.primary {
  color: #ffffff;
  background: var(--study);
}

.secondary {
  color: #ffffff;
  background: var(--rest);
}

.ghost {
  width: 100%;
  color: var(--night);
  background: #dce8e2;
}

.reminder-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.reminder-form input {
  min-height: 52px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font-size: 18px;
}

.reminder-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.reminder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border-top: 1px solid var(--line);
  color: var(--night);
}

.reminder-row button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: #edf3ef;
  font-size: 14px;
}

.action-deck {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.action-deck .hint {
  grid-column: 1 / -1;
}

.text-link,
.back-link {
  color: var(--blue);
  font-weight: 800;
  text-underline-offset: 4px;
}

.action-deck .text-link {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 2px;
}

/* Sync console: a calm instrument panel within the same study-nook language. */
.sync-page {
  background:
    radial-gradient(circle at 9% 4%, rgba(244, 201, 93, 0.24), transparent 24rem),
    linear-gradient(135deg, transparent 0 48%, rgba(35, 49, 47, 0.035) 48% 52%, transparent 52% 100%),
    var(--paper);
  background-size: auto, 34px 34px, auto;
}

.sync-shell {
  width: min(1180px, calc(100% - 32px));
}

.sync-masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 30px 4px 26px;
}

.sync-masthead h1 {
  margin-top: 22px;
  font-size: clamp(52px, 8vw, 96px);
}

.sync-intro {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.7;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(251, 253, 249, 0.86);
}

.status-light {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: var(--focus);
  box-shadow: 0 0 0 5px rgba(244, 201, 93, 0.18);
}

.service-status[data-state="online"] .status-light,
.log-row .status-light {
  background: var(--study);
  box-shadow: 0 0 0 5px rgba(13, 143, 104, 0.14);
}

.service-status[data-state="offline"] .status-light,
.log-row .status-light.has-error {
  background: #d6535d;
  box-shadow: 0 0 0 5px rgba(214, 83, 93, 0.14);
}

.service-status small,
.service-status strong {
  display: block;
}

.service-status small {
  margin-bottom: 2px;
  color: var(--muted);
}

.admin-lock {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.2fr);
  gap: 40px;
  align-items: end;
  padding: 30px;
  box-shadow: var(--shadow);
}

.admin-lock[hidden],
.sync-console[hidden],
.token-form[hidden],
.token-reveal[hidden] {
  display: none;
}

.unlock-form label,
.token-form label,
.filter-bar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.unlock-form input,
.token-form input,
.filter-bar input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
}

.form-message,
.console-message {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--rest);
  font-weight: 700;
}

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

.sync-summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--night);
  color: #fff;
}

.sync-summary article {
  min-width: 0;
  padding: 22px;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

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

.sync-summary span {
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  font-weight: 700;
}

.sync-summary strong {
  margin-top: 8px;
  overflow: hidden;
  font-size: clamp(20px, 3vw, 30px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-summary > button {
  align-self: center;
  margin: 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.records-panel {
  grid-column: 1 / -1;
}

.sync-panel-head {
  align-items: center;
}

.compact-button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.quiet-button,
.danger-button,
.text-button {
  min-height: 42px;
  color: var(--night);
  background: #dce8e2;
}

.danger-button {
  color: #9f3943;
  background: #f7e4e5;
}

.text-button {
  padding-inline: 8px;
  color: var(--blue);
  background: transparent;
}

.token-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: end;
  margin: -2px 0 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.token-reveal {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid #e2ba4f;
  border-radius: 8px;
  padding: 16px;
  background: #fff7dc;
}

.token-reveal p,
.token-row p,
.log-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.token-reveal code {
  overflow-wrap: anywhere;
  border: 1px dashed #d3a634;
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.74);
}

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

.token-row,
.log-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.token-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  background: var(--study);
  font-weight: 900;
}

.state-pill,
.source-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 9px;
  color: #087555;
  background: #dff2e9;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.state-pill.is-revoked {
  color: #9f3943;
  background: #f7e4e5;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #edf3ef;
  font-size: 12px;
  letter-spacing: 0.04em;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 3px;
  color: var(--muted);
}

td code {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-chip {
  color: #315e98;
  background: #e3ecf8;
}

.empty-state {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
  text-align: center;
}

.log-row {
  grid-template-columns: auto minmax(0, 1fr);
}

.log-row > code {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
}

body[data-status="study"] .role-chip,
body[data-status="study"] .eyebrow {
  color: var(--study);
}

body[data-status="rest"] .role-chip,
body[data-status="rest"] .eyebrow {
  color: var(--rest);
}

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

@media (max-width: 860px) {
  .focus-hero,
  .executor-hero,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .lamp-panel {
    align-items: flex-start;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 0 0;
  }

  .stats,
  .details ol,
  .action-deck,
  .home-sync-records {
    grid-template-columns: 1fr;
  }

  .focus-hero {
    min-height: 0;
    padding: 20px;
  }

  .sync-console,
  .admin-lock {
    grid-template-columns: 1fr;
  }

  .records-panel {
    grid-column: auto;
  }

  .filter-bar,
  .token-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  button {
    width: 100%;
  }

  .shell,
  .executor-shell {
    width: min(100% - 20px, 560px);
    padding: 10px 0 24px;
  }

  .focus-hero,
  .executor-hero {
    display: block;
    min-height: 0;
    padding: 16px;
    box-shadow: 0 10px 28px rgba(24, 33, 31, 0.1);
  }

  h1 {
    font-size: clamp(36px, 12vw, 54px);
    line-height: 1;
  }

  h2 {
    font-size: 21px;
  }

  .hero-clock {
    margin-top: 22px;
  }

  .hero-clock strong {
    font-size: clamp(44px, 17vw, 70px);
    line-height: 0.95;
  }

  .lamp-panel {
    margin-top: 18px;
    padding-top: 14px;
  }

  .dashboard-grid {
    gap: 12px;
    margin-top: 12px;
  }

  .panel {
    padding: 16px;
  }

  .panel-head {
    display: grid;
    align-items: start;
    gap: 12px;
  }

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

  .home-sync-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-sync-summary div:nth-child(2) {
    border-right: 0;
  }

  .home-sync-summary div:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  }

  .home-sync-record {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .home-sync-duration {
    grid-column: 2 / -1;
    justify-self: start;
    text-align: left;
  }

  .stats div {
    min-height: 92px;
    padding: 14px;
  }

  .stats strong {
    font-size: 24px;
    overflow-wrap: anywhere;
  }

  .details ol {
    display: block;
  }

  .details li + li {
    margin-top: 6px;
  }

  .range-toggle {
    width: 100%;
  }

  .range-toggle button {
    width: auto;
  }

  .study-timeline {
    gap: 10px;
    min-height: 460px;
    margin: 0 -16px;
    padding: 0 16px 8px;
  }

  .timeline-day {
    grid-template-rows: auto 400px;
    min-width: 112px;
    flex-basis: 112px;
  }

  .calendar-day {
    min-height: 400px;
  }

  .calendar-hour {
    left: 6px;
    font-size: 10px;
  }

  .calendar-block {
    left: 36px;
    right: 7px;
  }

  .action-deck {
    gap: 10px;
    padding: 14px;
  }

  .sync-shell {
    width: min(100% - 20px, 560px);
  }

  .sync-masthead {
    grid-template-columns: 1fr;
    padding: 16px 2px 20px;
  }

  .sync-masthead h1 {
    margin-top: 16px;
  }

  .service-status {
    justify-self: start;
  }

  .admin-lock {
    gap: 22px;
    padding: 20px;
  }

  .inline-field,
  .filter-bar,
  .token-form {
    grid-template-columns: 1fr;
  }

  .sync-summary {
    grid-template-columns: 1fr 1fr;
  }

  .sync-summary article {
    padding: 16px;
  }

  .sync-summary > button {
    grid-column: 1 / -1;
  }

  .token-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .token-row .danger-button {
    grid-column: 2 / -1;
    justify-self: start;
  }
}

@media (max-width: 420px) {
  .shell,
  .executor-shell {
    width: min(100% - 14px, 420px);
  }

  .focus-hero,
  .executor-hero,
  .panel {
    padding: 14px;
  }

  h1 {
    font-size: clamp(32px, 13vw, 46px);
  }

  .hero-clock strong {
    font-size: clamp(38px, 16vw, 56px);
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .home-sync-summary {
    grid-template-columns: 1fr;
  }

  .home-sync-summary div,
  .home-sync-summary div:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  }

  .home-sync-summary div:last-child {
    border-bottom: 0;
  }

  .study-timeline {
    margin: 0 -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .timeline-day {
    min-width: 104px;
    flex-basis: 104px;
  }
}
