/* Cord Calc 视觉：手作桌面。
   受众是手机上的手绳玩家（青少年、年轻女性，Eras 交换手绳文化）和文艺手作人群 →
   米色亚麻底 + 糖果色绣线、圆润的 Fredoka 标题、真实"打结"手链做签名元素（页头和实时预览）。
   字体自托管在 /fonts（OFL），不依赖第三方 CDN。 */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }

:root {
	--bg: #fbf4ea;
	--paper: #fffcf7;
	--ink: #3b2a33;
	--muted: #7d6a70;
	--line: #efe2d2;
	--coral: #ff6f91;
	--mango: #ffb347;
	--butter: #ffe07a;
	--mint: #5fd0b0;
	--sky: #6ec3f4;
	--lilac: #b48cf2;
	--radius: 22px;
	--shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 14px 34px -16px rgba(120, 70, 60, 0.35);
	--display: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; color: var(--ink); background-color: var(--bg);
	/* 亚麻布纹：两层极淡的横竖细线 */
	background-image:
		repeating-linear-gradient(0deg, rgba(150, 110, 80, 0.045) 0 1px, transparent 1px 4px),
		repeating-linear-gradient(90deg, rgba(150, 110, 80, 0.035) 0 1px, transparent 1px 5px);
	font: 17px/1.65 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: #d63f6c; text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: #a92a52; }
h1, h2, h3, .brand, .big, .step-n { font-family: var(--display); }

/* 页头：品牌 + 一条横贯的打结手链（SVG 由 build 注入 #band） */
.top { max-width: 1040px; margin: 0 auto; padding: 1rem 1.25rem 0; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.35rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 0.55rem; }
.brand svg { width: 34px; height: 34px; filter: drop-shadow(0 3px 4px rgba(120, 70, 60, 0.25)); }
.top nav { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; padding: 0.4rem 0.85rem; border-radius: 999px; font-weight: 700; font-size: 0.95rem; }
.top nav a:hover, .top nav a[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: 0 0 0 1.5px var(--line); }
.band { display: block; width: 100%; height: 26px; object-fit: cover; object-position: left; margin-top: 0.8rem; flex-basis: 100%; }

main { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem 3rem; }
article > h1 { font-size: clamp(2rem, 5.2vw, 3.2rem); line-height: 1.08; letter-spacing: -0.01em; margin: 1.6rem 0 0.7rem; max-width: 20ch; }
/* 标题里 <em> 当荧光笔：手绘感的下划波浪 */
article > h1 em { font-style: normal; background: linear-gradient(transparent 62%, rgba(255, 179, 71, 0.55) 62% 92%, transparent 92%); padding: 0 0.1em; }
article > h1 + p { font-size: 1.15rem; color: var(--muted); max-width: 44rem; }
article h2 { font-size: 1.65rem; margin: 2.8rem 0 0.6rem; }
article h3 { font-size: 1.18rem; margin: 1.7rem 0 0.3rem; }
article p, article li, article table { max-width: 46rem; }
article ul li::marker { color: var(--coral); }
table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--paper); border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 1.5px var(--line); font-size: 0.95rem; }
th, td { padding: 0.6rem 0.85rem; text-align: left; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { background: #fbeee0; font-family: var(--display); font-weight: 600; }
code { background: #f6e9da; padding: 0.1em 0.35em; border-radius: 6px; font-size: 0.9em; }
blockquote { margin: 1.2rem 0; padding: 0.8rem 1.1rem; background: #fff3d9; border-radius: 14px; border-left: 5px solid var(--mango); max-width: 46rem; }
blockquote p { margin: 0.2rem 0; }
.updated { color: var(--muted); font-size: 0.88rem; margin-top: 3rem; }

/* 折叠：FAQ 与公式细节，默认收起，正文不被长文撑满 */
details { max-width: 46rem; background: var(--paper); border-radius: 14px; box-shadow: 0 0 0 1.5px var(--line); margin: 0.6rem 0; }
details > summary { cursor: pointer; list-style: none; padding: 0.8rem 2.6rem 0.8rem 1rem; font-family: var(--display); font-weight: 600; font-size: 1.05rem; position: relative; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; background: #fbeee0; font-size: 1.1rem; }
details[open] > summary::after { content: "–"; background: var(--butter); }
details > :not(summary) { margin: 0 1rem 0.9rem; }

/* 工具：三步卡片 + 粘性结果卡 */
.tool { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.2rem; margin: 1.6rem 0 2.4rem; align-items: start; }
@media (max-width: 820px) { .tool { grid-template-columns: 1fr; } }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1.5px var(--line); padding: 1.25rem 1.3rem; }
.steps { display: grid; gap: 1rem; }
.step-h { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.8rem; font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.step-n { width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1rem; flex: none; }
.s1 .step-n { background: var(--coral); }
.s2 .step-n { background: var(--mint); }
.s3 .step-n { background: var(--lilac); }
.row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: end; margin-bottom: 0.8rem; }
.row > label { flex: 1 1 8.5rem; }
.lbl { font-weight: 800; font-size: 0.88rem; display: block; margin-bottom: 0.3rem; }
input[type="number"], select {
	width: 100%; font: inherit; font-weight: 700; padding: 0.62rem 0.8rem; min-height: 46px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--coral); box-shadow: 0 0 0 4px rgba(255, 111, 145, 0.18); }
.seg { display: inline-flex; background: #f6e9da; border-radius: 999px; padding: 4px; gap: 2px; }
.seg label { cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0.42rem 0.95rem; border-radius: 999px; font-weight: 800; font-size: 0.92rem; color: var(--muted); }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(120, 70, 60, 0.18); }
.seg input:focus-visible + span { outline: 3px solid var(--coral); }
.hint { color: var(--muted); font-size: 0.86rem; margin: 0.3rem 0 0; }

/* 每根线 = 一小捆绣线（色块带腰封），旁边是用量条 */
.strings { display: grid; gap: 0.5rem; }
.string-row { display: grid; grid-template-columns: 2.6rem 1fr 6rem; gap: 0.6rem; align-items: center; }
.skein { position: relative; width: 2.6rem; height: 2.1rem; border-radius: 10px; background: currentColor; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12), inset 0 0 0 1px rgba(0, 0, 0, 0.08); overflow: hidden; cursor: pointer; }
.skein::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.22) 0 2px, transparent 2px 5px); }
.skein::after { content: ""; position: absolute; left: 38%; width: 24%; top: 0; bottom: 0; background: #fffaf0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06); }
.skein input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.bar { height: 12px; border-radius: 999px; background: currentColor; transform-origin: left; transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12); }
.string-row input[type="number"] { min-height: 40px; padding: 0.4rem 0.6rem; }
.string-row .role { font-weight: 800; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.result { position: sticky; top: 1rem; background: linear-gradient(165deg, #fff9f0 0%, #ffeef3 100%); }
.result .eyebrow { font-weight: 800; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.result .big { font-size: clamp(2.4rem, 7vw, 3.3rem); font-weight: 700; line-height: 1.05; margin: 0.15rem 0 0.2rem; }
.result .big small { font-size: 0.42em; font-weight: 600; color: var(--muted); }
.result table { font-size: 0.92rem; margin-top: 0.8rem; background: rgba(255, 255, 255, 0.7); }
.result td, .result th { padding: 0.4rem 0.6rem; }
.swatch { display: inline-block; width: 0.95rem; height: 0.95rem; border-radius: 4px; vertical-align: -2px; margin-right: 0.4rem; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.preview { display: block; width: 100%; height: auto; margin: 0.8rem 0 0.2rem; filter: drop-shadow(0 6px 8px rgba(120, 70, 60, 0.22)); }
.note { background: #fff; border-radius: 12px; padding: 0.55rem 0.75rem; font-size: 0.88rem; margin-top: 0.7rem; box-shadow: 0 0 0 1.5px var(--line); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; }
button { font: inherit; font-weight: 800; border: 0; border-radius: 999px; padding: 0.6rem 1.1rem; min-height: 44px; cursor: pointer; background: var(--ink); color: #fff; }
button.ghost { background: #fff; color: var(--ink); box-shadow: 0 0 0 2px var(--line); }
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px); }
.noscript { background: #fff3cd; padding: 0.8rem 1rem; border-radius: 12px; }

/* 手机端常驻结果栏：表单在上、结果卡在下，滚动中也要随时看到"剪多长"；结果卡进入视口时隐藏 */
.mbar { display: none; }
@media (max-width: 820px) {
	.mbar:not([hidden]) { display: flex; position: fixed; left: 0.75rem; right: 0.75rem; bottom: calc(0.75rem + env(safe-area-inset-bottom)); z-index: 20;
		align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.7rem 0.9rem 0.7rem 1.1rem; border-radius: 20px;
		background: var(--ink); color: #fff; text-decoration: none; box-shadow: 0 14px 30px -10px rgba(59, 42, 51, 0.55); }
	.mbar .eyebrow { display: block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.7; }
	.mbar b { font-family: var(--display); font-size: 1.45rem; font-weight: 700; }
	.mbar .go { background: var(--butter); color: var(--ink); font-weight: 800; font-size: 0.9rem; padding: 0.5rem 0.85rem; border-radius: 999px; white-space: nowrap; }
	main { padding-bottom: 6rem; }
	.result { position: static; scroll-margin-top: 1rem; }
	article > h1 { margin-top: 1.1rem; }
	article > h1 + p { font-size: 1.02rem; }
	article > table { display: block; overflow-x: auto; white-space: nowrap; font-size: 0.86rem; -webkit-overflow-scrolling: touch; }
	article > table th, article > table td { padding: 0.5rem 0.65rem; }
}

/* 广告位：先占固定高度，后上 AdSense 也不挤动布局（CLS） */
.ad-slot { min-height: 120px; margin: 2rem 0; }
.ad-slot:empty { display: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem; margin: 1rem 0; max-width: 46rem; }
.cards a { display: block; padding: 1rem 1.1rem; background: var(--paper); border-radius: 16px; box-shadow: 0 0 0 1.5px var(--line); text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.cards a span { display: block; font-family: "Nunito", sans-serif; font-weight: 400; color: var(--muted); font-size: 0.9rem; }
.cards a:hover { box-shadow: 0 0 0 2px var(--coral); }

footer { max-width: 1040px; margin: 0 auto; padding: 2rem 1.25rem 3rem; color: var(--muted); font-size: 0.88rem; }
footer .band { margin: 0 0 1.2rem; opacity: 0.85; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
	.top, footer, .ad-slot, .actions, .steps, article > :not(.tool) { display: none !important; }
	.tool { display: block; }
	.result { position: static; box-shadow: none; background: none; }
}
