:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5f6a73;
  --paper: #f5f2ea;
  --surface: #fffdf8;
  --surface-soft: #f8f6f0;
  --line: #d8d1c4;
  --line-strong: #b9afa0;
  --steel: #23465b;
  --blue: #245d96;
  --blue-deep: #17466f;
  --blue-soft: #e9f1f7;
  --brick: #963f31;
  --brick-soft: #f7ece8;
  --gold: #a67b2e;
  --gold-soft: #f7efd9;
  --shadow: 0 18px 46px rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #eeece6;
  cursor: not-allowed;
  color: #727b82;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--blue-deep);
  outline-offset: 2px;
}

.page-masthead {
  align-items: center;
  background: rgba(245, 242, 234, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px clamp(16px, 4vw, 52px);
}

.page-masthead a {
  color: var(--steel);
  font-family: "Songti SC", SimSun, serif;
  font-size: 1.05rem;
  font-weight: 800;
}

.page-masthead span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.mistake-log-main {
  margin: 0 auto;
  max-width: 1460px;
  min-width: 0;
  padding: clamp(22px, 4vw, 52px) clamp(14px, 3.5vw, 48px) 48px;
  width: 100%;
}

.section-kicker,
.panel-heading p,
.detail-heading p {
  color: var(--brick);
  font-size: 0.75rem;
  font-weight: 800;
  margin: 0 0 7px;
}

.locked-view {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brick);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: clamp(26px, 7vh, 76px) auto 0;
  max-width: 560px;
  padding: clamp(26px, 5vw, 46px);
}

.locked-view h1,
.workspace-heading h1,
.panel-heading h2,
.detail-heading h2 {
  font-family: "Songti SC", SimSun, serif;
}

.locked-view h1 {
  font-size: 2.3rem;
  line-height: 1.2;
  margin: 0;
}

.locked-intro {
  color: var(--muted);
  line-height: 1.8;
  margin: 17px 0 9px;
}

.privacy-note {
  border-left: 3px solid var(--gold);
  color: var(--steel);
  font-size: 0.86rem;
  margin: 0 0 26px;
  padding: 4px 0 4px 10px;
}

.access-form,
.entry-form {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.access-form label,
.entry-form label {
  font-size: 0.84rem;
  font-weight: 750;
}

input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  max-width: 100%;
  min-height: 44px;
  min-width: 0;
  padding: 10px 12px;
  width: 100%;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--steel);
}

textarea {
  line-height: 1.65;
  resize: vertical;
}

.access-form button,
.month-toolbar button,
.detail-heading button,
.form-actions button,
.entry-list button {
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 750;
  min-height: 42px;
  padding: 9px 14px;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.access-form button,
.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.access-form button:hover:not(:disabled),
.primary-button:hover:not(:disabled) {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

.workspace-view {
  min-width: 0;
}

.workspace-header {
  align-items: end;
  border-bottom: 1px solid var(--line-strong);
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  margin-bottom: 20px;
  min-width: 0;
  padding: 0 2px 18px;
}

.workspace-heading {
  min-width: 0;
}

.workspace-heading h1 {
  font-size: 3rem;
  line-height: 1.1;
  margin: 0;
}

#monthLabel {
  color: var(--steel);
  font-size: 1rem;
  font-weight: 800;
  margin: 10px 0 0;
}

.guiding-principle {
  align-self: center;
  font-family: "Songti SC", SimSun, serif;
  color: var(--steel);
  font-size: 2.25rem;
  font-weight: 800;
  margin: 0;
  padding: 10px 20px;
  position: relative;
  text-align: center;
  white-space: nowrap;
}

.guiding-principle::after {
  background: var(--gold);
  bottom: 2px;
  content: "";
  height: 2px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 42px;
}

.month-toolbar {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
}

.month-toolbar button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--steel);
  flex: 0 0 auto;
  white-space: nowrap;
}

.month-toolbar button:hover:not(:disabled) {
  background: var(--blue-soft);
  border-color: #9cb8cc;
  color: var(--blue-deep);
}

#reloadMonthButton {
  background: var(--gold-soft);
  border-color: #d4b873;
  color: #6c4c12;
}

#logoutButton {
  background: var(--brick-soft);
  border-color: #dcbab2;
  color: #773126;
}

.mistake-log-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
}

.calendar-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: clamp(14px, 2vw, 22px);
}

.calendar-panel {
  border-top: 4px solid var(--steel);
}

.detail-panel {
  align-self: start;
  border-top: 4px solid var(--gold);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  position: sticky;
  top: 20px;
}

.panel-heading,
.detail-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 14px;
  min-width: 0;
  padding-bottom: 13px;
}

.panel-heading h2,
.detail-heading h2 {
  font-size: 1.28rem;
  line-height: 1.3;
  margin: 0;
  overflow-wrap: anywhere;
}

.panel-heading > span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.75rem;
}

.calendar-frame {
  min-width: 0;
}

.calendar-weekdays {
  color: var(--muted);
  display: grid;
  font-size: 0.76rem;
  font-weight: 800;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  text-align: center;
}

.calendar-weekdays li {
  min-width: 0;
  padding: 5px 0;
}

.calendar-weekdays abbr {
  text-decoration: none;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.calendar-grid > .calendar-weekday {
  display: none;
}

.calendar-placeholder {
  aspect-ratio: 1 / 1;
  border: 1px dashed rgba(185, 175, 160, 0.52);
  border-radius: 6px;
  min-width: 0;
}

.calendar-day {
  aspect-ratio: 1 / 1;
  min-width: 0;
  align-content: start;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  gap: 2px;
  justify-items: start;
  overflow: hidden;
  padding: clamp(5px, 0.8vw, 10px);
  text-align: left;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease;
}

.calendar-day:hover:not(:disabled):not(.is-selected) {
  background: #f1eee6;
  border-color: var(--steel);
  box-shadow: inset 0 0 0 1px rgba(35, 70, 91, 0.14);
}

.calendar-day time {
  font-family: "Songti SC", SimSun, serif;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1;
}

.calendar-day-count {
  color: var(--brick);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
}

.calendar-note-summary {
  color: var(--steel);
  display: block;
  font-size: 0.7rem;
  line-height: 1.3;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.calendar-note-more {
  color: var(--brick);
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.3;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.calendar-day.is-today {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: #553b0e;
}

.calendar-day.is-selected {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.calendar-day.is-selected .calendar-day-count,
.calendar-day.is-selected .calendar-note-summary,
.calendar-day.is-selected .calendar-note-more {
  color: #ffffff;
}

.calendar-day:disabled {
  cursor: progress;
}

.detail-heading {
  align-items: end;
}

.detail-heading > div {
  min-width: 0;
}

.detail-heading button {
  flex: 0 0 auto;
}

.empty-day-message {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
  padding: 12px 0 20px;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry-list li {
  border-bottom: 1px solid var(--line);
  min-width: 0;
  padding: 16px 0;
}

.entry-list strong,
.entry-list p,
.entry-list time {
  overflow-wrap: anywhere;
}

.entry-list strong {
  color: var(--brick);
  display: block;
  font-size: 0.88rem;
}

.entry-list p {
  line-height: 1.68;
  margin: 7px 0;
  white-space: pre-wrap;
}

.entry-list time {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
}

.entry-list li > div {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.entry-list button {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--steel);
  min-height: 42px;
  min-width: 42px;
  padding: 7px 12px;
}

.entry-list button:last-child {
  background: var(--brick-soft);
  border-color: #dcbab2;
  color: #773126;
}

.entry-form {
  border-top: 2px solid var(--gold);
  margin-top: 18px;
  padding-top: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.quiet-button {
  background: var(--surface-soft);
  border-color: var(--line) !important;
  color: var(--steel);
}

.status-message {
  color: var(--blue-deep);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.55;
  margin: 14px 2px 0;
  min-height: 1.55em;
  overflow-wrap: anywhere;
}

.status-message:empty {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1100px) {
  .workspace-header {
    align-items: flex-start;
  }

  .month-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 820px) {
  .mistake-log-main {
    overflow-x: hidden;
    padding: 18px 10px 36px;
  }

  .workspace-header {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-heading h1 {
    font-size: 2.1rem;
  }

  .guiding-principle {
    font-size: 1.75rem;
    justify-self: start;
    padding: 5px 0 9px;
    text-align: left;
  }

  .guiding-principle::after {
    left: 0;
    transform: none;
  }

  .mistake-log-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .month-toolbar {
    flex-wrap: wrap;
    justify-content: flex-start;
    justify-self: start;
  }

  .month-toolbar button {
    min-height: 44px;
  }

  .calendar-day {
    min-height: 42px;
  }

  .detail-panel {
    max-height: none;
    overflow: visible;
    position: static;
  }

  .detail-heading,
  .panel-heading {
    align-items: center;
  }

  .entry-list p,
  .entry-list strong,
  .entry-form,
  .detail-heading {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 360px) {
  .mistake-log-main {
    padding-inline: 2px;
  }

  .calendar-grid {
    gap: 2px;
  }

  .calendar-weekdays {
    gap: 2px;
  }

  .calendar-panel {
    padding-inline: 4px;
  }

  .calendar-day time {
    font-size: 0.94rem;
  }
}
