:root {
  color-scheme: light;
  --ink: #173d2a;
  --ink-soft: #55715f;
  --leaf: #4e8d43;
  --leaf-deep: #2f6e38;
  --leaf-light: #90bd65;
  --bark: #8a6240;
  --paper: rgba(255, 255, 248, 0.78);
  --paper-strong: rgba(255, 255, 250, 0.94);
  --line: rgba(35, 83, 51, 0.16);
  --shadow: 0 18px 55px rgba(73, 92, 60, 0.13);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
}

body {
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 3%, rgba(255, 251, 189, 0.9), transparent 25rem),
    linear-gradient(180deg, #dff2f4 0%, #edf4df 58%, #e9e5c8 100%);
}

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

button {
  font: inherit;
}

a {
  color: inherit;
}

.garden {
  position: relative;
  min-height: 100svh;
}

.masthead {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(22px, 4vw, 52px) clamp(20px, 5vw, 72px) 0;
  pointer-events: none;
}

.title-block,
.header-tools,
.feed-tabs,
.refresh-button,
.growth-key,
.story-panel,
.footer {
  pointer-events: auto;
}

.series {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  max-width: 11ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 70px);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.93;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: clamp(13px, 1.4vw, 16px);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 3px;
}

.language-switch,
.live-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.text-button {
  appearance: none;
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  cursor: pointer;
}

.language-button {
  opacity: 0.45;
}

.language-button.is-active {
  color: var(--ink);
  opacity: 1;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #85a57c;
  box-shadow: 0 0 0 5px rgba(77, 139, 67, 0.08);
}

.live-dot.is-live {
  background: #58a246;
  animation: live-pulse 2.2s ease-in-out infinite;
}

.live-dot.is-error {
  background: #b86f4b;
  animation: none;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(77, 139, 67, 0.08); }
  50% { box-shadow: 0 0 0 8px rgba(77, 139, 67, 0.02); }
}

.garden-stage {
  position: relative;
  min-height: min(82svh, 900px);
  height: 82svh;
  overflow: hidden;
  isolation: isolate;
}

.garden-stage::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 42%),
    radial-gradient(ellipse at 48% 88%, rgba(116, 151, 80, 0.16), transparent 48%),
    linear-gradient(180deg, transparent 71%, rgba(214, 221, 176, 0.52) 100%);
}

.garden-stage::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: -5%;
  right: -5%;
  bottom: -6%;
  height: 29%;
  background:
    radial-gradient(ellipse at 12% 22%, rgba(71, 116, 58, 0.12), transparent 29%),
    radial-gradient(ellipse at 72% 18%, rgba(68, 116, 55, 0.1), transparent 33%),
    linear-gradient(180deg, rgba(227, 231, 192, 0.12), rgba(201, 210, 161, 0.8));
  filter: blur(0.2px);
}

.sunlight {
  position: absolute;
  z-index: 1;
  inset: -10% -8%;
  pointer-events: none;
  opacity: 0.68;
  background:
    radial-gradient(ellipse at 82% 12%, rgba(255,255,219,0.98) 0 4%, transparent 18%),
    radial-gradient(circle at 64% 18%, rgba(255,255,232,0.46) 0 3%, transparent 12%),
    radial-gradient(circle at 30% 36%, rgba(255,255,241,0.32) 0 2%, transparent 10%),
    linear-gradient(112deg, transparent 0 56%, rgba(255, 255, 229, 0.18) 59%, transparent 63%);
  animation: drift-light 15s ease-in-out infinite alternate;
}

@keyframes drift-light {
  from { transform: translate3d(-1.2%, -0.5%, 0) scale(1); }
  to { transform: translate3d(1.2%, 0.8%, 0) scale(1.02); }
}

#forest {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.feed-tabs {
  position: absolute;
  z-index: 5;
  top: clamp(104px, 13vh, 122px);
  right: clamp(145px, 13vw, 190px);
  left: auto;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 999px;
  background: rgba(255,255,248,0.54);
  box-shadow: 0 8px 30px rgba(67, 91, 57, 0.07);
  backdrop-filter: blur(12px);
}

.feed-button,
.refresh-button,
.error-card button {
  appearance: none;
  border: 0;
  cursor: pointer;
}

.feed-button {
  min-width: 58px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.feed-button.is-active {
  color: #fffef4;
  background: var(--ink);
}

.refresh-button {
  position: absolute;
  z-index: 5;
  top: clamp(104px, 13vh, 122px);
  right: clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255,255,248,0.54);
  box-shadow: 0 8px 30px rgba(67, 91, 57, 0.07);
  backdrop-filter: blur(12px);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.refresh-button span:first-child {
  font-size: 16px;
  line-height: 0;
}

.refresh-button.is-loading span:first-child {
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.growth-key {
  position: absolute;
  z-index: 5;
  left: clamp(20px, 5vw, 72px);
  bottom: clamp(45px, 7vh, 76px);
  width: min(620px, calc(100% - 40px));
  padding: 13px 16px 14px;
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 18px;
  background: rgba(255,255,248,0.62);
  box-shadow: 0 12px 36px rgba(65, 89, 55, 0.08);
  backdrop-filter: blur(12px);
}

.key-title {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.key-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.key-items span {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
}

.key-items i {
  grid-row: 1 / 3;
  justify-self: center;
}

.key-items b {
  font-size: 11px;
  font-weight: 800;
}

.key-items small {
  color: var(--ink-soft);
  font-size: 9px;
}

.key-line {
  display: block;
  width: 5px;
  height: 22px;
  border-radius: 99px;
  background: var(--bark);
  transform: rotate(12deg);
}

.key-line.branch {
  width: 3px;
  height: 18px;
  transform: rotate(48deg);
}

.key-fork {
  position: relative;
  width: 18px;
  height: 18px;
}

.key-fork::before,
.key-fork::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 1px;
  width: 3px;
  height: 18px;
  border-radius: 99px;
  background: var(--bark);
  transform-origin: bottom;
}

.key-fork::before { transform: rotate(-31deg); }
.key-fork::after { transform: rotate(31deg); }

.key-leaf {
  display: block;
  width: 17px;
  height: 11px;
  border-radius: 100% 0 100% 0;
  background: var(--leaf);
  transform: rotate(-15deg);
}

.stage-hint {
  position: absolute;
  z-index: 4;
  right: clamp(20px, 5vw, 72px);
  bottom: clamp(47px, 7vh, 78px);
  margin: 0;
  color: rgba(35, 67, 45, 0.65);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.loading {
  position: absolute;
  z-index: 7;
  top: 51%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  transform: translate(-50%, -50%);
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loading.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.seed {
  position: relative;
  display: block;
  width: 34px;
  height: 44px;
}

.seed::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 14px;
  height: 9px;
  border-radius: 50%;
  background: #8c6545;
}

.seed::after {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 16px;
  width: 2px;
  height: 21px;
  border-radius: 99px;
  background: var(--leaf-deep);
  transform-origin: bottom;
  animation: seed-grow 1.4s ease-in-out infinite alternate;
}

.seed i::before,
.seed i::after {
  content: "";
  position: absolute;
  bottom: 20px;
  width: 10px;
  height: 6px;
  border-radius: 100% 0 100% 0;
  background: var(--leaf);
  animation: leaf-open 1.4s ease-in-out infinite alternate;
}

.seed i::before { left: 8px; transform: rotate(18deg); }
.seed i::after { left: 17px; transform: scaleX(-1) rotate(18deg); }

@keyframes seed-grow { from { transform: scaleY(0.6); } to { transform: scaleY(1); } }
@keyframes leaf-open { from { opacity: 0.4; } to { opacity: 1; } }

.error-card {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100% - 40px));
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: 20px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  text-align: center;
}

.error-card p {
  margin: 0 0 14px;
  font-size: 13px;
}

.error-card button {
  padding: 9px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.story-panel {
  position: absolute;
  z-index: 10;
  top: clamp(190px, 24vh, 250px);
  right: clamp(20px, 5vw, 72px);
  width: min(340px, calc(100% - 40px));
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.86);
  border-radius: 22px;
  background: rgba(255, 255, 249, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.close-panel {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 21px;
}

.panel-kicker {
  margin: 0 34px 9px 0;
  color: var(--leaf-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.story-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.16;
}

.panel-meta {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
}

.story-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin: 16px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.story-metrics div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 11px;
  background: rgba(255,255,250,0.92);
}

.story-metrics span {
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.story-metrics strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
}

.comment-text {
  max-height: 180px;
  margin: 15px 0 0;
  overflow: auto;
  color: #294c36;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  line-height: 1.55;
}

.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
}

.panel-links a {
  color: var(--leaf-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.footer {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 18svh;
  padding: 24px clamp(20px, 5vw, 72px);
  border-top: 1px solid rgba(41, 77, 47, 0.08);
  color: var(--ink-soft);
  background: rgba(246, 245, 225, 0.72);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.footer p {
  margin: 0;
}

.footer a {
  text-underline-offset: 3px;
}

.back-link {
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 900px) {
  .garden-stage {
    height: 84svh;
    min-height: 650px;
  }

  .stage-hint {
    display: none;
  }

  .growth-key {
    width: calc(100% - 40px);
  }

  .story-panel {
    top: auto;
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 680px) {
  .masthead {
    gap: 12px;
    padding-top: 18px;
  }

  h1 {
    max-width: 9ch;
    font-size: clamp(34px, 11vw, 50px);
  }

  .subtitle {
    max-width: 22ch;
    margin-top: 8px;
    font-size: 12px;
  }

  .header-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
  }

  .garden-stage {
    height: 86svh;
    min-height: 620px;
  }

  .feed-tabs,
  .refresh-button {
    top: 154px;
  }

  .feed-tabs {
    right: auto;
    left: 16px;
  }

  .refresh-button {
    right: 16px;
    width: 37px;
    height: 37px;
    justify-content: center;
    padding: 0;
  }

  .refresh-button span:last-child {
    display: none;
  }

  .growth-key {
    left: 16px;
    bottom: 18px;
    width: calc(100% - 32px);
    padding: 11px 12px;
  }

  .key-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
  }

  .story-panel {
    left: 16px;
    right: 16px;
    bottom: 18px;
    width: auto;
    max-height: 53svh;
    overflow: auto;
  }

  .story-panel:not([hidden]) ~ .footer {
    visibility: hidden;
  }

  .footer {
    min-height: 14svh;
    padding: 17px 16px;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
}

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