/* hokkori — warm paper & ink. All colors are tokens; nothing hardcoded below :root. */
:root {
  --ink: #2a2522;        /* main: text, bar, primary */
  --paper: #f4ede2;      /* sub: page background */
  --card: #fbf7f0;       /* sub: card surface */
  --line: #e3d8c6;       /* sub: rules, borders */
  --muted: #6f655b;      /* sub: secondary text (4.9:1 on paper) */
  --accent: #a8431f;     /* accent: links, warm state (5.6:1 on card) */
  --ok: #4f6f4a;
  --warn: #9a6b1e;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Noto Serif", serif;
  --bar-h: 48px;
  --col: 480px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 16px/1.55 var(--serif); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button:not(:disabled), [role="button"]:not(:disabled), select, summary { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, button { font: inherit; color: inherit; }
input[type=text], select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* top bar */
.bar { position: fixed; top: 0; left: 0; right: 0; height: var(--bar-h); z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.bar-name { color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.bar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.bar-day { display: none; }
.bar-count { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-menu { width: 36px; height: 36px; border: 0; background: transparent; display: grid; place-items: center; gap: 5px; border-radius: 8px; }
.bar-menu span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; }
.bar-menu:hover { background: var(--line); }
.sheet { position: fixed; top: var(--bar-h); right: 10px; z-index: 21; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(42,37,34,.12); display: flex; flex-direction: column; min-width: 160px; overflow: hidden; }
.sheet[hidden] { display: none; }
.sheet a { padding: 12px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.sheet a:last-child { border-bottom: 0; }
.sheet a:hover { background: var(--paper); }

/* feed: full-height snapping cards */
.page-feed { overflow: hidden; }
.feed { height: 100dvh; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior-y: contain; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.card { position: relative; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; display: grid; grid-template-rows: minmax(0, 44%) minmax(0, 1fr); background: var(--card); border-bottom: 1px solid var(--line); }
.thumb { margin: 0; overflow: hidden; background: var(--line); padding-top: var(--bar-h); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.fallback { background: linear-gradient(160deg, hsl(var(--hue) 45% 88%), hsl(calc(var(--hue) + 40) 35% 78%)); }
.card .body { min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 16px 20px 20px; }
.meta { margin: 0; font-size: 13px; color: var(--muted); }
.meta .source { font-weight: 700; color: var(--ink); }
.meta .dot { padding: 0 2px; }
.card .title { margin: 0; font-size: clamp(20px, 5.6vw, 26px); line-height: 1.25; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .desc { margin: 0; color: var(--ink); opacity: .85; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.actions { margin-top: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 6px; }
.warm { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 14px; transition: transform .12s ease, background .2s, border-color .2s; }
.warm:hover { border-color: var(--accent); }
.warm:active { transform: scale(.96); }
.warm .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.warm-ico { width: 12px; height: 12px; border-radius: 50%; background: var(--line); box-shadow: inset 0 0 0 2px var(--card); transition: background .2s; }
.warm.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.warm.is-on .warm-ico { background: var(--accent); }
.warm.pop .warm-ico { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
.read { font-size: 14px; color: var(--accent); text-decoration: none; border: 0; background: none; padding: 8px 0; }
.read:hover { text-decoration: underline; }
.more { position: absolute; right: 8px; top: 50%; width: 36px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; opacity: .55; }
.card.end { grid-template-rows: 1fr; }
.card.end .body { justify-content: center; align-items: flex-start; padding-top: calc(var(--bar-h) + 24px); }
.card.end .title { font-size: clamp(22px, 6vw, 30px); }
.card.end .actions { margin-top: 18px; }

/* detail panel (right swipe / tap) */
.backdrop { position: fixed; inset: 0; background: rgba(42,37,34,.25); z-index: 30; }
.backdrop[hidden] { display: none; }
.detail { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--col), 100%); z-index: 31; background: var(--card); border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); overflow-y: auto; padding: 0 20px 32px; }
.detail.is-open { transform: translateX(0); }
.detail-close { position: sticky; top: 0; display: block; width: 100%; text-align: left; border: 0; background: var(--card); padding: 14px 0 10px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.detail-body .title { font-size: 24px; line-height: 1.25; margin: 6px 0 10px; }
.detail-body .desc { margin: 0 0 16px; }
.detail-body .actions { margin-top: 8px; }
.detail-body .share-row { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.detail-body .share-row button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; }
.toast.show { opacity: .95; transform: translate(-50%, 0); }

/* prose pages: about / 404 / 500 / style guide */
.prose { max-width: var(--col); margin: 0 auto; padding: calc(var(--bar-h) + 24px) 20px 48px; min-height: 100dvh; background: var(--card); }
.prose h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 14px; }
.prose h2 { font-size: 20px; margin: 26px 0 8px; }
.prose h3 { font-size: 17px; margin: 18px 0 6px; }
.prose p, .prose li { max-width: 68ch; }
.muted { color: var(--muted); }
.foot { margin: 32px -20px -48px; padding: 16px 20px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.swatch-box { height: 56px; border-radius: 8px; border: 1px solid var(--line); }
.swatch code { font-size: 12px; color: var(--muted); }
.card-sample { height: auto; min-height: 420px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card-sample .thumb { padding-top: 0; }

/* desktop: one phone-width column in the middle, same interaction */
@media (min-width: 720px) {
  .bar { width: var(--col); left: 50%; right: auto; margin-left: calc(var(--col) / -2); }
  .feed, .prose { width: var(--col); margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .bar-day { display: inline; }
  .detail { right: auto; left: 50%; width: var(--col); margin-left: calc(var(--col) / -2); transform: translateX(100vw); }
  .detail.is-open { transform: translateX(0); }
  .more { opacity: .35; }
}
@media (prefers-reduced-motion: reduce) { .detail, .warm, .toast { transition: none; } .warm.pop .warm-ico { animation: none; } }

.detail:focus { outline: none; }
