@font-face {
  font-family: "MFShangYa";
  src: url("../font/MFShangYa.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "HYTiaoTiao";
  src: url("../font/HYTiaoTiao.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #25211d;
  --muted: #776d63;
  --paper: #fffdf8;
  --canvas: #f6eee3;
  --accent: #e65f45;
  --accent-dark: #b93c2b;
  --highlight: #ffd978;
  --line: rgba(65, 51, 41, 0.16);
  --shadow: 0 22px 70px rgba(74, 50, 31, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 8%, rgba(230, 95, 69, 0.1), transparent 28rem),
    radial-gradient(circle at 88% 92%, rgba(255, 201, 92, 0.16), transparent 25rem),
    var(--canvas);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100% - 32px, 780px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 17px 12px 16px 10px;
  background: #fff;
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-2deg);
}

.brand-logo img {
  width: 44px;
  height: 44px;
  object-fit: cover;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-family: "MFShangYa", "PingFang SC", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
}

.brand-copy small,
.issue {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.issue {
  white-space: nowrap;
}

.diary {
  position: relative;
  align-self: center;
  min-height: min(58vh, 510px);
  padding: clamp(24px, 6vw, 48px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px 22px 10px 18px;
  background:
    linear-gradient(90deg, transparent 31px, rgba(230, 95, 69, 0.12) 32px, transparent 33px),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(58, 44, 34, 0.055) 32px),
    var(--paper);
  box-shadow: var(--shadow);
}

.diary::before {
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  border: 1px solid rgba(84, 65, 51, 0.09);
  border-radius: 5px 16px 6px 13px;
}

.diary-topline,
.diary-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.diary-topline p {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.diary-topline b {
  color: var(--ink);
  font-size: 1rem;
}

.quote {
  position: relative;
  z-index: 1;
  align-self: center;
  margin: 0;
  font-family: "HYTiaoTiao", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.35rem, 4.5vw, 2rem);
  line-height: 1.75;
  letter-spacing: 0.045em;
  text-align: justify;
  text-wrap: pretty;
}

.quote mark {
  color: inherit;
  background: linear-gradient(transparent 62%, var(--highlight) 62%, var(--highlight) 92%, transparent 92%);
}

.quote.is-changing {
  animation: quote-in 340ms ease-out both;
}

.diary-footer {
  align-items: flex-end;
  letter-spacing: 0.03em;
}

.stamp {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  transform: rotate(-7deg);
}

.actions {
  display: grid;
  justify-items: center;
}

.refresh-button {
  min-height: 52px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 4px 5px 0 var(--ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.refresh-button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 5px 7px 0 var(--ink);
}

.refresh-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 2px 0 var(--ink);
}

.refresh-button:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 4px;
}

.refresh-icon {
  font-size: 1.45rem;
  line-height: 1;
}

@keyframes quote-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 24px, 780px);
    gap: 18px;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px 10px 14px 9px;
  }

  .brand-logo img {
    width: 40px;
    height: 40px;
  }

  .brand-copy small {
    display: none;
  }

  .diary {
    min-height: 60vh;
    padding: 25px 24px 22px 42px;
    gap: 18px;
  }

  .diary-footer > span:first-child {
    max-width: 75%;
  }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #f4ecdf;
    --muted: #b7aa9c;
    --paper: #24211e;
    --canvas: #171513;
    --accent: #e56c56;
    --accent-dark: #f18470;
    --highlight: rgba(233, 171, 70, 0.58);
    --line: rgba(255, 244, 230, 0.13);
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  }

  .brand-logo {
    background: #fff7ed;
    border-color: #f4ecdf;
    box-shadow: 4px 4px 0 #f4ecdf;
  }

  .diary {
    background:
      linear-gradient(90deg, transparent 31px, rgba(229, 108, 86, 0.16) 32px, transparent 33px),
      repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(255, 255, 255, 0.045) 32px),
      var(--paper);
  }

  .refresh-button {
    border-color: #f4ecdf;
    box-shadow: 4px 5px 0 #f4ecdf;
  }
}
