:root {
  color-scheme: light;
  --paper: #f5f1ea; --panel: #fffcf7; --ink: #312a34; --muted: #655e68;
  --accent: #B85268; --selected-bg: #F8E6EB; --selected-edge: #A46273; --selected-ink: #8B3E52;
  --progress-track: #EED9DF; --progress-fill: #AB5368;
  --line: #dcd2cf; --serif: "Songti SC","STSong","Noto Serif CJK SC",Georgia,serif;
  font-family: "Avenir Next","PingFang SC","Microsoft YaHei",sans-serif;
  color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
.localizing body { visibility: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; border: 0; background: transparent; }
button:disabled { opacity: .4; cursor: default; }
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible,a:focus-visible,canvas:focus-visible,select:focus-visible { outline: 3px solid var(--selected-ink); outline-offset: 2px; }
button:hover:not(:disabled) { filter: brightness(.93); }
[hidden] { display: none !important; }
.mast { position: sticky; top: 0; z-index: 5; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-inline: max(4.5%,calc((100% - 1500px) / 2)); background: var(--panel); }
.identity,.head-actions,.deskbar,.desk-foot,.section-title,.dialog-actions,.sound { display: flex; align-items: center; }
.identity { gap: 10px; white-space: nowrap; }
.identity .latin { font: italic 17px Georgia,serif; color: var(--selected-ink); }
.yarnmark { background-color: var(--accent); position: relative; flex: none; border-radius: 50%; overflow: hidden; isolation: isolate; }
.yarnmark { width: 28px; height: 28px; }
.yarnmark::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg,transparent 0 2px,#ffffff45 2.7px 3.4px,transparent 4.2px),radial-gradient(ellipse at 32% 20%,#ffffff3a,transparent 55%,#10181059 98%); }
.yarnmark::after { content: ""; position: absolute; width: 117%; height: 68%; bottom: -11%; left: -8%; border-radius: 45% 50% 0 0; transform: rotate(-32deg); background: repeating-linear-gradient(24deg,transparent 0 1.8px,#ffffff52 2.7px 3.3px,transparent 4.4px),linear-gradient(#ffffff0d,#080c1545),var(--accent); box-shadow: 0 -1px 2px #13261545; }
.head-actions { gap: 12px; white-space: nowrap; }
#language {
  appearance: none; max-width: 155px; padding: 7px 29px 7px 8px;
  border: 1px solid var(--line); border-radius: 7px; color: inherit; font-size: 13px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23312a34' stroke-width='1.5'/%3E%3C/svg%3E") right 12px center / 10px 6px no-repeat border-box;
}
.primary { padding: 11px 17px; border-radius: 7px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; }
.quiet,.sound { font-size: 13px; font-weight: 500; }
.quiet > [aria-hidden] { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1.4px solid currentColor; border-radius: 50%; font: 600 12px Georgia,serif; }
main { width: 91%; max-width: 1500px; margin: auto; padding: 22px 0 42px; }
h1,h2,p { margin: 0; }
.sound-controls { display: inline-flex; align-items: center; padding-right: 6px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.sound { gap: 8px; padding: 9px 12px; border-radius: 18px; }
#motor-tone { border: 0; border-left: 1px solid var(--line); border-radius: 0 18px 18px 0; padding: 4px 6px; color: inherit; background-color: var(--panel); font-size: 12px; }
.x-link { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 8px; }
.x-link:hover { background: var(--selected-bg); }
#x-tip { display: none; position: absolute; top: 100%; right: 0; width: max-content; max-width: calc(100vw - 24px); padding: 6px 10px; border-radius: 6px; background: var(--ink); color: var(--panel); font-size: 12px; line-height: 1.4; white-space: normal; }
.x-link:is(:hover, :focus-visible) #x-tip { display: block; }
.waves { display: flex; align-items: center; gap: 2px; height: 14px; }
.waves b { width: 2px; background: currentColor; height: 7px; border-radius: 2px; }
.waves b:nth-child(2) { height: 13px; }.waves b:nth-child(3) { height: 10px; }
.sound[aria-pressed=false] .waves b { height: 2px; }
.layout { display: grid; grid-template-columns: minmax(0,1fr) clamp(246px,23%,325px); gap: 19px; }
.desk,.inspector { min-width: 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--panel); }
.deskbar,.desk-foot { justify-content: space-between; gap: 8px; padding: 11px 15px; }
.deskbar { border-bottom: 1px solid var(--line); }
.views { display: flex; flex-wrap: wrap; max-width: 100%; border-radius: 8px; background: #f0e9e5; padding: 3px; }
.views button,.angle,.desk-foot { font-size: 13px; }
.views button,.angle { border-radius: 6px; padding: 7px 13px; white-space: nowrap; }
.views button[aria-pressed=true] { background: var(--accent); color: #fff; }
.primary,.views button[aria-pressed=true] { box-shadow: inset 0 0 0 1px var(--selected-edge); }
button.primary:hover:not(:disabled),.views button[aria-pressed=true]:hover { background: var(--selected-ink); filter: none; }
button.primary:active:not(:disabled) { background: var(--selected-ink); }
.angle { border: 1px solid var(--line); }
.angle[aria-pressed=true],.thread[aria-pressed=true] { background: var(--selected-bg); border-color: var(--selected-edge); color: var(--selected-ink); }
.deskbar { flex-wrap: wrap; }
.desk-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; margin-left: auto; }
#assist { display: inline-flex; align-items: center; gap: 5px; }
#assist i { width: 17px; height: 10px; border-radius: 8px; background: #817a79; padding: 2px; }
#assist i::after { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; background: white; }
#assist[aria-pressed=true] i { background: var(--selected-ink); }
#assist[aria-pressed=true] i::after { margin-left: auto; }
.stage { position: relative; background: #f6f1e6; isolation: isolate; }
#workspace { outline-offset: -3px; display: block; width: 100%; aspect-ratio: 1.64; touch-action: none; user-select: none; }
.stage-hud { pointer-events: none; position: absolute; bottom: 14px; left: 15px; right: 15px; display: flex; justify-content: space-between; align-items: end; }
.plate,.zoom-group { background: var(--panel); color: var(--ink); border: 1px solid #b8a9a7; box-shadow: 0 1px 3px #312a3415; border-radius: 6px; }
.plate { padding: 5px 9px; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.zoom-group { display: flex; pointer-events: auto; }
.zoom-group button { min-width: 29px; height: 29px; padding: 0 6px; font-size: 15px; }
#zoom { font: 600 11px/1 ui-monospace,monospace; }
#pan { padding-inline: 9px; font-size: 12px; border-right: 1px solid var(--line); }
#pan[aria-pressed=true] { background: var(--selected-bg); color: var(--selected-ink); }
#workspace.can-pan { cursor: grab; }
#workspace.dragging { cursor: grabbing; }
#notice { position: absolute; z-index: 2; left: 50%; top: 14px; transform: translateX(-50%); width: max-content; max-width: 88%; background: var(--selected-ink); color: #fff; border-radius: 6px; padding: 9px 12px; font-size: 13px; text-align: center; pointer-events: none; }
.desk-foot { flex-wrap: wrap; min-height: 48px; color: var(--muted); border-top: 1px solid var(--line); }
.desk-foot > div { display: flex; align-items: center; gap: 8px; }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--selected-ink); }
.desk-foot button { white-space: nowrap; }
.desk-foot > div { flex-wrap: wrap; }
.desk-foot .edit-actions { flex: none; flex-wrap: nowrap; gap: 4px; margin-left: auto; }
.edit-actions button { padding: 6px; }
#restart { border-left: 1px solid var(--line); padding-left: 10px; }
.desk-foot .live { flex-shrink: 0; }
#action { font-weight: 700; }
#suggest { color: var(--selected-ink); background: var(--selected-bg); border: 1px solid var(--selected-edge); border-radius: 5px; padding: 4px 8px; }
#suggest::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-right: 4px; border-radius: 50%; background: var(--yarn); border: 1px solid #20432d55; }
.inspector { contain: size; display: grid; grid-template-rows: auto minmax(0,max-content) minmax(126px,1fr) auto; }
.inspector-actions { padding: 11px 18px; border-bottom: 1px solid var(--line); }
#import { width: 100%; }
.inspector > section { padding: 18px; }.inspector > section + section { border-top: 1px solid var(--line); }
.section-title { justify-content: space-between; gap: 6px; }
h2 { font-size: 15px; font-weight: 650; }
.section-title > span { color: var(--muted); font-size: 11px; }
.pattern-panel { display: flex; flex-direction: column; min-height: 0; }
.sample { min-height: 0; margin: 13px 0 0; border-radius: 7px; overflow: hidden; background-color: #e8ded3; background-image: repeating-linear-gradient(0deg,#49361008 0 1px,transparent 1px 3px),repeating-linear-gradient(90deg,#49361009 0 1px,transparent 1px 3px); }
.sample canvas { width: 100%; max-height: 100%; display: block; object-fit: contain; }
.threads { display: flex; flex-direction: column; min-height: 0; }
#palette { display: grid; align-content: start; min-height: 0; gap: 5px; margin-top: 12px; overflow-y: auto; scrollbar-width: none; }
#palette::-webkit-scrollbar { display: none; }
#palette .thread:focus-visible { outline-offset: -3px; }
.thread { display: flex; align-items: center; border-radius: 7px; border: 1px solid transparent; gap: 10px; min-width: 0; padding: 6px 9px; text-align: left; }
.bobbin { position: relative; width: 24px; height: 24px; margin-inline: 2px; flex: none; transform: rotate(12deg); border-radius: 35% 35% 34% 34% / 12%; border-block: 3px solid #5e5555; background: repeating-linear-gradient(164deg,transparent 0 2px,#fff8df69 2.5px 3px,transparent 3.4px 5px), repeating-linear-gradient(10deg,transparent 0 1.3px,#301b142a 1.7px 2.1px),linear-gradient(90deg,#28180f39,transparent 25%,#fffee524 40%,transparent 65%,#381e1840),var(--yarn); box-shadow: 0 1px 2px #1e291f28; }
.thread .thread-name { font-size: 12px; font-weight: 600; }
.thread small { margin-left: auto; font: 10px ui-monospace,monospace; color: var(--muted); }
.thread .chosen { width: 11px; font-size: 12px; color: var(--selected-ink); }
#palette.many-colors { grid-template-columns: repeat(auto-fit,minmax(38px,1fr)); gap: 4px; }
.many-colors .thread { justify-content: center; position: relative; min-height: 36px; padding: 5px; }
.many-colors .thread-name,.many-colors .thread small { display: none; }
.many-colors .thread .chosen { position: absolute; right: 1px; bottom: 1px; width: auto; font: bold 10px/1 sans-serif; }
#replace .dialog-actions,#restart-dialog .dialog-actions { flex-wrap: wrap; }
#save-dialog .dialog-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: stretch; }
#save-dialog .dialog-actions button:not(.close) { min-height: 42px; padding: 8px 12px; font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
@media (max-width:480px) { #save-dialog .dialog-actions { grid-template-columns: 1fr; gap: 8px; } }
.yarn-quality { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.yarn-quality select { max-width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; }
.yarn-quality span { color: var(--muted); white-space: nowrap; }
.progress-panel strong { font: 600 20px Georgia,serif; }
#repair,#save-piece { width: 100%; margin-top: 12px; }
progress { appearance: none; display: block; border: 0; background: var(--progress-track); width: 100%; height: 6px; border-radius: 8px; overflow: hidden; margin: 13px 0 0; }
progress::-webkit-progress-bar { background: var(--progress-track); }progress::-webkit-progress-value { background: var(--progress-fill); }progress::-moz-progress-bar { background: var(--progress-fill); }
dialog { border: 1px solid var(--line); border-radius: 14px; max-width: min(440px,90vw); padding: 26px; background: var(--panel); color: var(--ink); box-shadow: 0 20px 100px #0e261e40; }
dialog::backdrop { background: #312a3480; }
dialog h2 { font-family: var(--serif); font-size: 23px; margin: 1px 25px 12px 0; }
dialog p,dialog li { line-height: 1.75; font-size: 14px; }dialog ol { padding-left: 20px; }dialog li { padding-left: 3px; margin-bottom: 5px; }
.close { position: absolute; top: 11px; right: 12px; font-size: 23px; }
.dialog-actions { display: flex; gap: 14px; margin-top: 16px; justify-content: flex-end; }
@media (min-width:1570px) { #workspace { max-height: 690px; } }
@media (max-width:1150px) { .inspector > section { padding: 14px; }.inspector-actions { padding: 8px 14px; } }
@media (max-width:850px) { .layout { grid-template-columns: minmax(0,1fr) 214px; gap: 12px; }.inspector > section { padding: 13px; }.inspector-actions { padding-inline: 13px; } main { width: 95%; }.mast { padding-inline: 2.5%; } #workspace { aspect-ratio:1.18; } }
@media (max-width:760px) { .quiet { padding: 6px; }.quiet-label { display: none; } }
@media (max-width:650px) {
  .mast { min-height: 58px; padding: 8px 12px; gap: 6px; flex-wrap: wrap; }.identity { gap: 5px; }.identity .latin { font-size: 13px; }.yarnmark { width: 20px; height: 20px; }
  .head-actions { gap: 5px; margin-left: auto; flex-wrap: wrap; }.quiet { padding: 4px; }.primary { padding: 8px 10px; font-size: 12px; }
  #language { max-width: 101px; padding: 6px 29px 6px 6px; font-size: 12px; }
  main { width: auto; margin-inline: 12px; padding-block: 12px 18px; }.sound { padding: 6px 8px; font-size: 11px; }
  .layout { display: flex; flex-direction: column; gap: 11px; }.desk,.inspector { width: 100%; }.deskbar,.desk-foot { padding: 8px 9px; }.desk-foot { min-height: 40px; }
  #workspace { aspect-ratio: 1.1; }.views button,.angle,.desk-foot { font-size: 12px; }.views button,.angle { padding: 6px 9px; }.stage-hud { left: 8px; right: 8px; bottom: 8px; }
  .inspector { contain: none; grid-template-columns: 45% 55%; grid-template-rows: auto auto auto; }.inspector > section { padding: 12px; }.inspector > .threads { border-top: 0; border-left: 1px solid var(--line); }.inspector-actions,.progress-panel { grid-column: 1/-1; }.pattern-panel { display: block; }.sample { margin: 9px 0 0; }.sample canvas { max-height: none; }.thread { padding: 4px; gap: 5px; } .thread small { display: none; }.thread .chosen { margin-left: auto; }.thread .bobbin { width: 19px; height: 20px; }#palette { max-height: 180px; margin-top: 7px; }.section-title h2 { font-size: 13px; }
}
@media (max-width:540px) { #sound-text { display: none; } }
@media (max-width:350px) { .mast { padding-inline: 8px; } }
