:root { --bg:#fff; --ink:#3b3f45; --ink-soft:#8d9299; --line:#eceef0; --accent:#2f6f6a; --accent-bg:#eef5f4; }
:root[data-theme="dark"] { --bg:#17191c; --ink:#dfe2e6; --ink-soft:#7d838b; --line:#272a2f; --accent:#6fc2b9; --accent-bg:#1f2b2a; }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { min-height:100%; margin:0; }
body { background:var(--bg); color:var(--ink); font-family:"PingFang SC","HarmonyOS Sans SC","Noto Sans SC","Microsoft YaHei",system-ui,sans-serif; -webkit-font-smoothing:antialiased; }
.app { max-width:1440px; min-height:100vh; margin:0 auto; padding:0 40px; }
header { display:flex; align-items:center; justify-content:space-between; padding:34px 0 20px; border-bottom:1px solid var(--line); }
header h1 { margin:0; font-size:22px; font-weight:600; letter-spacing:.04em; }
header p { margin:6px 0 0; color:var(--ink-soft); font-size:13px; }
.header-actions { display:flex; align-items:center; gap:10px; }
.theme-toggle,.user-entry { appearance:none; border:1px solid var(--line); background:var(--bg); color:var(--ink); cursor:pointer; transition:.15s; }
.theme-toggle { display:grid; width:40px; height:40px; padding:0; border-radius:50%; place-items:center; }
.theme-toggle svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; }
.user-entry { display:inline-flex; min-height:40px; padding:0 14px; align-items:center; gap:9px; border-radius:8px; font:inherit; font-size:14px; }
.user-entry svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; }
.theme-toggle:hover,.user-entry:hover { border-color:var(--accent); background:var(--accent-bg); color:var(--accent); }
.theme-toggle:focus-visible,.user-entry:focus-visible,.item:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.tool-sections { padding:32px 0 56px; }
.tool-section + .tool-section { margin-top:34px; }
.tool-section h2 { margin:0 0 18px; color:var(--ink); font-size:19px; font-weight:600; letter-spacing:.04em; }
.grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:18px; }
.item { display:flex; min-height:178px; padding:26px 16px; align-items:center; justify-content:center; flex-direction:column; gap:14px; border:1px solid var(--line); border-radius:12px; background:var(--bg); color:var(--ink); font:inherit; cursor:pointer; transition:.15s; }
.item svg { width:30px; height:30px; fill:none; stroke:var(--ink-soft); stroke-width:1.3; stroke-linecap:round; stroke-linejoin:round; }
.item span { font-size:15px; letter-spacing:.06em; white-space:nowrap; }
.item:hover { border-color:var(--accent); background:var(--accent-bg); transform:translateY(-3px); box-shadow:0 8px 20px rgba(30,45,45,.08); }
.item:hover svg { stroke:var(--accent); }
.sheet { position:fixed; inset:0; z-index:10; overflow-y:auto; background:var(--bg); transform:translateX(100%); transition:transform .28s cubic-bezier(.2,.8,.2,1); }
.sheet.open { transform:none; }
.sheet-inner { max-width:760px; margin:0 auto; }
.bar { position:sticky; top:0; display:flex; height:52px; padding:0 8px; align-items:center; border-bottom:1px solid var(--line); background:var(--bg); }
.bar button { width:44px; height:44px; border:0; border-radius:10px; background:none; color:var(--ink); cursor:pointer; }
.bar svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; }
.bar h2 { flex:1; margin:0 44px 0 0; text-align:center; font-size:17px; }
.sheet-body { padding:72px 24px; color:var(--ink-soft); text-align:center; }
.sheet-body>svg { width:44px; height:44px; fill:none; stroke:var(--accent); stroke-width:1.2; }
#sheet-text { margin:20px 0 0; font-size:15px; line-height:1.7; }
.converter { max-width:640px; margin:0 auto; overflow:hidden; border:1px solid var(--line); border-radius:12px; color:var(--ink); text-align:left; }
.converter-row,.calc-result { display:grid; grid-template-columns:minmax(130px,1fr) minmax(180px,1.4fr); min-height:68px; padding:0 22px; align-items:center; border-bottom:1px solid var(--line); }
.converter-label { font-size:16px; }
.converter-input { width:100%; padding:10px 0; border:0; outline:0; background:transparent; color:var(--ink); font:inherit; font-size:18px; text-align:right; }
.converter-input:focus { color:var(--accent); }
.converter-input::-webkit-outer-spin-button,.converter-input::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }
.converter-input[type=number] { appearance:textfield; -moz-appearance:textfield; }
.converter-actions { display:flex; justify-content:flex-end; padding:14px 18px; background:var(--accent-bg); }
.reset-button { border:0; border-radius:8px; padding:9px 16px; background:var(--accent-bg); color:var(--accent); font:inherit; cursor:pointer; }
.capital-result { min-height:88px; padding:26px 22px; border-bottom:1px solid var(--line); color:var(--ink); font-size:27px; font-weight:500; text-align:right; }
.calc-tabs { display:grid; max-width:640px; margin:0 auto 18px; grid-template-columns:1fr 1fr; border-bottom:1px solid var(--line); }
.calc-tab { border:0; border-bottom:2px solid transparent; padding:13px 10px; background:transparent; color:var(--ink-soft); font:inherit; cursor:pointer; }
.calc-tab.active { border-color:var(--accent); color:var(--accent); font-weight:600; }
.calc-result { border-bottom:0; border-top:1px solid var(--line); }
.calc-result strong { justify-self:end; color:var(--ink); font-size:20px; font-weight:500; }
.cost-loss small { display:block; margin-top:3px; color:var(--ink-soft); font-size:12px; }
.production-panel { max-width:640px; margin:0 auto; text-align:left; }
.production-panel h3 { margin:0 0 16px; color:var(--ink); font-size:22px; }
.production-heading { display:flex; align-items:center; justify-content:space-between; margin:28px 0 16px; }
.production-heading h3 { margin:0; }
.production-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.production-grid--four .metric-card { min-height:132px; }
.production-grid--one { grid-template-columns:1fr; }
.fineness-control { display:flex; align-items:center; gap:8px; }
.fineness-control .converter-input { min-width:0; }
.unit-select { border:0; border-left:1px solid var(--line); outline:0; background:transparent; color:var(--ink-soft); font:inherit; cursor:pointer; }
.k-select { width:100%; padding:10px 0; border-left:0; background:var(--bg); color:var(--ink); color-scheme:light dark; text-align:right; }
.k-select option { background:var(--bg); color:var(--ink); }
.warp-tabs { grid-template-columns:repeat(4,1fr); max-width:640px; }
.yarn-usage-tabs { grid-template-columns:1fr 1fr; }
.price-panel { max-width:680px; margin:0 auto; text-align:left; }
.price-panel > h3,.material-title h3,.net-result h3 { margin:22px 0 12px; color:var(--ink); font-size:21px; }
.price-actions,.material-title { display:flex; align-items:center; justify-content:space-between; margin:24px 0 12px; }
.price-actions h3 { margin:0; color:var(--ink); font-size:22px; }
.price-cards { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.price-cards article { min-height:126px; padding:25px 12px; border-radius:12px; background:var(--bg); text-align:center; }
.price-cards strong { color:#2488f5; font-size:28px; }
.price-cards strong span { margin-left:3px; color:var(--ink); font-size:17px; }
.price-cards p { margin:10px 0 0; color:var(--ink-soft); font-size:15px; }
.price-card--orange { color:#ff6435 !important; }
.price-cards--three { grid-template-columns:repeat(2,1fr); }
.price-cards--three > .price-cards { display:contents; }
.copy-button,.add-material,.remove-material { border:1px solid #2488f5; border-radius:9px; padding:9px 14px; background:#2488f5; color:#fff; font:inherit; cursor:pointer; }
.add-material { display:block; margin:28px auto; border-style:dashed; background:transparent; color:#2488f5; }
.add-material:disabled { opacity:.45; cursor:not-allowed; }
.remove-material { padding:5px 10px; border-color:var(--line); background:var(--bg); color:var(--ink-soft); font-size:13px; }
.net-result { margin-top:22px; }
.metric-card { min-height:146px; padding:30px 16px; border-radius:12px; background:var(--bg); text-align:center; }
.metric-card strong { color:#2488f5; font-size:34px; }
.metric-card--actual strong { color:#ff6435; }
.metric-card strong span { margin-left:4px; color:var(--ink); font-size:20px; }
.metric-card p { margin:10px 0 0; color:var(--ink-soft); font-size:15px; }
.metric-card--rack { grid-column:1 / -1; }
.calc-note { max-width:640px; margin:16px auto 0; padding:0 6px; color:var(--ink-soft); font-size:13px; line-height:1.8; text-align:left; }
@media (max-width:900px) { .app { padding:0 24px; } .grid { grid-template-columns:repeat(3,1fr); } }
@media (max-width:560px) { .app { padding:0 16px; } header { padding:22px 0 16px; } .user-entry { padding:0 10px; } .user-entry span { display:none; } .tool-sections { padding-top:20px; } .tool-section + .tool-section { margin-top:28px; } .tool-section h2 { margin-bottom:14px; font-size:18px; } .grid { grid-template-columns:repeat(2,1fr); gap:12px; } .item { min-height:142px; } .sheet-body { padding:36px 16px; } .converter-row,.calc-result { grid-template-columns:1fr 1.2fr; min-height:58px; padding:0 16px; } .capital-result { padding:22px 16px; font-size:23px; } .production-panel h3 { font-size:20px; } .metric-card { min-height:126px; padding:24px 8px; } .metric-card strong { font-size:29px; } }

/* Workspace layout inspired by the supplied reference. */
:root {
  color-scheme:dark;
  --bg:#1c1d21;
  --surface:#18191d;
  --surface-raised:#22242a;
  --ink:#f2f3f6;
  --ink-soft:#a3abbc;
  --line:#34373e;
  --accent:#b5c9fa;
  --accent-bg:#2e3951;
}
:root[data-theme="dark"] {
  color-scheme:dark;
  --bg:#1c1d21;
  --surface:#18191d;
  --surface-raised:#22242a;
  --ink:#f2f3f6;
  --ink-soft:#a3abbc;
  --line:#34373e;
  --accent:#b5c9fa;
  --accent-bg:#2e3951;
}
:root[data-theme="light"] {
  color-scheme:light;
  --bg:#f7f8fb;
  --surface:#ffffff;
  --surface-raised:#f2f4f9;
  --ink:#242b38;
  --ink-soft:#69758a;
  --line:#dfe3ec;
  --accent:#355baf;
  --accent-bg:#e4ebfa;
}
body { background:#151619; }
.app-shell {
  display:grid;
  grid-template-columns:294px minmax(0,1fr);
  width:100%;
  min-height:100vh;
  margin:0;
  overflow:hidden;
  border:0;
  border-radius:0;
  background:var(--bg);
}
.sidebar {
  display:flex;
  min-width:0;
  padding:38px 26px 30px;
  flex-direction:column;
  border-right:1px solid var(--line);
  background:var(--surface);
}
.brand-title { display:flex; align-items:center; gap:15px; color:var(--ink); font-size:25px; font-weight:700; letter-spacing:.02em; white-space:nowrap; }
.brand-title svg { width:27px; height:27px; flex:none; fill:none; stroke:var(--accent); stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.brand p { margin:16px 0 0; color:var(--ink-soft); font-size:15px; }
.side-nav { display:grid; gap:12px; margin-top:54px; }
.nav-item {
  display:flex;
  width:100%;
  min-height:62px;
  padding:0 18px;
  align-items:center;
  gap:14px;
  border:0;
  border-radius:12px;
  background:transparent;
  color:var(--ink);
  font:inherit;
  font-size:18px;
  text-align:left;
  cursor:pointer;
  transition:background .15s,color .15s;
}
.nav-item svg { width:22px; height:22px; flex:none; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.nav-item:hover { background:var(--surface-raised); }
.nav-item.active { background:var(--accent-bg); color:var(--accent); font-weight:650; }
.nav-item:focus-visible,.item:focus-visible,.bar button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.sidebar-foot { margin:auto 0 0; padding-top:40px; color:var(--ink-soft); font-size:14px; }
.workspace { position:relative; display:flex; min-width:0; flex-direction:column; }
.topbar {
  display:flex;
  height:100px;
  min-height:100px;
  padding:0 44px;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid var(--line);
  background:var(--bg);
}
.workspace-name { color:var(--ink); font-size:18px; font-weight:550; }
.workspace-label { color:var(--ink-soft); font-size:16px; }
.header-actions { gap:20px; }
.theme-toggle { width:36px; height:36px; border-color:var(--line); border-radius:9px; background:transparent; }
.theme-toggle:hover { border-color:var(--accent); }
.page-content { min-height:calc(100vh - 124px); padding:44px 44px 72px; }
.page-view[hidden] { display:none; }
.page-heading { padding-bottom:32px; border-bottom:1px solid var(--line); }
.page-heading h1 { margin:0; color:var(--ink); font-size:34px; font-weight:700; letter-spacing:.01em; line-height:1.3; }
.page-heading p { margin:10px 0 0; color:var(--ink-soft); font-size:16px; }
.tool-sections { padding:34px 0 0; }
.tool-section + .tool-section { margin-top:38px; }
.tool-section h2 { margin-bottom:16px; color:var(--ink); font-size:19px; }
.grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; }
.item {
  min-height:134px;
  padding:20px 12px;
  border-color:var(--line);
  border-radius:12px;
  background:var(--surface);
}
.item svg { width:28px; height:28px; stroke:var(--accent); }
.item span { font-size:15px; letter-spacing:0; white-space:normal; }
.item:hover { border-color:var(--accent); background:var(--accent-bg); box-shadow:0 12px 28px rgba(0,0,0,.12); }
/* Keep the calculator index within the viewport; tool detail pages keep their own spacing. */
.page-content:has(#calculator-page:not([hidden])) { min-height:calc(100vh - 128px); padding-top:26px; padding-bottom:18px; }
#calculator-page .page-heading { padding-bottom:18px; }
#calculator-page .page-heading h1 { font-size:30px; }
#calculator-page .page-heading p { margin-top:5px; font-size:14px; }
#calculator-page .tool-sections { padding-top:18px; }
#calculator-page .tool-section + .tool-section { margin-top:17px; }
#calculator-page .tool-section h2 { margin-bottom:9px; font-size:17px; }
#calculator-page .grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
#calculator-page .item { min-height:clamp(72px,9.1vh,86px); padding:10px 8px; gap:5px; }
#calculator-page .item svg { width:23px; height:23px; }
#calculator-page .item span { font-size:14px; line-height:1.25; }
.sheet {
  position:absolute;
  inset:100px 0 0;
  z-index:5;
  background:var(--bg);
  transform:none;
  transition:none;
  visibility:hidden;
  pointer-events:none;
}
.sheet.open { visibility:visible; pointer-events:auto; }
.sheet-inner { max-width:1100px; }
.bar { height:70px; padding:0 30px; background:var(--bg); }
.bar h2 { margin-right:44px; text-align:left; font-size:20px; }
.sheet-body { padding:42px 30px 70px; }
.converter,.metric-card,.price-cards article { background:var(--surface); }
.price-cards strong,.metric-card strong { color:var(--accent); }
.price-card--orange,.metric-card--actual strong { color:#f6a177 !important; }
.copy-button,.add-material { border-color:var(--accent); background:var(--accent); color:var(--surface); }
.add-material { background:transparent; color:var(--accent); }
.sheet--circular { background:var(--bg); }
.sheet--circular .bar { background:var(--bg); }
@media (max-width:1100px) {
  .app-shell { grid-template-columns:240px minmax(0,1fr); }
  .sidebar { padding-inline:18px; }
  .brand-title { font-size:21px; }
  .nav-item { font-size:16px; }
  .topbar { padding-inline:28px; }
  .page-content { padding-inline:28px; }
  .grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:720px) {
  .app-shell { display:block; width:100%; min-height:100vh; margin:0; border:0; border-radius:0; }
  .sidebar { padding:17px 16px 0; border-right:0; border-bottom:1px solid var(--line); }
  .brand-title { font-size:19px; }
  .brand-title svg { width:23px; height:23px; }
  .brand p,.sidebar-foot { display:none; }
  .side-nav { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:17px 0 10px; }
  .nav-item { min-height:46px; padding:0 6px; justify-content:center; gap:6px; border-radius:9px; font-size:13px; white-space:nowrap; }
  .nav-item svg { width:17px; height:17px; }
  .topbar { height:58px; min-height:58px; padding:0 18px; }
  .workspace-name { font-size:14px; }
  .workspace-label { display:none; }
  .page-content { min-height:calc(100vh - 155px); padding:27px 18px 50px; }
  .page-heading { padding-bottom:24px; }
  .page-heading h1 { font-size:28px; }
  .tool-sections { padding-top:24px; }
  .grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .item { min-height:112px; }
  .sheet { inset:58px 0 0; }
  .bar { height:58px; padding:0 10px; }
  .bar h2 { font-size:17px; }
  .sheet-body { padding:28px 16px 50px; }
  .page-content:has(#calculator-page:not([hidden])) { min-height:0; padding:14px 14px 18px; }
  #calculator-page .page-heading { padding-bottom:14px; }
  #calculator-page .page-heading h1 { font-size:26px; }
  #calculator-page .tool-sections { padding-top:12px; }
  #calculator-page .tool-section + .tool-section { margin-top:10px; }
  #calculator-page .tool-section h2 { margin-bottom:6px; font-size:15px; }
  #calculator-page .grid {
    display:grid;
    grid-auto-flow:column;
    grid-auto-columns:minmax(132px,42%);
    grid-template-columns:none;
    overflow-x:auto;
    overscroll-behavior-x:contain;
    scroll-snap-type:x mandatory;
    scrollbar-width:thin;
    padding-bottom:3px;
  }
  #calculator-page .item { min-height:70px; scroll-snap-align:start; }
}
@media (max-width:720px) and (max-height:650px) {
  .sidebar { padding-top:10px; }
  .side-nav { margin-top:10px; margin-bottom:7px; }
  #calculator-page .page-heading p { display:none; }
  #calculator-page .tool-sections { padding-top:9px; }
}
