* {
  box-sizing: border-box;
}

:root {
  --ink: #26231f;
  --muted: #746f68;
  --line: #ded8cc;
  --paper: #fbfaf6;
  --page: #fffdf8;
  --mist: #eef3f0;
  --sage: #6f8b7a;
  --brick: #a35643;
  --gold: #b58a45;
  --shadow: 0 22px 60px rgba(38, 35, 31, 0.1);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family:
    ui-serif, "Songti SC", "Noto Serif CJK SC", Georgia, "Times New Roman",
    serif;
  background:
    linear-gradient(rgba(255, 253, 248, 0.78), rgba(255, 253, 248, 0.78)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(116, 111, 104, 0.08) 32px),
    #ede7dc;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.book-rail,
.capture-panel {
  align-self: start;
  position: sticky;
  top: 22px;
}

.book-rail {
  padding: 18px;
  border: 1px solid rgba(38, 35, 31, 0.1);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.86);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 62px;
  color: #fffdf8;
  background: var(--ink);
  border-radius: 4px;
  font-size: 20px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 11px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  margin-bottom: 0;
  font-size: 44px;
  font-weight: 500;
}

h3 {
  margin-bottom: 0;
  font-size: 22px;
  font-weight: 500;
}

.year-card,
.phone-card,
.result-card {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
}

.year-card span,
.quiet {
  color: var(--muted);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
}

.year-card strong {
  display: block;
  margin: 8px 0;
  font-size: 25px;
  font-weight: 500;
}

.year-card p,
.body-copy,
.result-card p {
  color: var(--muted);
  line-height: 1.7;
}

.month-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.month-list button,
.phone-card button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.month-list button.active {
  color: #fffdf8;
  border-color: var(--ink);
  background: var(--ink);
}

.month-list button.muted {
  color: #aaa39a;
  background: rgba(222, 216, 204, 0.24);
}

.planner {
  min-width: 0;
}

.topbar,
.section-title,
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 46vw);
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.82);
}

.search-box span {
  color: var(--sage);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 20px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.book-view {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid rgba(38, 35, 31, 0.1);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.86);
  box-shadow: var(--shadow);
}

.book-frame {
  position: relative;
  min-height: var(--book-page-height, 610px);
  perspective: 1500px;
  transition: min-height 180ms ease;
}

.page-stack {
  position: relative;
  min-height: var(--book-page-height, 610px);
  transition: min-height 180ms ease;
}

.book-page {
  position: absolute;
  inset: 0;
  display: none;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(38, 35, 31, 0.04), transparent 7%, transparent 93%, rgba(38, 35, 31, 0.03)),
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(116, 111, 104, 0.08) 31px),
    var(--page);
  box-shadow:
    inset 16px 0 28px rgba(38, 35, 31, 0.035),
    0 18px 40px rgba(38, 35, 31, 0.08);
  transform-origin: left center;
}

.book-page.active {
  display: block;
  animation: pageIn 220ms ease-out;
}

.book-page.turning-next {
  animation: turnNext 300ms ease-out;
}

.book-page.turning-prev {
  animation: turnPrev 300ms ease-out;
}

@keyframes pageIn {
  from {
    opacity: 0.35;
    transform: translateX(18px) rotateY(-4deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
  }
}

@keyframes turnNext {
  from {
    opacity: 0.5;
    transform: rotateY(-12deg) translateX(28px);
  }
  to {
    opacity: 1;
    transform: rotateY(0) translateX(0);
  }
}

@keyframes turnPrev {
  from {
    opacity: 0.5;
    transform: rotateY(10deg) translateX(-28px);
  }
  to {
    opacity: 1;
    transform: rotateY(0) translateX(0);
  }
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.day-cell {
  text-align: left;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--page);
  cursor: pointer;
}

.day-cell:hover {
  border-color: rgba(38, 35, 31, 0.35);
  transform: translateY(-1px);
}

.day-cell b {
  font-size: 18px;
  font-weight: 500;
}

.day-cell p {
  margin: 16px 0 2px;
  font-size: 14px;
  line-height: 1.35;
}

.day-cell span {
  color: var(--muted);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 12px;
}

.day-cell.empty {
  color: #aaa39a;
  background: rgba(255, 253, 248, 0.45);
}

.day-cell.note {
  border-color: rgba(111, 139, 122, 0.55);
  background: var(--mist);
}

.day-cell.selected {
  border: 1.5px solid var(--brick);
  background: #fff8f2;
}

.day-cell.today {
  border-color: rgba(181, 138, 69, 0.65);
  background: #fffaf0;
}

.daily-page-template {
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 20px;
}

.book-page.daily-page-template.active {
  display: grid;
}

.date-strip {
  padding: 16px 14px;
  border-right: 1px solid var(--line);
}

.date-strip strong {
  display: block;
  font-size: 72px;
  line-height: 0.94;
  font-weight: 400;
}

.date-strip > span {
  color: var(--muted);
}

.meta-list {
  margin-top: 28px;
  color: var(--muted);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
}

.meta-list p {
  margin-bottom: 9px;
}

.paper-page {
  min-height: 520px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(116, 111, 104, 0.09) 31px),
    var(--page);
}

.turn-button {
  position: absolute;
  z-index: 10;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 14px 28px rgba(38, 35, 31, 0.08);
  cursor: pointer;
  font-size: 38px;
  line-height: 1;
  transform: translateY(-50%);
}

.turn-button.prev {
  left: -14px;
}

.turn-button.next {
  right: -14px;
}

.turn-button:disabled,
.control-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.book-controls {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 104px;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.control-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.72);
  cursor: pointer;
}

.page-indicator {
  color: var(--muted);
  text-align: center;
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 22px;
}

.entry {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 16px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(222, 216, 204, 0.8);
}

.entry-num {
  color: var(--brick);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
}

.entry-body p {
  line-height: 1.9;
}

.entry.emphasized {
  padding: 16px 0 0;
}

.ai-summary {
  margin-top: 12px;
  padding: 13px 14px;
  border-left: 3px solid var(--sage);
  background: rgba(238, 243, 240, 0.78);
}

.ai-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--sage);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 12px;
}

.ai-summary p {
  margin-bottom: 0;
  color: #42403b;
}

.blank-note {
  display: grid;
  place-content: center;
  min-height: 360px;
  color: var(--muted);
  text-align: center;
}

.blank-note p {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 28px;
}

.blank-note span {
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 14px;
}

.capture-panel {
  display: grid;
  gap: 18px;
}

.phone-card {
  background: #25231f;
  color: #fffdf8;
}

.phone-card .eyebrow,
.phone-card .body-copy {
  color: rgba(255, 253, 248, 0.68);
}

.message-bubble {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 8px 8px 2px 8px;
  background: rgba(255, 253, 248, 0.13);
  line-height: 1.6;
}

.message-bubble.image {
  color: #d8e5dc;
}

.phone-card button {
  width: 100%;
  margin-top: 16px;
  color: var(--ink);
  border-color: #fffdf8;
  background: #fffdf8;
}

.entry-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--page);
  box-shadow: 0 28px 80px rgba(38, 35, 31, 0.22);
}

.entry-dialog::backdrop {
  background: rgba(38, 35, 31, 0.28);
}

.entry-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

.close-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.entry-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
}

.entry-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(116, 111, 104, 0.08) 31px),
    #fffdf8;
  line-height: 1.8;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: #fffdf8;
  background: var(--ink);
  cursor: pointer;
}

.result-card a {
  display: inline-block;
  margin: 12px 0 8px;
  color: var(--brick);
  text-decoration: none;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .book-rail,
  .capture-panel {
    position: static;
  }

  .book-rail {
    display: grid;
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(68px, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    gap: 14px;
    padding: 10px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .book-rail,
  .planner,
  .capture-panel,
  .book-view,
  .book-frame,
  .page-stack,
  .book-page,
  .paper-page {
    min-width: 0;
    max-width: 100%;
  }

  .book-rail,
  .book-view,
  .phone-card,
  .result-card {
    border-radius: 6px;
    box-shadow: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h2 {
    font-size: 38px;
  }

  .search-box {
    width: 100%;
  }

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

  .day-cell {
    min-width: 0;
  }

  .day-cell {
    min-height: 82px;
  }

  .book-view {
    padding: 12px;
  }

  .book-frame,
  .page-stack {
    min-height: var(--book-page-height, 690px);
  }

  .book-page {
    padding: 16px;
    overflow: hidden;
  }

  .daily-page-template {
    grid-template-columns: 1fr;
  }

  .paper-page {
    min-height: 440px;
  }

  .date-strip {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .date-strip strong {
    grid-row: span 3;
    font-size: 62px;
  }

  .meta-list {
    margin-top: 8px;
  }

  .entry {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .turn-button {
    display: none;
  }

  .book-controls {
    grid-template-columns: 82px minmax(0, 1fr) 82px;
  }
}
