/* Over the Fence - an autumn garden: cream paper, rust and ochre leaves, a weathered timber fence, moss lawns. */
:root {
  --bg: #f6f0e4; --paper: #fffaf0; --ink: #2f2418; --muted: #6e5f4c; --line: #dccdb2;
  --rust: #a8461f; --rust-ink: #ffffff; --ochre: #b7831f; --moss: #4f6a33; --lawn: #e7ecd3; --lawn2: #dde5c4;
  --wood: #c9a678; --wood-dk: #8a6a44; --rail: #a9875c; --gate: #d7b98c;
  --common: #3f6b2a; --common-bg: #e3efd6; --trade: #8a5a0b; --trade-bg: #f8ead0; --stuck: #8c2f1c; --stuck-bg: #f6ddd5; --open: #6e5f4c; --open-bg: #efe7d8;
  --note-bg: #fff6d9; --note-line: #e8d79f; --focus: #1f5fa8; --shadow: 0 1px 2px rgba(60, 40, 20, 0.08), 0 6px 18px rgba(60, 40, 20, 0.06);
  --warn: #8c2f1c; --info: #5b4a2d; --safety-bg: #fbe3dc; --safety-ink: #7a2412;
}
:root[data-theme="dark"] {
  --bg: #17140f; --paper: #221d16; --ink: #f1e8d8; --muted: #b7a88f; --line: #3d3427;
  --rust: #e07a4c; --rust-ink: #1b120b; --ochre: #e0b252; --moss: #a9c47e; --lawn: #1f2618; --lawn2: #263020;
  --wood: #8f7350; --wood-dk: #5c4630; --rail: #7a5f40; --gate: #a88a60;
  --common: #a9d48a; --common-bg: #22331a; --trade: #f0c46a; --trade-bg: #3a2c12; --stuck: #f3a08a; --stuck-bg: #3d1f17; --open: #c9b89c; --open-bg: #2c261d;
  --note-bg: #2e2818; --note-line: #4d4226; --focus: #8fb8ff; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.3);
  --warn: #f3a08a; --info: #d8c8a8; --safety-bg: #3d1f17; --safety-ink: #ffc8b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.55 Georgia, "Iowan Old Style", "Palatino Linotype", serif; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.small { font-size: 0.86rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
a { color: var(--rust); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Header */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.back { text-decoration: none; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.brand strong { font-size: 1.05rem; letter-spacing: 0.01em; white-space: nowrap; }
.logo { width: 28px; height: 28px; flex: none; }
.lg-pk { fill: var(--wood); stroke: var(--wood-dk); stroke-width: 1; }
.lg-rail { fill: var(--rail); }
.session { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer; text-decoration: none; font-size: 0.9rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.2; }
.pill:hover { border-color: var(--rust); }
.pill.solid { background: var(--rust); color: var(--rust-ink); border-color: var(--rust); }
.pill.solid:hover { filter: brightness(1.06); }
.pill.ghost { cursor: default; background: transparent; }
.pill.big { padding: 10px 22px; font-size: 1rem; }
.pill.tiny { padding: 3px 10px; font-size: 0.8rem; }
.pill:disabled { opacity: 0.5; cursor: not-allowed; }

/* Layout */
main { max-width: 1040px; margin: 0 auto; padding: 16px; }
.hero { padding: 18px 4px 8px; }
.kicker { display: inline-block; margin: 0 0 10px; font: 0.86rem/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--muted); border-left: 4px solid var(--ochre); padding: 2px 0 2px 10px; }
h1 { font-size: clamp(1.7rem, 4.6vw, 2.6rem); line-height: 1.12; margin: 4px 0 10px; letter-spacing: -0.01em; overflow-wrap: break-word; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.lede { font-size: 1.06rem; max-width: 70ch; margin: 0 0 12px; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { border: 1px dashed var(--wood-dk); background: var(--paper); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: 0.88rem system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
.chip.on { border-style: solid; background: var(--trade-bg); border-color: var(--ochre); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 16px 0; box-shadow: var(--shadow); }
.ph { display: flex; align-items: center; gap: 10px; }
.step-no { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ochre); color: #1b120b; font: 700 0.95rem system-ui, sans-serif; flex: none; }
.lbl { display: block; font: 600 0.88rem system-ui, -apple-system, "Segoe UI", sans-serif; margin: 10px 0 4px; }
textarea, input[type="text"], select { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 9px 11px; }
textarea { resize: vertical; min-height: 64px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 0.95rem; }
.check input { margin-top: 5px; }
.safety { background: var(--safety-bg); color: var(--safety-ink); border-radius: 10px; padding: 10px 12px; margin: 10px 0 0; }
.note { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 10px; padding: 8px 12px; }

/* Verdict badge and tally */
.verdict-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.badge { display: inline-block; border-radius: 6px; padding: 4px 10px; font: 700 0.82rem system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: 0.02em; background: var(--open-bg); color: var(--open); border: 1px solid currentColor; white-space: nowrap; }
.badge.v-knock { background: var(--common-bg); color: var(--common); }
.badge.v-note { background: var(--trade-bg); color: var(--trade); }
.badge.v-mediator { background: var(--stuck-bg); color: var(--stuck); }
.tally { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 14px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; min-width: 0; }
.tile b { font-size: 1.15rem; overflow-wrap: anywhere; }

/* The fence */
.fence-head { display: grid; grid-template-columns: 1fr 150px 1fr; gap: 0; font: 700 0.78rem system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.fence-head span:first-child { padding-left: 12px; }
.fence-head span:last-child { text-align: right; padding-right: 12px; }
.fence-host { border-radius: 12px; overflow: hidden; }
.fence { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 1fr 150px 1fr; align-items: stretch; position: relative; }
.row + .row { border-top: 1px dashed var(--line); }
.yard { padding: 12px; min-width: 0; }
.yard.you { background: linear-gradient(90deg, var(--lawn2), var(--lawn)); }
.yard.them { background: linear-gradient(270deg, var(--lawn2), var(--lawn)); }
.leafcard { background: var(--paper); border-radius: 4px 18px 4px 18px; padding: 8px 12px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.yard.them .leafcard { border-radius: 18px 4px 18px 4px; }
.y-lbl { display: block; font: 700 0.72rem system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.y-pos, .y-need { margin: 2px 0 6px; font-size: 0.93rem; overflow-wrap: break-word; }
.y-need { margin-bottom: 0; }
.y-empty { margin: 0; padding: 10px 0; }
.post { background: repeating-linear-gradient(0deg, var(--lawn) 0 14px, var(--lawn2) 14px 28px); display: flex; flex-direction: column; align-items: center; padding: 10px 6px; text-align: center; gap: 2px; }
.panel-ic { width: 76px; height: 95px; }
.p-no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--paper); font: 700 0.85rem system-ui, sans-serif; }
.p-title { font: 700 0.84rem/1.25 system-ui, -apple-system, "Segoe UI", sans-serif; overflow-wrap: break-word; max-width: 100%; }
.p-status { font: 700 0.72rem system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.06em; border-radius: 4px; padding: 1px 6px; }
.row.st-common .p-status { background: var(--common-bg); color: var(--common); }
.row.st-trade .p-status { background: var(--trade-bg); color: var(--trade); }
.row.st-stuck .p-status { background: var(--stuck-bg); color: var(--stuck); }
.row.st-open .p-status { background: var(--open-bg); color: var(--open); }
.why { grid-column: 1 / -1; margin: 0; padding: 6px 12px 10px; background: var(--bg); color: var(--muted); }
/* Panel pictures */
.pk { fill: var(--wood); stroke: var(--wood-dk); stroke-width: 1.5; }
.rail { fill: var(--rail); }
.gatep { fill: var(--gate); stroke: var(--wood-dk); stroke-width: 2; }
.hinge { fill: var(--ink); }
.leafmark { fill: var(--rust); stroke: var(--rust); stroke-width: 1.5; }
.tag { fill: var(--trade-bg); stroke: var(--trade); stroke-width: 2.5; }
.swap { fill: none; stroke: var(--trade); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.board { fill: var(--wood-dk); stroke: var(--ink); stroke-width: 1.5; }
.seam { stroke: var(--ink); stroke-opacity: 0.35; stroke-width: 1.5; }
.brace { stroke: var(--wood); stroke-width: 5; stroke-linecap: round; }
.lock { fill: none; stroke: var(--stuck); stroke-width: 3.5; }
.lockbody { fill: var(--stuck); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-ic { width: 22px; height: 28px; flex: none; }
.mini-ic { width: 30px; height: 38px; flex: none; }
.heat { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.heat li { background: var(--bg); border-left: 4px solid var(--ochre); border-radius: 6px; padding: 6px 10px; }
.heat li.k-escalation, .heat li.k-label { border-left-color: var(--rust); }
.heat li.none { border-left-color: var(--moss); }
.flash { padding-left: 18px; margin: 0 0 8px; }
.flash li { margin: 4px 0; }
.sub { margin-top: 20px; }

/* Ask, progress */
.runrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }
.gate { margin: 10px 0 0; }
p.gate { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 10px; padding: 8px 12px; }
.steps { list-style: none; padding: 0; margin: 0; }
.step { padding: 3px 0; color: var(--muted); font: 0.92rem system-ui, sans-serif; }
.step.done { color: var(--common); }
.step.active { color: var(--ink); font-weight: 700; }
.step-ic { display: inline-block; width: 1.2em; font-family: ui-monospace, Menlo, monospace; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); padding: 10px; border-radius: 8px; max-height: 360px; overflow: auto; font-size: 0.82rem; }

/* The reply */
.res-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.res-head h2 { margin: 0; overflow-wrap: break-word; min-width: 0; }
.summary { font-size: 1.04rem; }
.opener { position: relative; background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 6px; padding: 22px 18px 14px; margin: 18px 0; background-image: repeating-linear-gradient(180deg, transparent 0 27px, var(--note-line) 27px 28px); transform: rotate(-0.4deg); }
.opener h3 { margin-top: 0; }
.pin { position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; margin: 0 0 0 -9px; border-radius: 50%; background: var(--rust); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3); }
.opener-text { white-space: pre-wrap; font-size: 1.02rem; line-height: 28px; margin: 0 0 12px; }
.plain { padding-left: 20px; margin: 0; }
.plain li { margin: 4px 0; }
.trades { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: tr; }
.trade-card { background: var(--bg); border: 1px solid var(--line); border-left: 5px solid var(--ochre); border-radius: 10px; padding: 10px 14px; counter-increment: tr; }
.t-idea { margin: 0 0 6px; font-weight: 700; }
.t-idea::before { content: counter(tr) ". "; color: var(--trade); }
.t-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-two p { margin: 0; }
.t-tags { margin: 6px 0 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fb { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px 10px; }
.recon { list-style: none; padding: 0; margin: 0; }
.recon li { padding: 6px 10px; border-radius: 8px; margin: 4px 0; background: var(--bg); font-size: 0.92rem; }
.recon li.warn { background: var(--stuck-bg); color: var(--warn); }
.recon li.info { color: var(--info); }
li.none { color: var(--muted); font-style: italic; list-style: none; }
.exports, .cardrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Saved maps */
.saved { list-style: none; padding: 0; margin: 12px 0 0; }
.hrow { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.hinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hinfo b { overflow-wrap: anywhere; }
.hbtns { display: flex; gap: 6px; flex-wrap: wrap; }

.foot { max-width: 1040px; margin: 0 auto; padding: 12px 16px 40px; color: var(--muted); font-size: 0.86rem; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(92vw, 460px); }
.toast { background: var(--ink); color: var(--paper); border-radius: 10px; padding: 10px 14px; font: 0.9rem system-ui, sans-serif; box-shadow: var(--shadow); transition: opacity 0.5s; }
.toast.err { background: var(--stuck); color: var(--paper); }
:root[data-theme="dark"] .toast.err { color: #1b120b; }
.toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }

/* Phone: the panel sits on the left, both sides stack beside it. */
@media (max-width: 680px) {
  .two, .cols, .t-two { grid-template-columns: 1fr; }
  .tally { grid-template-columns: 1fr 1fr; }
  .fence-head { display: none; }
  .row { grid-template-columns: 92px minmax(0, 1fr); grid-template-areas: "post you" "post them" "why why"; }
  .row .yard.you { grid-area: you; padding-bottom: 4px; }
  .row .yard.them { grid-area: them; padding-top: 4px; background: var(--lawn); }
  .row .post { grid-area: post; padding: 10px 4px; }
  .row .why { grid-area: why; }
  .panel-ic { width: 60px; height: 75px; }
  .yard.you .leafcard::before, .yard.them .leafcard::before { display: block; font: 700 0.7rem system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; color: var(--moss); margin-bottom: 2px; }
  .yard.you .leafcard::before { content: "Your side"; }
  .yard.them .leafcard::before { content: "Your neighbour's side"; }
  .panel { padding: 14px; }
  .bar { padding: 8px 12px; }
  .back-t { display: none; }
}
@media print {
  .bar, .samples, .askbox, .histbox, .exports, .cardrow, .toasts, .tellbox, .standbox { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { box-shadow: none; break-inside: avoid; }
}
