:root {
  --paper: #f4efe4; --paper-2: #ebe4d4; --ink: #24221d; --ink-2: #5d574b; --line: #d6cdb9;
  --moss: #4f7a3a; --amber: #c9821b; --focus: #1f5fbf;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #191814; --paper-2: #23211b; --ink: #ece6d8; --ink-2: #a8a091; --line: #3a362d; --moss: #8db56f; --amber: #e3a448; --focus: #7aa7ff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--ink-2); } .small { font-size: 13px; }

.bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 5; }
.mark { display: flex; gap: 8px; align-items: center; font: 600 17px var(--serif); text-decoration: none; }
.mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.btn { font: 600 15px var(--sans); border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 999px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.quiet { opacity: .7; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
textarea, input { width: 100%; font: 17px/1.45 var(--serif); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; resize: vertical; }
textarea:focus, input:focus { border-color: var(--ink-2); outline: none; }
input { font-family: var(--sans); font-size: 15px; flex: 1; min-width: 140px; }

/* home */
.plant, .forest, #mine { max-width: 760px; margin: 0 auto; padding: 22px 16px 6px; }
h1 { font: 600 clamp(28px, 6vw, 44px)/1.1 var(--serif); margin: 6px 0 10px; letter-spacing: -.01em; }
h1 span { color: var(--moss); }
h2 { font: 600 20px var(--serif); margin: 22px 0 10px; }
.sub { color: var(--ink-2); max-width: 36em; margin: 0 0 16px; }
.planter { border-top: 1px solid var(--line); padding-top: 14px; }
.outline { list-style: none; margin: 10px 0 0; padding: 0; }
.outline li { position: relative; margin: 0 0 8px; }
.outline li.d1 { margin-left: 18px; } .outline li.d2 { margin-left: 36px; } .outline li.d3 { margin-left: 54px; }
.outline li.d4 { margin-left: 66px; } .outline li.d5 { margin-left: 76px; } .outline li.d6 { margin-left: 84px; }
.outline li:not(.d0)::before { content: ""; position: absolute; left: -11px; top: -8px; bottom: 50%; border-left: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); width: 9px; border-bottom-left-radius: 8px; }
.ops { display: flex; gap: 14px; font-size: 14px; }
.hint { color: var(--ink-2); font-size: 14px; }

.canvas { position: relative; overflow: auto; overscroll-behavior: contain; }
.canvas svg { display: block; }
.canvas.small { height: 170px; background: var(--paper-2); border-radius: 10px; }
.canvas.mini { width: 72px; height: 56px; flex: none; overflow: hidden; }

.stems path { fill: none; stroke: var(--ink); stroke-linecap: round; opacity: .8; }
.stems path.reader { stroke: var(--moss); }
.stems path.on { opacity: 1; }
.stems .trunk { opacity: 1; }
.dot { cursor: pointer; }
.dot .hit { fill: transparent; }
.dot .core { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.dot.reader .core { stroke: var(--moss); }
.dot.read .core { fill: var(--ink); }
.dot.reader.read .core { fill: var(--moss); }
.dot.fresh .core { fill: var(--amber); stroke: var(--amber); }
.dot.cur .core { stroke-width: 3; fill: var(--paper); }
.dot.cur.fresh .core { fill: var(--amber); }
.lbl { font: 12.5px var(--sans); fill: var(--ink-2); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.lbl.cur { font-weight: 600; fill: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .canvas.big .intro .stems path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: grow .7s ease-out forwards; }
  .canvas.big .intro .stems .trunk { stroke-dasharray: none; animation: none; }
  @keyframes grow { to { stroke-dashoffset: 0; } }
}

.feed { display: grid; gap: 4px; }
.tree-card { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.tree-card strong { font: 600 17px/1.3 var(--serif); display: block; }
.tree-card .meta { color: var(--ink-2); font-size: 13px; }
.tag, .new { font-size: 12px; font-weight: 600; margin-right: 6px; }
.tag { color: var(--ink-2); }
.new { color: var(--amber); }

/* tree page: map on top (phone), side by side (desktop) */
.reader { display: grid; grid-template-rows: 46vh auto; }
.canvas.big { height: 46vh; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.legend { position: sticky; left: 8px; bottom: 8px; display: inline-flex; gap: 12px; font-size: 12px; color: var(--ink-2); background: color-mix(in srgb, var(--paper-2) 85%, transparent); padding: 3px 8px; border-radius: 6px; margin: -30px 0 0 8px; }
.legend .link { font-size: 12px; padding: 0; color: var(--amber); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; border: 2px solid var(--ink); }
.legend i.r { border-color: var(--moss); } .legend i.f { background: var(--amber); border-color: var(--amber); }
.panel { padding: 14px 16px 40px; max-width: 680px; }
.crumbs { font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs b { font-weight: 400; opacity: .6; }
.crumbs .link { padding: 0; }
.thought { margin: 10px 0 14px; }
.thought p { font: 21px/1.5 var(--serif); margin: 0 0 8px; overflow-wrap: anywhere; }
.thought footer { font-size: 13px; color: var(--ink-2); }
.thought.by-reader { border-left: 3px solid var(--moss); padding-left: 12px; }
h3 { font: 600 13px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 18px 0 6px; }
.kids { list-style: none; margin: 0; padding: 0; }
.kids button { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 11px 0 11px 18px; font: 17px/1.4 var(--serif); color: var(--ink); cursor: pointer; position: relative; }
.kids button::before { content: "↑"; position: absolute; left: 0; color: var(--ink-2); font-family: var(--sans); }
.kids button.by-reader::before { color: var(--moss); }
.kids button.read { color: var(--ink-2); }
.kids em { display: block; font: 13px var(--sans); color: var(--moss); font-style: normal; }
.end { color: var(--ink-2); font-style: italic; font-family: var(--serif); }
.grow { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.grow label { display: block; font-weight: 600; margin-bottom: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 18px; font-size: 14px; }
@media (min-width: 900px) {
  .reader { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) 460px; height: calc(100vh - 53px); }
  .canvas.big { height: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .panel { overflow: auto; padding: 22px 26px 40px; }
}

.ssr { max-width: 680px; margin: 0 auto; padding: 16px; font-family: var(--serif); }
.gone { max-width: 600px; margin: 60px auto; padding: 16px; }
.sheet { position: fixed; inset: auto 0 0 0; background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0,0,0,.12); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); z-index: 20; }
.sheet > div { max-width: 640px; margin: 0 auto; }
.sheet h2 { margin-top: 0; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; }
#toast.on { opacity: 1; }
