:root {
  color-scheme: light;
  --paper: #f6f1df;
  --panel: #fffaf0;
  --ink: #1f1b16;
  --muted: #756f64;
  --line: #1f1b16;
  --mint: #9fd8b5;
  --blue: #8fb8de;
  --amber: #f0c56a;
  --rose: #e8a2a0;
  --urgent: #e76f51;
  --shadow: 5px 5px 0 var(--ink);
  --radius: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(31, 27, 22, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(31, 27, 22, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 16px 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Courier New", "Microsoft YaHei", monospace;
  letter-spacing: 0;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 12px;
}

.auth-layout {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
}

.auth-brand {
  text-align: center;
}

.auth-brand h1 {
  margin: 4px 0 10px;
  font-size: 3rem;
  line-height: 1;
  text-shadow:
    3px 0 0 var(--amber),
    0 3px 0 var(--mint),
    3px 3px 0 var(--ink);
}

.auth-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.auth-stamp {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  padding: 0 10px;
  border: 2px solid var(--line);
  background: var(--amber);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.auth-panel {
  overflow: hidden;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 3px solid var(--line);
}

.auth-tab,
.auth-submit {
  min-height: 44px;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.auth-tab + .auth-tab {
  border-left: 3px solid var(--line);
}

.auth-tab.is-selected {
  background: var(--blue);
  box-shadow: inset 0 -5px 0 rgba(31, 27, 22, 0.16);
}

.auth-form {
  display: grid;
  gap: 9px;
  padding: 18px;
}

.auth-form label {
  font-size: 0.86rem;
  font-weight: 900;
}

.auth-form input {
  width: 100%;
  min-height: 46px;
  border: 2px solid var(--line);
  background: #fffef8;
  color: var(--ink);
  outline: none;
  padding: 0 10px;
}

.auth-submit {
  margin-top: 8px;
  border: 2px solid var(--line);
  background: var(--mint);
  box-shadow: var(--shadow);
}

.auth-tab:hover,
.auth-submit:hover {
  filter: brightness(0.97);
}

.auth-tab:active,
.auth-submit:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.auth-tab:disabled,
.auth-submit:disabled,
.auth-form input:disabled {
  cursor: wait;
  opacity: 0.58;
}

.auth-message {
  min-height: 22px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.5;
  text-align: center;
}

.auth-message.is-error {
  color: var(--urgent);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 28px;
}

.topbar {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 108px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.top-actions .text-button {
  min-width: 52px;
  padding-inline: 6px;
}

.logout-button {
  background: #ffd6d2;
}

.brand-title {
  margin: 0;
  text-align: center;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    3px 0 0 var(--amber),
    0 3px 0 var(--mint),
    3px 3px 0 var(--ink);
}

.is-invisible {
  visibility: hidden;
  pointer-events: none;
}

.icon-button,
.text-button,
.duration-button,
.event-type-button,
.progress-button,
.complete-button,
.home-event-button {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: none;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  font-size: 1.12rem;
  font-weight: 900;
}

.top-nav-button {
  width: 52px;
  min-width: 52px;
  font-size: 0.84rem;
}

.text-button {
  min-height: 38px;
  padding: 0 8px;
  font-weight: 900;
  white-space: nowrap;
}

.icon-button:hover,
.text-button:hover,
.duration-button:hover,
.event-type-button:hover,
.progress-button:hover,
.complete-button:hover,
.home-event-button:hover,
.calendar-day:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.icon-button:active,
.text-button:active,
.duration-button:active,
.event-type-button:active,
.progress-button:active,
.complete-button:active,
.home-event-button:active,
.calendar-day:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.month-toolbar,
.day-heading {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.page-arrow {
  justify-self: center;
}

#calendarTitle,
#dateTitle {
  margin: 0;
  text-align: center;
  font-size: 1.8rem;
  line-height: 1;
}

#calendarTitle {
  justify-self: center;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--ink);
}

.date-card {
  min-width: 0;
  justify-self: center;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

#dateTitle {
  display: inline-block;
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--ink);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-row {
  margin: 0 0 8px;
}

.weekday-row span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  min-height: clamp(72px, 10vw, 108px);
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: none;
}

.calendar-day.is-outside {
  color: rgba(31, 27, 22, 0.35);
  background: #eee7d1;
}

.calendar-day.is-today {
  background: var(--mint);
}

.calendar-day.is-selected {
  background: var(--amber);
}

.day-number {
  align-self: start;
  font-size: 1.05rem;
  font-weight: 900;
}

.day-marker {
  align-self: end;
  justify-self: end;
  width: 10px;
  height: 10px;
  border: 2px solid var(--line);
  background: var(--rose);
}

.pixel-panel {
  min-width: 0;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
  border-bottom: 3px solid var(--line);
  background: #fff4c8;
  box-shadow: inset 0 -4px 0 rgba(31, 27, 22, 0.08);
}

.panel-title h3,
.subsection-title h4 {
  margin: 0;
  line-height: 1.1;
}

.panel-title h3 {
  font-size: 1rem;
}

.event-board {
  margin-top: 16px;
}

.home-event-list {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.home-event-button {
  display: grid;
  grid-template-columns: 28px 86px 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  width: 100%;
  padding: 6px 8px;
  text-align: left;
}

.home-event-button.is-urgent {
  background: #ffe1dc;
}

.event-date,
.event-text,
.detail-mark {
  min-width: 0;
}

.event-date {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.event-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.level-badge,
.animal-icon,
.detail-mark {
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 4px;
  font-weight: 900;
  line-height: 1;
}

.animal-icon {
  width: 26px;
  height: 26px;
  background: var(--mint);
  font-size: 0.78rem;
}

.level-badge {
  min-height: 26px;
  padding: 0 6px;
  background: var(--blue);
  font-size: 0.78rem;
}

.level-badge.is-urgent {
  background: var(--urgent);
  color: #fffaf0;
}

.detail-mark {
  min-height: 24px;
  padding: 0 5px;
  background: var(--amber);
  font-size: 0.72rem;
}

.home-empty,
.list-empty,
.empty-state {
  color: var(--muted);
  font-weight: 900;
}

.home-empty,
.list-empty {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

.day-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  grid-template-areas:
    "note timeline"
    "summary summary";
  gap: 12px;
  align-items: start;
}

.note-panel {
  grid-area: note;
}

.timeline-panel {
  grid-area: timeline;
}

.note-panel,
.timeline-panel {
  display: flex;
  height: 720px;
  min-height: 720px;
  flex-direction: column;
  overflow: hidden;
}

.timeline-panel .panel-title {
  background: #d9ecfb;
}

.summary-area {
  grid-area: summary;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.summary-area.has-extra {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-panel .panel-title {
  background: #ddf0e4;
}

.extra-summary .panel-title {
  background: #f8d4d0;
}

.notebook-body {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 14px;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.note-section {
  display: grid;
  gap: 8px;
}

.note-section + .note-section {
  padding-top: 14px;
  border-top: 3px dashed var(--line);
}

.subsection-title {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.subsection-title h4 {
  font-size: 0.95rem;
}

.timeline-slot input {
  width: 100%;
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fffef8;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.event-type-row,
.duration-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.event-type-button,
.duration-button {
  min-height: 38px;
  padding: 0 10px;
  font-weight: 900;
}

.duration-button.is-selected {
  background: var(--blue);
}

.event-type-button {
  background: var(--mint);
}

.event-type-button.is-urgent {
  background: var(--urgent);
  color: #fffaf0;
}

.note-entry-list {
  display: grid;
  gap: 14px;
}

.note-entry {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--line);
  background: #fffef8;
  box-shadow: 3px 3px 0 var(--line);
}

.entry-header {
  display: flex;
  gap: 6px;
  align-items: center;
}

.entry-header-spacer {
  min-width: 0;
  flex: 1;
}

.entry-header .level-badge,
.progress-button {
  width: 76px;
  min-width: 76px;
  min-height: 36px;
}

.note-entry.is-completed .event-text-input {
  color: var(--muted);
  text-decoration: line-through;
}

.daily-note-input,
.event-text-input {
  width: 100%;
  border: 2px solid var(--line);
  outline: none;
  background:
    repeating-linear-gradient(
      transparent 0,
      transparent 31px,
      rgba(31, 27, 22, 0.12) 32px
    ),
    #fffef8;
  padding: 10px 12px;
  line-height: 32px;
}

.daily-note-input {
  min-height: 260px;
}

.event-text-input {
  min-height: 112px;
  resize: vertical;
}

.tiny-delete {
  display: inline-grid;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  place-items: center;
  padding: 0;
  font-weight: 900;
}

.progress-button {
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  background: var(--amber);
  font-weight: 900;
}

.progress-button.has-detail {
  box-shadow:
    inset 0 -5px 0 var(--mint),
    var(--shadow);
}

.tiny-delete {
  background: #ffd6d2;
  box-shadow: none;
}

.entry-detail {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px dashed var(--line);
  background: #f3edda;
}

.detail-text {
  min-height: 180px;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--panel);
  color: var(--ink);
  padding: 10px;
  line-height: 1.6;
}

.complete-button {
  min-height: 36px;
  padding: 0 10px;
  background: var(--mint);
  font-weight: 900;
  white-space: nowrap;
}

.complete-button.is-completed {
  background: var(--amber);
}

.duration-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px;
  border-bottom: 2px solid var(--line);
}

.timeline-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.timeline-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.timeline-slot {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.timeline-slot time {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #f7e6aa;
  font-weight: 900;
}

.delete-slot-button {
  background: #ffd6d2;
  box-shadow: none;
}

.empty-state {
  display: none;
  margin: 12px;
  min-height: 54px;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state.is-visible {
  display: grid;
}

textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 0;
  outline: none;
  background:
    repeating-linear-gradient(
      transparent 0,
      transparent 31px,
      rgba(31, 27, 22, 0.12) 32px
    ),
    var(--panel);
  color: var(--ink);
  padding: 14px;
  line-height: 32px;
}

.summary-panel textarea {
  min-height: 180px;
}

input:focus,
textarea:focus,
.detail-text:focus {
  box-shadow: inset 0 0 0 2px var(--blue);
}

.notebook-body,
.timeline-scroll {
  scrollbar-width: auto;
  scrollbar-color: var(--amber) #e8e0c9;
}

.notebook-body::-webkit-scrollbar,
.timeline-scroll::-webkit-scrollbar {
  width: 14px;
}

.notebook-body::-webkit-scrollbar-track,
.timeline-scroll::-webkit-scrollbar-track {
  border-left: 2px solid var(--line);
  background: #e8e0c9;
}

.notebook-body::-webkit-scrollbar-thumb,
.timeline-scroll::-webkit-scrollbar-thumb {
  border: 2px solid var(--line);
  background: var(--amber);
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 10px;
  }

  .topbar {
    grid-template-columns: 108px minmax(0, 1fr) 108px;
  }

  .brand-title {
    font-size: 2.25rem;
  }

  .month-toolbar,
  .day-heading {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .calendar-grid,
  .weekday-row {
    gap: 6px;
  }

  .calendar-day {
    min-height: 56px;
    padding: 6px;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .day-number {
    font-size: 0.9rem;
  }

  .home-event-button {
    grid-template-columns: 28px 1fr auto;
  }

  .home-event-button .event-date,
  .home-event-button .level-badge {
    grid-column: auto;
  }

  .home-event-button .event-text {
    grid-column: 1 / -1;
    padding-left: 34px;
  }

  .day-layout,
  .summary-area.has-extra {
    grid-template-columns: 1fr;
  }

  .day-layout {
    grid-template-areas:
      "note"
      "timeline"
      "summary";
  }

  .note-panel,
  .timeline-panel {
    height: 640px;
    min-height: 640px;
  }

  .entry-detail {
    margin-left: 0;
  }

  .timeline-slot {
    grid-template-columns: 1fr 42px;
  }

  .timeline-slot time {
    grid-column: 1 / -1;
    justify-content: start;
    padding-left: 10px;
  }
}

@media (max-width: 500px) {
  .brand-title {
    font-size: 2rem;
  }

  .auth-brand h1 {
    font-size: 2.5rem;
  }

  #calendarTitle,
  #dateTitle {
    font-size: 1.2rem;
  }

  .event-type-row,
  .duration-row {
    gap: 6px;
  }

  .event-type-button,
  .duration-button {
    padding-inline: 4px;
  }

  .note-panel,
  .timeline-panel {
    height: 580px;
    min-height: 580px;
  }

  .entry-header {
    gap: 4px;
  }

  .entry-header .level-badge,
  .progress-button {
    width: 64px;
    min-width: 64px;
    font-size: 0.78rem;
  }

  .entry-header .complete-button {
    padding-inline: 5px;
    font-size: 0.78rem;
  }
}

@media (max-width: 360px) {
  .topbar {
    grid-template-columns: 100px minmax(0, 1fr) 100px;
  }

  .brand-title {
    font-size: 1.45rem;
  }

  .top-actions {
    gap: 2px;
  }

  .top-actions .text-button {
    min-width: 48px;
    padding-inline: 4px;
    font-size: 0.78rem;
  }
}
