:root { font-family: system-ui, sans-serif; color: #172d3e; background: #f3f6fa; font-size: 16px; }
canvas#graphic { image-rendering: pixelated; }
.chart .a td,.chart .b td { background: #fff; color: #172d3e; }
.chart .a th { background: #e5edf3; }.chart .b th { background: #f5f3eb; }
.row-number-right { white-space: nowrap; min-width: 115px; }
#graphic { object-fit: fill; flex: none; }
.fabric-main { margin-top: 20px; }.fabric-main .image-area { height: 420px; }
#fabric,#angle-preview { object-fit: fill; flex: none; }
.fabric-views { margin-top: 24px; }
.width-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.width-options button { padding: 8px 12px; }
.width-options button[aria-pressed=true] { background: #116b85; color: white; border-color: #116b85; }
.motif-advice { font-size: .875rem; line-height: 1.5; margin: 18px 0; }
.motif-advice h3 { font-size: 1rem; }
#detail-warning:not(:empty) { border-left: 3px solid #b57315; padding-left: 10px; }
canvas#mask { object-fit: fill; flex: none; }
.gauge { margin: 24px 0 16px; border: 1px solid #a9bbc9; border-radius: 6px; padding: 16px; min-width: 0; }
.gauge legend { font-weight: 650; padding: 0 8px; }
.gauge input { width: 100%; font: inherit; padding: 10px; border: 1px solid #a9bbc9; border-radius: 5px; }
.physical-result { line-height: 1.7; font-variant-numeric: tabular-nums; }
#proportion-warning:not(:empty) { border-left: 3px solid #b57315; padding-left: 12px; color: #78500f; }
* { box-sizing: border-box; }
body { margin: 0; }
header { background: #152e40; color: white; padding: 22px 4vw; display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 650; }.brand span { color: #69d3e0; padding: 0 10px; }.badge { font-size: .875rem; color: #c5dae8; }
main { max-width: 1440px; margin: auto; padding: 30px 4vw 60px; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 8px; letter-spacing: -.03em; }
.intro { margin: 0 0 28px; color: #526778; }
h2 { font-size: 1rem; color: #537b92; margin: 0 0 22px; }h2 span { color: #172d3e; margin-left: 12px; }
.workspace { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
section { background: white; border: 1px solid #d6e0e8; border-radius: 10px; padding: 24px; min-width: 0; }
label { display: block; font-weight: 600; margin: 18px 0 10px; }
input[type=number], input[type=file] { width: 100%; font: inherit; border: 1px solid #a9bbc9; border-radius: 5px; padding: 10px; background: white; }
input[type=file] { font-size: .875rem; }input[type=range] { width: 100%; accent-color: #126d89; }input[type=checkbox] { width: 18px; height: 18px; accent-color: #126d89; }.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
output { float: right; font-variant-numeric: tabular-nums; color: #126d89; }
button { font: inherit; cursor: pointer; border: 1px solid #aec1cd; padding: 10px 16px; border-radius: 5px; background: #fff; color: #172d3e; }
button:hover { background: #e7f3f7; }button:disabled { opacity: .45; cursor: default; }#generate { background: #116b85; color: white; border-color: #116b85; width: 100%; margin-top: 12px; }
:focus-visible { outline: 3px solid #df8800; outline-offset: 3px; }
.hint, figcaption { font-size: .875rem; color: #536776; line-height: 1.5; }.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }figure { margin: 0; min-width: 0; }.image-area { height: 260px; display: flex; align-items: center; justify-content: center; background: #edf1f5; border: 1px solid #d6e0e8; padding: 12px; }canvas { max-width: 100%; max-height: 100%; object-fit: contain; }#mask { image-rendering: pixelated; width: 100%; height: 100%; }figcaption { margin-top: 10px; }
#error { color: #a12128; }#status { font-size: .875rem; }.pattern { margin-top: 24px; }.pattern-heading { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }.pattern p { line-height: 1.5; }.legend { display: flex; gap: 12px 24px; align-items: center; flex-wrap: wrap; }.legend b { display: inline-block; text-align: center; width: 28px; border: 1px solid #849bad; margin-right: 5px; }.yarn-a,.yarn-b { padding: 5px 10px; border-radius: 4px; }.yarn-a { background: #263b50; color: white; }.yarn-b { background: #edf2f7; border: 1px solid #849bad; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 24px 0 14px; }.chart { overflow: auto; max-height: 640px; border: 1px solid #849bad; }table { border-collapse: separate; border-spacing: 0; font-size: 14px; text-align: center; }td { min-width: 28px; height: 28px; border-right: 1px solid #8fa0af; border-bottom: 1px solid #8fa0af; font-weight: 600; }th { min-width: 28px; padding: 5px; background: #f0f4f8; color: #273f51; }th.row-label { min-width: 128px; position: sticky; left: 0; z-index: 1; border-right: 2px solid #8297a8; white-space: nowrap; }.a td { background: #263b50; color: white; }.b td { background: #fff; color: #172d3e; }.block-end td { border-top: 3px solid #1588a0; }details { border-top: 1px solid #d6e0e8; padding-top: 16px; }summary { cursor: pointer; }
@media(max-width: 850px) { .workspace { grid-template-columns: 1fr; }main { padding: 24px 16px; }section { padding: 18px; } }
@media(max-width: 460px) { .preview-grid { grid-template-columns: 1fr; }.image-area { height: 210px; } }

.yarn-controls input[type=color] { width:100%; height:42px; padding:3px; border:1px solid #a9bbc9; border-radius:5px; cursor:pointer; }
.chart .a td,.chart .a th,#legend-a { background:var(--yarn-a); color:var(--ink-a); border-color:var(--ink-a); }
.chart .b td,.chart .b th,#legend-b { background:var(--yarn-b); color:var(--ink-b); border-color:var(--ink-b); }
.chart .block-end td { border-top-width:1px; }

.chart:not([data-mode=color]) td { background:#fff; color:#172d3e; border-color:#8fa0af; }
#chart-mode { font:inherit; padding:8px; margin-bottom:12px; }

#graphic { image-rendering:auto !important; }
#row-description { white-space:pre-wrap; font:inherit; line-height:1.7; max-height:600px; overflow:auto; }

.odd-note { margin-top:24px; padding:22px 24px; border-left:5px solid #408899; border-radius:8px; background:#eaf5f7; color:#173c49; }
.odd-note h2 { color:inherit; margin-bottom:10px; font-size:1.1rem; }
.odd-note p { margin:0; line-height:1.7; }

.image-area { position:relative; }
#edit-hover { position:absolute; pointer-events:none; z-index:2; border:2px solid #d77b00; background:#ffcf4533; }
#edit-tools button { margin:4px 2px; }
#edit-tools button[aria-pressed=true] { background:#126d89; color:white; }

.project-panel { margin-bottom:24px; } .project-panel button { margin:4px; } #project-list article { padding:16px 0; border-top:1px solid #d6e0e8; } #project-list canvas { vertical-align:middle; margin-right:12px; } #project-error { color:#a12128; }
[hidden] { display:none !important; }

#project-dialog { max-width:min(90vw,520px); border:1px solid #a9bbc9; border-radius:10px; padding:24px; } #project-dialog::backdrop { background:#152e4066; } #project-answer { width:100%; font:inherit; padding:10px; margin-bottom:12px; }

#crop-dialog { width:min(95vw,960px); max-height:95vh; overflow:auto; border:1px solid #a9bbc9; border-radius:10px; } #crop-dialog::backdrop { background:#152e4088; } #crop-canvas { width:100%; display:block; touch-action:none; max-height:none; } #crop-dialog button { margin:5px; } #crop-confirm { padding:12px; background:#fff3d9; }

.previews .image-area { height:220px; } .previews .fabric-main .image-area { height:260px; }
#editor-dialog { width:min(96vw,1100px); max-height:96vh; overflow:auto; border:1px solid #a9bbc9; border-radius:10px; } #editor-dialog::backdrop { background:#152e4077; } .editor-zoom { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; } #editor-zoom { width:180px; } .editor-stage { position:relative; overflow:hidden; } #editor-canvas { width:100%; display:block; touch-action:none; max-height:none; }

#example-display { width:100%; height:100%; object-fit:contain; }

.language-control { display:flex; align-items:center; gap:8px; margin:0; font-size:.875rem; }
.language-control select { font:inherit; padding:6px 10px; border:1px solid #a9bbc9; border-radius:5px; background:#fff; color:#172d3e; }
#upload-open { width:100%; margin-bottom:8px; }

.result-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); grid-template-areas:"image fabric" "gauge motif"; gap:24px 18px; align-items:start; }
.result-layout > div { min-width:0; }
.result-image { grid-area:image; }
.result-gauge { grid-area:gauge; }
.result-fabric { grid-area:fabric; }
.result-motif { grid-area:motif; }
.result-layout .fabric-main,.result-layout .gauge { margin-top:0; }
.sample-gauge-note { padding:12px; border-left:3px solid #287c91; background:#eaf5f8; font-size:.875rem; line-height:1.5; }
@media(max-width:850px) { .result-layout { grid-template-columns:minmax(0,1fr); grid-template-areas:"image" "gauge" "fabric" "motif"; } .result-image { width:100%; max-width:400px; } }
/* One palette for workflow stages; image and stitch data remain untouched. */
:root {
  --page:#F6F4EF; --surface:#FFFFFF; --preparation:#FBF3E4;
  --preview:#EDF4F6; --instructions:#EEF4EC;
  --text:#26343D; --muted:#60717A; --border:#CAD6D8;
  --accent:#287C8E; --accent-hover:#216A79;
  color:var(--text); background:var(--page);
}
header { background:var(--surface); color:var(--text); border-bottom:1px solid var(--border); }
.brand span { color:var(--accent); }
.badge,.intro,.hint,figcaption { color:var(--muted); }
section { border-color:var(--border); }
.project-panel { background:var(--surface); }
.controls,.result-gauge .gauge { background:var(--preparation); border-top:3px solid #C6AC7F; }
.previews { background:var(--preview); border-top:3px solid #96B4BE; }
.pattern,.odd-note { background:var(--instructions); border-color:var(--border); border-top:3px solid #A5B99C; }
.odd-note { border-left:3px solid #A5B99C; color:var(--text); }
h2 { color:var(--accent-hover); }
h2 span { color:var(--text); }
input:not([type=color]),select,button { border-color:var(--border); }
input:not([type=color]):not([type=range]):not([type=checkbox]),select { background:var(--surface); color:var(--text); }
input[type=range],input[type=checkbox] { accent-color:var(--accent); }
output { color:var(--accent-hover); }
button { background:var(--surface); color:var(--text); }
button:hover:not(:disabled) { background:var(--preview); border-color:var(--accent-hover); }
#project-save,#upload-open,#crop-apply,#edit-done,
button[aria-pressed=true],.width-options button[aria-pressed=true],#edit-tools button[aria-pressed=true] {
  background:var(--accent); color:#fff; border-color:var(--accent);
}
#project-save:hover:not(:disabled),#upload-open:hover:not(:disabled),#crop-apply:hover:not(:disabled),#edit-done:hover:not(:disabled),button[aria-pressed=true]:hover:not(:disabled) {
  background:var(--accent-hover); color:#fff; border-color:var(--accent-hover);
}
button:active:not(:disabled) { box-shadow:inset 0 0 0 2px var(--accent-hover); }
button:disabled { opacity:1; background:#E8ECEB; color:#53646D; border-color:var(--border); cursor:not-allowed; box-shadow:none; }
:focus-visible { outline:3px solid var(--accent-hover); outline-offset:3px; }
.image-area { background:var(--surface); border-color:var(--border); }
#row-description { background:var(--surface); color:var(--text); padding:16px; border:1px solid var(--border); border-radius:5px; }
.sample-gauge-note { background:var(--surface); border-left-color:var(--accent); }
details { border-color:var(--border); }
dialog { background:var(--surface); color:var(--text); }
@media print {
  :root,body,main,section,.pattern,.odd-note,#row-description { background:#fff !important; color:#000 !important; box-shadow:none !important; }
  header,.project-panel,.workspace,.intro,main>h1,button,.pager,label[for=chart-mode],#chart-mode,dialog { display:none !important; }
  main { max-width:none; padding:0; }
  .pattern,.odd-note { border:0; padding:0; }
  .pattern *, .odd-note * { color:#000 !important; background:#fff !important; border-color:#000 !important; box-shadow:none !important; }
  #chart,#row-description { overflow:visible; max-height:none; }
  #chart table { width:100%; table-layout:fixed; }
  #chart td,#chart th { min-width:0; padding:1px; font-size:8pt; }
  #chart .row-label,#chart .row-number-right { position:static; width:72pt; white-space:normal; }
  #chart tr { break-inside:avoid; }
}

.about { margin-top:24px; } .storage-note,#pwa-status { padding:12px; background:#fff; border-left:3px solid var(--accent); line-height:1.5; } @media print { .about { display:none; } }
/* Each pair shares label, input and help tracks, regardless of translation length. */
.gauge .preview-grid > div {
  display:grid;
  grid-template-rows:subgrid;
  grid-row:span 3;
  row-gap:0;
  min-width:0;
}
.gauge .preview-grid label { align-self:end; }
/* An absent PWA message must not leave an empty notification stripe. */
#pwa-status:empty { display:none; }

/* Keep the project library compact, with wrapping actions on small screens. */
#project-list { max-height:480px; overflow-y:auto; overscroll-behavior:contain; margin-top:12px; }
#project-list[hidden] { display:none; }
#project-list article { overflow-wrap:anywhere; }
#project-list button { max-width:100%; white-space:normal; }

/* Source arrival stays within its existing neutral preview surface. */
.result-image .image-area { overflow:clip; }
button { border-radius:8px; }

#crop-display { width:100%; height:100%; object-fit:contain; }

/* Overview retains every stitch and stripe; only presentation is compact. */
#chart[data-overview=true] { max-height:none; }
#chart[data-overview=true] td { min-width:14px; width:14px; height:11px; font-size:10px; line-height:10px; padding:0; }
#chart[data-overview=true] th { min-width:14px; padding:1px; font-size:9px; line-height:11px; }
#chart[data-overview=true] .row-label,#chart[data-overview=true] .row-number-right { min-width:64px; white-space:nowrap; position:static; }
#chart-pager[hidden] { display:none; }
#chart-dialog { width:96vw; max-width:1800px; max-height:94vh; border:1px solid var(--border); border-radius:10px; }
#chart-dialog::backdrop { background:#26343d88; }
#chart-wide-host { overflow:auto; max-height:72vh; }
@media print { #chart-overview-note { display:none; } }

#rotated-source { width:100%; height:100%; object-fit:contain; }
#shape-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(72px,1fr)); gap:8px; max-height:340px; overflow:auto; margin-top:12px; }
#shape-grid button { padding:6px; min-width:0; font-size:12px; }
#shape-grid img { display:block; width:100%; height:64px; object-fit:contain; background:white; }
.rotation-controls { margin-top:12px; }

#shape-grid[hidden],#personal-motifs[hidden] { display:none; }
.motif-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-top:12px; }
.motif-tabs [aria-selected=true] { background:var(--accent); color:white; }
#personal-motifs { max-height:400px; overflow-y:auto; }
#personal-motifs article { background:white; border:1px solid var(--border); padding:10px; margin:8px 0; overflow-wrap:anywhere; }
#personal-motifs img { width:70px; height:70px; object-fit:contain; display:block; }
#personal-motifs button { padding:6px; margin:3px; max-width:100%; }
#motif-dialog { max-width:min(92vw,520px); border:1px solid var(--border); border-radius:10px; }
#motif-dialog::backdrop { background:#26343d88; }
#motif-answer { display:block; width:100%; margin:12px 0; padding:8px; }
#motif-answer[hidden] { display:none; }
#motif-status:empty { display:none; }

.motif-tabs button[aria-selected=true]:hover:not(:disabled) { background:var(--accent-hover); color:white; }

/* Independent column heights; settings stay with the selected image. */
.workspace { align-items:start; }
.previews { align-self:start; }
.current-motif-controls { margin-top:16px; }
.current-motif-controls > :last-child { margin-bottom:0; }
.legend .purl-symbol { font-weight:900; color:#000; text-shadow:0 .35px currentColor,0 -.35px currentColor; }

.result-layout { grid-template-areas:none; }
.result-column { display:flex; flex-direction:column; gap:24px; min-width:0; }

#shape-library { margin-top:28px; }
#shape-library > summary { font-size:1.2rem; font-weight:750; color:#356747; line-height:1.4; }
#shape-library .motif-advice { margin:12px 0 18px; }
.controls .result-motif { margin-top:20px; }
.controls .result-motif .image-area { height:220px; background:white; }
#source-stage { height:220px; display:flex; align-items:center; justify-content:center; max-width:100%; }
.result-image #source-area { flex:none; padding:0; max-width:100%; background:white; border:0; }
#source-area canvas { width:100%; height:100%; object-fit:contain; }
#fabric-dialog { width:min(96vw,1400px); max-height:94vh; border:1px solid var(--border); border-radius:10px; }
#fabric-dialog::backdrop { background:#26343d99; }
#fabric-stage { height:65vh; overflow:auto; background:#fff; }
#fabric-large { display:block; margin:auto; max-width:none; max-height:none; object-fit:contain; }

/* Sequential workflow: DOM and mobile order match the numbered stages. */
.workspace.workflow { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
.workflow .result-image { max-width:none; }
.workflow .fabric-main { margin-top:0; }
.workflow .image-area { height:260px; background:white; }
.workflow .gauge { margin-top:0; }
.motif-step,.gauge-step,.yarn-step { background:var(--preparation); border-top:3px solid #C6AC7F; }
#shape-library > summary { color:var(--accent-hover); }
#edit-start { background:var(--accent); color:white; border-color:var(--accent); font-size:1.05rem; font-weight:650; padding:12px 20px; margin-top:12px; border-radius:8px; }
#edit-start:hover:not(:disabled) { background:var(--accent-hover); color:white; }
#edit-start:active:not(:disabled) { box-shadow:inset 0 0 0 2px #174b56; }
#project-origin:empty { display:none; }
.input-thumbnail,.mask-thumbnail { margin:16px 0 0; text-align:center; }
.input-thumbnail canvas,.mask-thumbnail canvas { max-width:100%; width:auto; max-height:180px; object-fit:contain; background:white; }
#fabric-angle { object-fit:contain; }
@media(max-width:850px) { .workspace.workflow { grid-template-columns:minmax(0,1fr); } }

.mask-thumbnail canvas { width:min(100%,320px); height:auto; image-rendering:pixelated; }

.field-error { color:#9c3030; font-size:.9em; margin:4px 0 0; }
.field-error[hidden] { display:none; }
/* Six flexible steps; only the inner data views use white surfaces. */
.guided-workflow { gap:20px; }
.workflow-step { border:1px solid var(--border); border-top:3px solid #C6AC7F; border-radius:12px; padding:0; min-width:0; background:var(--preparation); overflow-wrap:anywhere; }
.workflow-step.tone-preview { background:var(--preview); border-top-color:#96B4BE; }
.workflow-step.tone-result { background:var(--instructions); border-top-color:#A5B99C; }
.workflow-step > summary { padding:18px 20px; min-height:64px; }
.workflow-step > summary h2 { display:inline; font-size:1.15rem; font-weight:700; margin:0; color:var(--text); }
.step-number { color:var(--accent-hover); font-weight:750; margin-right:10px; }
.step-summary { display:block; font-size:.85rem; font-weight:400; color:var(--muted); margin:6px 0 0 26px; }
.workflow-step[open] > summary .step-summary { display:none; }
.step-body { padding:0 20px 20px; }
.step-body > section { padding:0; border:0; background:transparent; }
#step-5,#step-6 { grid-column:1/-1; }
.step-purpose { margin-top:0; line-height:1.6; }
#shape-library > summary { color:var(--accent); font-size:1.2rem; font-weight:700; }
#shape-library { margin:20px 0; }
#shape-grid,#personal-motifs { max-height:350px; overflow-y:auto; overscroll-behavior:contain; }
button { min-height:44px; max-width:100%; white-space:normal; overflow-wrap:anywhere; }
button:disabled { cursor:default; }
button.step-primary,#edit-start { background:var(--accent); color:white; border-color:var(--accent); font-weight:650; }
button.step-primary:hover:not(:disabled) { background:var(--accent-hover); color:white; }
button.step-primary:active:not(:disabled) { box-shadow:inset 0 0 0 2px #174b56; }
button.step-primary:disabled,#edit-start:disabled { background:#E8ECEB; color:#53646D; border-color:var(--border); }
#edit-start { display:inline-flex; gap:8px; align-items:center; justify-content:center; }
#edit-start svg { flex:none; }
.project-panel { padding:16px 20px; }
.project-panel h2 { margin-bottom:8px; }
.project-panel button,#project-save { background:var(--surface); color:var(--text); }
#project-save:hover:not(:disabled) { background:var(--preview); color:var(--text); }
#project-status { font-size:.875rem; color:var(--muted); margin:8px 0; }
.project-panel .storage-note { padding:6px 10px; font-size:.85rem; }
.width-options button[aria-pressed=true] { background:var(--preview); color:var(--accent-hover); border:2px solid var(--accent); font-weight:700; }
#source-stage { height:220px; }
.current-motif-controls { margin-top:12px; }
.fine-settings { margin-top:14px; padding-top:12px; }
.fine-settings > summary { min-height:36px; }
.mask-thumbnail { padding:12px; background:white; border:1px solid var(--border); border-radius:8px; }
.result-cards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; gap:20px; }
.result-cards .result-card { padding:18px; background:var(--surface); border:1px solid var(--border); border-radius:10px; margin:0; min-width:0; }
.result-cards .result-fabric { grid-area:auto; }
.result-card .image-area { height:260px; }
.result-card h2,.result-card strong { font-size:1rem; font-weight:700; }
.result-card .chart { max-height:340px; }
.description-card #row-description { max-height:300px; }
.description-card .odd-note { margin:0 0 20px; padding:12px 14px; }
.description-card .odd-note h2 { font-size:.95rem; }
.description-card .odd-note p { font-size:.875rem; }
#description-dialog { width:min(92vw,960px); max-height:90vh; border:1px solid var(--border); border-radius:10px; }
#description-dialog::backdrop { background:#26343d88; }
#description-large { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; line-height:1.8; }
#chart-dialog .chart { max-height:70vh; }
#step-5 .yarn-controls { display:flex; flex-wrap:wrap; align-items:flex-start; gap:16px 24px; max-width:100%; }
#step-5 .color-field { display:grid; grid-template-columns:minmax(60px,1fr) 120px 26px; align-items:center; gap:8px; flex:0 1 280px; min-width:222px; max-width:100%; }
#step-5 .color-field input[type=color] { width:120px; height:42px; box-sizing:border-box; margin:0; }
#step-5 .color-field .help-tip { margin:0; }
#step-5 .yarn-controls label { margin:0; }
.step-body .gauge { background:transparent; border:0; padding:0; }
.step-body .gauge legend { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
@media(min-width:1300px) { .preparation-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:18px; align-items:start; } .current-motif-controls { margin-top:0; } }
@media(max-width:850px) { .result-cards { grid-template-columns:minmax(0,1fr); } .step-body { padding:0 14px 16px; } .workflow-step > summary { padding:16px 14px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto !important; animation:none !important; transition:none !important; } }
@media print {
 .workspace.guided-workflow,#step-6,.step-body,.preview-step,.result-cards { display:block !important; background:#fff !important; padding:0; border:0; }
 .guided-workflow > details:not(#step-6),.workflow-step > summary,.result-cards > article { display:none !important; }
 .result-cards .pattern { margin:0; padding:0; border:0; }
 .result-card .chart,.description-card #row-description { max-height:none; overflow:visible; }
}
/* Label and help tracks stay aligned in both languages and error states. */
.step-body .gauge .preview-grid > div { grid-row:span 4; }
.step-body .gauge .preview-grid label { grid-row:1; }
.step-body .gauge .preview-grid input { grid-row:2; }
.step-body .gauge .preview-grid .field-error { grid-row:3; }
.step-body .gauge .preview-grid #blocks-note { grid-row:4; }
.first-four { min-width:0; }
.first-four pre { white-space:pre-wrap; overflow-wrap:anywhere; max-width:100%; line-height:1.6; }
#chart .row-label, #chart .row-number-right { white-space:normal; }
@media print {
  .first-four { display:none; }
  #row-description { display:block!important; white-space:pre-wrap; color:#000; background:#fff; }
  #chart td, #chart th, .legend b { color:#000!important; background:#fff!important; border-color:#000!important; }
}
#editor-dialog[open] { display:flex; flex-direction:column; gap:8px; height:94vh; overflow:hidden; box-sizing:border-box; }
#editor-dialog.expanded { width:98vw; max-width:98vw; height:98vh; max-height:98vh; margin:auto; }
#editor-dialog h2 { margin:0; }
#editor-dialog .editor-stage { flex:1 1 0; min-width:0; min-height:90px; overflow:scroll; scrollbar-gutter:stable; contain:size layout; position:relative; }
#editor-scroll-space { position:absolute; top:0; left:0; pointer-events:none; }
#editor-canvas { position:sticky; top:0; left:0; width:auto; height:auto; max-width:none; max-height:none; cursor:crosshair; }
#editor-comparison > div,.mask-comparison { display:flex; gap:16px; align-items:center; justify-content:center; }
#editor-comparison canvas { height:100px; max-width:240px; object-fit:contain; }
#editor-map { touch-action:none; cursor:crosshair; }
#editor-coordinates { min-height:1.5em; font-size:.85rem; }
#editor-dialog .hint { display:none; }
#editor-dialog .editor-zoom,#edit-tools { flex-shrink:0; margin:0; }
#edit-tools p { margin:0; }
.mask-thumbnail canvas { width:auto; height:auto; max-width:100%; max-height:320px; object-fit:contain; }
#mask-dialog { width:min(96vw,1200px); max-height:96vh; box-sizing:border-box; overflow:auto; }
.mask-comparison figure { flex:1; min-width:0; text-align:center; }
.mask-comparison canvas { width:auto; height:auto; max-width:100%; max-height:65vh; object-fit:contain; image-rendering:pixelated; }
@media(max-width:600px){#editor-dialog[open] { width:99vw; max-width:99vw; height:99dvh; max-height:99dvh; padding:8px; } #editor-dialog button { min-height:32px; padding:5px; } #editor-comparison canvas { height:65px; max-width:130px; } #editor-dialog .editor-zoom { gap:4px; } #editor-zoom { width:100px; } #edit-tools p { display:none; } }
.editor-heading { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.editor-heading h2 { flex:1; font-size:1.1rem; }
#editor-dialog .editor-stage { min-height:90px; }
#editor-dialog #edit-tools { display:flex; gap:5px; flex-wrap:wrap; }
#editor-dialog #edit-tools p { display:none; }
#editor-dialog button { min-height:34px; padding:6px 9px; }
#editor-comparison { margin:0; padding:4px; }
#editor-comparison figcaption { margin:2px 0; }
#editor-comparison canvas { height:72px; }
#editor-coordinates { min-height:20px; }
#editor-dialog,#editor-stage { transition:none; animation:none; }
#editor-comparison { flex-shrink:0; }
#editor-comparison figure { width:240px; }
#editor-comparison canvas { width:100%; }
#current-motif { position:sticky; top:0; z-index:5; padding:12px 16px; background:#edf5f5; border-left:4px solid #287c8e; font-weight:600; }
#personal-motifs article[data-current="true"] { outline:2px solid #287c8e; background:#edf5f5; }
.motif-active { display:block; color:#245460; }
#blank-dialog { width:min(92vw,450px); }
#blank-dialog label { display:block; margin-top:12px; }
#blank-dialog input { width:100%; }
#blank-presets { display:flex; flex-wrap:wrap; gap:5px; margin:8px 0; }
@media(min-width:1000px){#editor-comparison canvas { height:100px; } }
@media(max-width:600px){.editor-heading h2 { flex-basis:100%; } #editor-comparison canvas { height:50px; } #editor-dialog .editor-zoom button,#edit-tools button { font-size:12px; } }
#mask-dialog[open] { display:flex; flex-direction:column; width:96vw; max-width:1600px; height:96dvh; max-height:96dvh; padding:16px; gap:6px; overflow:auto; }
#mask-close { align-self:flex-end; flex:none; }
#mask-dialog .mask-comparison { flex:1; min-height:100px; overflow:hidden; }
#mask-dialog .mask-comparison figure:first-child { display:none; }
#mask-dialog .mask-comparison figure:last-child { width:100%; height:100%; display:flex; align-items:center; justify-content:center; }
#mask-dialog figcaption { display:none; }
#mask-dialog #mask-large { max-height:none; max-width:none; flex:none; object-fit:contain; }
#mask-dialog > input,#mask-dialog > label { width:min(100%,420px); align-self:center; flex:none; margin:0; }
#mask-dialog > input { height:24px; }
#mask-dialog > label { font-size:.875rem; }
@media(max-width:600px){#mask-dialog[open] { padding:8px; width:99vw; height:99dvh; max-height:99dvh; } }
#help-dialog { width:min(94vw,900px); max-height:94dvh; padding:16px; border:1px solid var(--border); border-radius:12px; box-sizing:border-box; }
#help-dialog[open] { display:flex; flex-direction:column; }
#help-dialog::backdrop { background:#26343d80; }
.help-heading { display:flex; gap:12px; align-items:center; justify-content:space-between; }
.help-heading h2 { margin:0; }
#help-body { overflow:auto; min-height:0; padding:8px 2px; line-height:1.6; }
#help-body nav { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:16px; }
#help-body button { margin:3px; }
#help-body details { margin:8px 0; padding:8px; }
#help-body summary { cursor:pointer; }
button.help-tip { border-radius:50%; padding:0; min-height:26px; min-width:26px; width:26px; height:26px; margin:3px; font-size:14px; vertical-align:middle; }
.help-demo-grid { display:grid; grid-template-columns:repeat(7,32px); justify-content:center; margin:12px 0; }
#help-body .help-demo-grid button { width:32px; height:32px; min-height:32px; padding:0; margin:0; border-radius:0; border:1px solid #77858b; }
.help-demo-grid .black { background:#000; }.help-demo-grid .white { background:#fff; }
.help-demo-views { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.help-demo-views canvas { width:100%; height:auto; max-height:260px; object-fit:contain; }
.help-instructions { white-space:pre-wrap; overflow-wrap:anywhere; font-size:.85rem; background:#fff; padding:8px; }
@media(max-width:600px){#help-dialog{width:98vw;padding:10px;}#help-body nav button{font-size:.85rem;} .help-demo-views{grid-template-columns:1fr;} }
@media print { #help-open,.help-tip,#help-dialog { display:none!important; } }

/* Keep related actions and yarn labels together at fractional browser zoom. */
.start-actions { display:flex; flex-wrap:wrap; gap:16px; margin:16px 0; }
.start-actions button { flex:1 1 230px; min-height:48px; margin:0; max-width:100%; white-space:normal; }
.color-legend { display:flex; flex-wrap:wrap; gap:12px; max-width:100%; }
.color-legend > span { flex:0 0 auto; width:auto; white-space:nowrap; }
.motif-tabs button[aria-expanded="true"] { background:var(--accent); color:white; }
#manual-state button { margin:6px; min-height:44px; }
#manual-crop-dialog { width:min(90vw,560px); box-sizing:border-box; }
#manual-crop-preview { display:block; width:auto; height:auto; max-width:100%; max-height:40vh; image-rendering:pixelated; margin:16px auto; }
[hidden] { display:none!important; }

.motif-actions { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin:12px 0; }
.motif-actions button,#edit-start { margin:0; min-height:44px; }
.editor-toolbar { gap:12px; }
#shape-library { margin-top:16px; }
.motif-tabs button { min-height:44px; position:relative; }
#shape-library { margin:16px 0; padding:16px; border:1px solid var(--border); border-radius:10px; background:var(--surface,#fff); }
#shape-library > h3 { margin:0 0 12px; }
.motif-tabs,.motif-transfer { display:flex; flex-wrap:wrap; gap:12px; margin:12px 0; }
.motif-tabs button,.motif-transfer button { margin:0; }
#shape-library .motif-advice { margin-top:16px; }
