/* Stitch guide (views/stitch-guide.js) — một bộ CSS cho mọi trang kỹ thuật + trang /stitches mới. Đi kèm charts.css (bảng cỡ len), dùng biến màu của site.css. */
.sg-page h1 { margin-bottom: 6px; }
.sg-h1-sub { display: block; font-size: .55em; font-weight: 700; color: var(--muted); margin-top: 4px; }
.sg-meta { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sg-meta li { background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 999px; padding: .25em .85em; font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.sg-meta li:first-child { background: var(--rose); color: var(--rose-ink); box-shadow: none; font-weight: 800; }
.sg-aka { margin: 10px 0 0; font-size: .88rem; color: var(--muted); }

.sg-ctrl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.sg-play { font-size: .92rem; }
@media (max-width: 640px) { .sg-play { width: 100%; } }

/* ===== KHUNG HÌNH CHUẨN 4:3: thanh trên (góc nhìn · trạng thái) + ảnh thật, chưa có thì hình vẽ giữ chỗ ===== */
.sg-fig { margin: 0; background: #fffdfa; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.sg-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px dashed var(--line); min-height: 42px; }
.sg-view { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sg-view::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--wc, var(--rose)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.sg-state { background: #2f3a2f; color: #fff; border-radius: 999px; padding: .28em .8em; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.sg-canvas { aspect-ratio: 4 / 3; }
.sg-canvas > svg, .sg-canvas > img { display: block; width: 100%; height: 100%; }
.sg-canvas > img, .sg-mini > img { object-fit: cover; }
.sg-mini > img { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; }
.sg-fig.sg-drag { outline: 3px dashed var(--rose-deep); outline-offset: 3px; }


/* Chú giải cách đọc hình */
.sg-legend { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 12px 16px; margin: 0 0 6px; }
.sg-legend summary { font-weight: 800; cursor: pointer; }
.sg-legend ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.sg-legend li { display: flex; gap: 10px; align-items: center; }
.lg-ic { flex: 0 0 72px; display: grid; place-items: center; background: #fffdfa; border: 1px solid var(--line); border-radius: 10px; height: 46px; }
.lg-ic svg { display: block; }
.sg-legend li b { display: block; font-size: .9rem; }
.sg-legend small { display: block; font-size: .8rem; color: var(--ink-2); line-height: 1.35; }
.sg-state-demo { font-size: .62rem; padding: .25em .55em; }

/* Dải các bước */
.sg-strip { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sg-strip a { position: relative; display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-sm); color: var(--ink); text-decoration: none; overflow: hidden; border-top: 4px solid var(--wc); height: 100%; }
.sg-strip a:hover, .sg-strip a:focus-visible { box-shadow: var(--shadow); transform: translateY(-1px); }
.sg-mini { display: block; background: #fffdfa; padding: 4px; }
.sg-mini text, .sg-mini .tag, .hub-fig text, .hub-fig .tag { display: none; }
.sg-mini-n { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--wc); display: grid; place-items: center; font-weight: 900; font-size: .8rem; box-shadow: 0 0 0 2px var(--surface); }
.sg-mini-t { padding: 6px 10px 9px; font-size: .84rem; font-weight: 800; line-height: 1.25; }
@media (max-width: 640px) { .sg-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }

/* Chuẩn bị */
.sg-need { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.sg-need li { display: flex; gap: 12px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 12px 14px; }
.sg-need .ic { font-size: 1.5rem; line-height: 1; width: 40px; height: 40px; border-radius: 12px; background: var(--tint); display: grid; place-items: center; flex: 0 0 auto; }
.sg-need p { margin: 2px 0 0; font-size: .9rem; color: var(--ink-2); }

/* ===== THẺ BƯỚC CHUẨN ===== */
.sg-step { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; margin: 18px 0; border-top: 6px solid var(--wc); scroll-margin-top: calc(var(--header-h) + 14px); }
.sg-step:target { outline: 3px solid var(--rose-deep); outline-offset: 3px; }
.sg-step-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.sg-step-head h3 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.sg-of { margin: 0; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sg-step-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 760px) { .sg-step-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.sg-step-txt > p:first-child { margin-top: 0; font-size: 1.04rem; }
.sg-check { display: flex; gap: 10px; background: color-mix(in srgb, var(--rose) 28%, transparent); border-radius: 12px; padding: 10px 12px; font-size: .94rem; }
.sg-check > span:first-child { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: var(--rose-deep); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: .8rem; margin-top: 2px; }
.sg-note { font-size: .92rem; border-radius: 12px; padding: 10px 12px; margin: 10px 0 0; }
.sg-note .nl { display: block; font-weight: 800; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.sg-note.tip { background: var(--tint-2); }
.sg-note.tip .nl { color: #9a5f08; }
.sg-note.slip { background: #fdecec; }
.sg-note.slip .nl { color: #b54131; }
@media (max-width: 640px) { .sg-step { padding: 14px; } .sg-step-head h3 { font-size: 1.15rem; } }

/* Len lông */
.sg-plush { background: linear-gradient(180deg, color-mix(in srgb, var(--rose) 30%, var(--surface)), var(--surface) 260px); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.sg-habits { list-style: none; padding: 0; margin: 14px 0; counter-reset: p; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sg-habits li { counter-increment: p; background: var(--surface); border-radius: 14px; padding: 12px 14px 12px 50px; position: relative; box-shadow: var(--shadow-sm); }
.sg-habits li::before { content: counter(p); position: absolute; left: 12px; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--rose); color: var(--rose-ink); display: grid; place-items: center; font-weight: 900; font-size: .85rem; }
.sg-habits b { display: block; }
.sg-habits span { font-size: .9rem; color: var(--ink-2); }
.sg-alt, .sg-chart { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: center; margin-top: 18px; }
@media (min-width: 760px) { .sg-alt, .sg-chart { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); } }
.sg-alt h3, .sg-chart h3 { margin: 0 0 6px; }
.sg-fig-chart .sg-bar { display: none; }

/* Sửa lỗi */
.sg-fix { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sg-fix > div { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 14px 16px; border-left: 4px solid #e0703e; }
.sg-fix h3 { margin: 0 0 4px; font-size: 1rem; font-family: var(--font); font-weight: 800; }
.sg-fix p { margin: 0; font-size: .9rem; color: var(--ink-2); }

/* Cách pattern viết */
.sg-pw { margin: 0; display: grid; gap: 8px; }
.sg-pw > div { display: grid; gap: 4px 16px; grid-template-columns: minmax(0, 1fr); background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm); }
@media (min-width: 640px) { .sg-pw > div { grid-template-columns: 240px minmax(0, 1fr); align-items: center; } }
.sg-pw code { font: 800 .92rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--tint); padding: .2em .5em; border-radius: 6px; }
.sg-pw dd { margin: 0; font-size: .92rem; color: var(--ink-2); }

/* Lộ trình người mới (cuối trang kỹ thuật) */
.sg-path { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); counter-reset: none; }
.sg-path li > a, .sg-path li > span { display: flex; flex-direction: column; gap: 2px; height: 100%; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 10px 12px; color: var(--ink); text-decoration: none; position: relative; }
.sg-path i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; background: var(--tint); display: grid; place-items: center; font-weight: 900; font-size: .8rem; margin-bottom: 4px; }
.sg-path b { font-size: .92rem; line-height: 1.25; }
.sg-path small { font-size: .8rem; color: var(--ink-2); }
.sg-path .cur a { outline: 3px solid var(--rose-deep); outline-offset: -3px; }
.sg-path .cur i { background: var(--rose-deep); color: #fff; }
.sg-path .soon > span { opacity: .62; box-shadow: none; border: 1px dashed var(--line); }
.sg-path em, .hub-cards em, .hub-path em { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sg-next { margin: 14px 0 0; font-size: .95rem; }
.soon-chip { display: inline-block; background: var(--tint); border-radius: 999px; padding: .1em .6em; font-size: .75rem; font-weight: 800; color: var(--muted); margin-left: 4px; }

/* ===== TRANG /stitches ===== */
.sg-hub { padding-bottom: 40px; }
.hub-path-sec { margin: 26px 0 8px; }
.hub-path { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 980px) { .hub-path { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 560px) { .hub-path { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hub-path li > a, .hub-path li > span { position: relative; display: flex; flex-direction: column; height: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-sm); overflow: hidden; color: var(--ink); text-decoration: none; padding-bottom: 10px; }
.hub-path a:hover { box-shadow: var(--shadow); }
.hub-path i { font-style: normal; position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--rose-deep); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: .82rem; }
.hub-path .soon i { background: var(--tint); color: var(--ink-2); }
.hub-path b, .hub-path small { display: block; }
.hub-path b { padding: 8px 10px 0; font-size: .92rem; line-height: 1.25; }
.hub-path small { padding: 2px 10px 0; font-size: .8rem; color: var(--ink-2); }
.hub-path .soon > span, .hub-cards .soon > span { box-shadow: none; border: 1px dashed var(--line); }
.hub-fig { display: block; background: #fffdfa; border-bottom: 1px solid var(--line); aspect-ratio: 360 / 280; }
.hub-fig svg { display: block; width: 100%; height: 100%; }
.hub-fig-soon { display: grid; place-items: center; font-size: 2rem; opacity: .35; background: var(--tint); }
.hub-group { margin-top: 30px; scroll-margin-top: calc(var(--header-h) + 14px); }
.hub-group h2 { margin: 0; }
.hub-group > p { margin: 4px 0 0; color: var(--ink-2); }
.hub-cards { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.hub-cards li > a, .hub-cards li > span { position: relative; display: flex; flex-direction: column; height: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-sm); overflow: hidden; color: var(--ink); text-decoration: none; }
.hub-cards a:hover { box-shadow: var(--shadow); }
.hub-cards .hub-t { padding: 8px 12px 10px; display: block; }
.hub-cards .hub-t b { display: block; font-size: .94rem; line-height: 1.25; }
.hub-cards .hub-t small { display: block; font-size: .8rem; color: var(--ink-2); margin-top: 2px; }
.hub-cards .soon > span, .hub-path .soon > span { opacity: .72; }

/* Làm theo từng bước */
.fa { border: 0; padding: 18px; border-radius: 24px; width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.fa::backdrop { background: rgba(30, 36, 30, .55); }
.fa-top { display: flex; justify-content: space-between; align-items: center; }
.fa-of { margin: 0; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fa h2 { margin: 2px 0 10px; font-size: clamp(1.2rem, 1rem + 1vw, 1.5rem); }
.fa-fig svg { max-height: 42dvh; }
.fa-txt { font-size: 1rem; margin-top: 10px; }
.fa-txt p { margin: 0 0 8px; }
.fa-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
.fa-dots { display: flex; gap: 6px; }
.fa-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.fa-dots i.on { background: var(--rose-deep); width: 20px; border-radius: 999px; }

.sg-nofig { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-size: .9rem; padding: 12px; text-align: center; }
.hub-fig > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sg-preview { position: sticky; top: 0; z-index: 60; background: #2f3a2f; color: #fff; text-align: center; padding: 8px 14px; font-weight: 800; font-size: .9rem; }
.sg-preview a { color: #ffd2dc; margin-left: 8px; }
