:root {
  color-scheme: light;
  --canvas: #f5f5f2;
  --surface: #ffffff;
  --surface-muted: #efefeb;
  --ink: #191a18;
  --muted: #72736e;
  --line: #deded8;
  --accent: #a63a34;
  --shadow: 0 10px 30px rgb(25 26 24 / 5%);
  --custom-background-image: none;
  --background-overlay-alpha: 0.530;
  --section-surface-alpha: 0.770;
  --current-card-alpha: 0.810;
  --next-card-alpha: 0.760;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  position: relative;
  isolation: isolate;
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  padding: max(28px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
}

body::before {
  background-image: var(--custom-background-image);
  background-position: center;
  background-size: cover;
  opacity: 0;
}

body::after {
  z-index: -1;
  background: rgb(18 20 18 / var(--background-overlay-alpha));
  opacity: 0;
}

html.has-custom-background body::before,
html.has-custom-background body::after {
  opacity: 1;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
}

.page-header {
  padding: 8px 2px 26px;
  border-bottom: 1px solid var(--line);
}

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

.background-toggle,
.background-panel button,
.background-select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 88%);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.background-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow);
}

.background-panel button:disabled {
  cursor: default;
  opacity: 0.45;
}

.background-visibility-control {
  display: grid;
  flex-basis: 100%;
  gap: 6px;
}

.background-visibility-control label {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.background-visibility-control input {
  width: 100%;
  accent-color: var(--accent);
}

.background-visibility-control input:disabled {
  cursor: default;
}

.background-visibility-hint {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.7rem;
}

.background-status {
  flex-basis: 100%;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.background-status[data-tone="error"] {
  color: #7f2925;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

html.has-custom-background .page-header,
html.has-custom-background .week-section {
  padding-right: 14px;
  padding-left: 14px;
  border-radius: 16px;
  background: rgb(245 245 242 / var(--section-surface-alpha));
  backdrop-filter: blur(12px);
}

html.has-custom-background .page-header {
  padding-top: 14px;
}

html.has-custom-background .week-section {
  padding-top: 16px;
  padding-bottom: 16px;
}

.eyebrow,
.next-refresh,
.period-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.eyebrow {
  color: var(--accent);
  font-weight: 650;
}

h1,
h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 700;
}

h1 {
  margin-top: 9px;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.next-refresh {
  margin-top: 12px;
}

.week-section {
  margin-top: 28px;
}

.week-section--current {
  position: relative;
}

.week-section--current::before {
  position: absolute;
  top: 1px;
  bottom: 0;
  left: -10px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

h2 {
  font-size: 1.22rem;
  letter-spacing: 0.01em;
}

.period-label {
  text-align: right;
}

.treasure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.treasure-card {
  display: flex;
  min-height: 68px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.96rem;
  font-weight: 610;
  line-height: 1.35;
}

html.has-custom-background .treasure-card {
  background: rgb(255 255 255 / var(--current-card-alpha));
}

.week-section--next .treasure-card {
  background: var(--surface-muted);
  box-shadow: none;
  color: #4d4e4a;
}

html.has-custom-background .week-section--next .treasure-card {
  background: rgb(239 239 235 / var(--next-card-alpha));
}

.error-message {
  margin: 28px 0 0;
  padding: 16px;
  border: 1px solid #dfb5b1;
  border-radius: 12px;
  background: #fff4f3;
  color: #7f2925;
  line-height: 1.6;
}

noscript {
  display: block;
  max-width: 720px;
  margin: 24px auto;
  color: #7f2925;
}

@media (max-width: 340px) {
  .treasure-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: block;
  }

  .period-label {
    margin-top: 4px;
    text-align: left;
  }
}

@media (min-width: 700px) {
  body {
    padding-top: 56px;
  }

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

  .week-section--current::before {
    left: -16px;
  }
}

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