/* =======================================================================
 *   Resin.Tools — Base styles (theme-agnostic)
 *   Put theme palettes + per-theme accents in theme.css
 *   ======================================================================= */

:root{
  /* -------------------------------------------------------------------
   *     Core theme tokens (defaults = Dark)
   *     ------------------------------------------------------------------- */
  --bg: #0b0f14;
  --panel: rgba(18,26,35,.88);
  --panel2: rgba(15,22,32,.76);

  --fg:     #c7c1bb; /* near-black text */
  --yellow: #b02323; /* muted gold */
  --orange: #e06c00;

  --text: #eaf2ff;
  --muted: #9bb0c6;
  --title: #f2543f;
  --subtitle: #cfcfcf;

  --border: rgba(255,255,255,.10);
  --border2: rgba(255,255,255,.14);

  --warn: #ffb020;
  --bad: #ff5c5c;
  --ok: #5dff9f;

  --shadow2: 0 8px 20px rgba(0,0,0,.25);
  --radius2: 18px;

  --field-bg: rgba(0,0,0,.20);
  --panelOpen: rgba(18,26,35,.92);
  --chev: rgba(255,255,255,.45);

  /* this is for the APK button */
  --btn-pad-y: 10px;
  --btn-pad-x: 12px;
  --btn-radius: 14px;
  --control-height: 33px;
  --control-radius: 8px;

  /* Common surface tokens */
  --row-bg: rgba(255,255,255,.04);
  --row-border: rgba(255,255,255,.07);
  --row-bg-2: rgba(255,255,255,.03);
  --row-border-2: rgba(255,255,255,.07);

  --readonly-bg: rgba(255,255,255,.06);
  --readonly-border: rgba(255,255,255,.10);
  --footer-height: 56px;      /* baseline footer height */
  --footer-gap: 18px;         /* breathing room above footer */
  --page-bottom-pad: calc(var(--footer-height) + var(--footer-gap) + env(safe-area-inset-bottom));
  --focus-border: rgba(74,163,255,.80);
  --focus-ring: rgba(74,163,255,.16);

  /* -------------------------------------------------------------------
   *     Density tokens (default = Comfort)
   *     ------------------------------------------------------------------- */
  --font-base: 16px;
  --font-small: 12px;
  --font-tiny: 11px;

  --pad-input-y: 8px;
  --pad-input-x: 12px;
  --pad-card: 12px;

  --gap: 10px;
  --row-pad: 6px;

  --radius-input: 14px;
  --radius-row: 16px;

  --toggle-w: 52px;
  --toggle-h: 30px;
  --toggle-knob: 24px;

  --badge-font: 12px;
  --title-size: 14px;
  --summary-pad: 12px;
  --body-pad: 12px;
  --tool-pad: 12px;
  --page-pad: 14px;
  --page-gap: 16px;

  /* -------------------------------------------------------------------
   *     Formula colors (defaults)
   *     ------------------------------------------------------------------- */
  --f-var1: var(--ok);
  --f-var2: var(--warn);
  --f-var3: var(--title);
  --f-const: var(--muted);

  /* -------------------------------------------------------------------
   *     Button scheme tokens (defaults)
   *     ------------------------------------------------------------------- */
  --btn-text: var(--muted);
  --btn-border: rgba(255,255,255,.16);

  --btn-primary-a: rgba(74,163,255,.22);
  --btn-primary-b: rgba(74,163,255,.10);

  --btn-secondary-bg: rgba(255,255,255,.06);
  --btn-secondary-border: rgba(255,255,255,.16);

  --btn-danger-bg: rgba(255,92,92,.12);
  --btn-danger-border: rgba(255,92,92,.28);

  /* -------------------------------------------------------------------
   *     Cross-theme accent tokens (theme.css may override these)
   *     ------------------------------------------------------------------- */
  --bg-glow-a: rgba(74,163,255,.16);
  --bg-glow-b: rgba(93,255,159,.10);

  --card-glow-a: rgba(74,163,255,.14);
  --card-glow-b: rgba(93,255,159,.10);

  --toggle-on-bg: rgba(74,163,255,.22);
  --toggle-on-border: rgba(74,163,255,.45);

  --footer-bg: rgba(11,15,20,.92);
  --footer-border: rgba(255,255,255,.08);

}

/* Spacious: presentation and touch-first spacing. */
:where(html, body)[data-density="spacious"]{
  --font-base: 17px;
  --font-small: 13px;
  --font-tiny: 12px;
  --pad-input-y: 11px;
  --pad-input-x: 14px;
  --pad-card: 16px;
  --gap: 14px;
  --row-pad: 8px;
  --radius-input: 18px;
  --radius-row: 20px;
  --radius2: 22px;
  --toggle-w: 58px;
  --toggle-h: 34px;
  --toggle-knob: 28px;
  --badge-font: 13px;
  --btn-pad-y: 11px;
  --btn-pad-x: 15px;
  --btn-radius: 16px;
  --control-height: 40px;
  --control-radius: 12px;
  --title-size: 16px;
  --summary-pad: 16px;
  --body-pad: 16px;
  --tool-pad: 16px;
  --page-pad: 18px;
  --page-gap: 20px;
}

/* Compact */
:where(html, body)[data-density="compact"]{
  --font-base: 14px;
  --font-small: 10px;
  --font-tiny: 9px;
  --pad-input-y: 6px;
  --pad-input-x: 9px;
  --pad-card: 8px;
  --gap: 7px;
  --row-pad: 3px;
  --radius-input: 10px;
  --radius-row: 12px;
  --radius2: 14px;
  --toggle-w: 46px;
  --toggle-h: 26px;
  --toggle-knob: 20px;
  --badge-font: 10px;
  --btn-pad-y: 6px;
  --btn-pad-x: 9px;
  --btn-radius: 10px;
  --control-height: 30px;
  --control-radius: 7px;
  --title-size: 13px;
  --summary-pad: 9px;
  --body-pad: 9px;
  --tool-pad: 9px;
  --page-pad: 10px;
  --page-gap: 12px;
}

/* Dense */
:where(html, body)[data-density="dense"]{
  --font-base: 12px;
  --font-small: 9px;
  --font-tiny: 8px;
  --pad-input-y: 4px;
  --pad-input-x: 6px;
  --pad-card: 4px;
  --gap: 4px;
  --row-pad: 4px;
  --radius-input: 7px;
  --radius-row: 8px;
  --radius2: 10px;
  --toggle-w: 38px;
  --toggle-h: 20px;
  --toggle-knob: 16px;
  --badge-font: 9px;
  --btn-pad-y: 4px;
  --btn-pad-x: 6px;
  --btn-radius: 7px;
  --control-height: 26px;
  --control-radius: 5px;
  --title-size: 12px;
  --summary-pad: 7px;
  --body-pad: 7px;
  --tool-pad: 7px;
  --page-pad: 7px;
  --page-gap: 8px;
}

/* Maximum Data: prioritizes maximum on-screen information on large displays. */
:where(html, body)[data-density="maximum"]{
  --font-base: 10px;
  --font-small: 8px;
  --font-tiny: 7px;
  --pad-input-y: 2px;
  --pad-input-x: 4px;
  --pad-card: 2px;
  --gap: 2px;
  --row-pad: 1px;
  --radius-input: 4px;
  --radius-row: 5px;
  --radius2: 6px;
  --toggle-w: 32px;
  --toggle-h: 18px;
  --toggle-knob: 14px;
  --badge-font: 8px;
  --btn-pad-y: 3px;
  --btn-pad-x: 5px;
  --btn-radius: 4px;
  --control-height: 22px;
  --control-radius: 4px;
  --title-size: 11px;
  --summary-pad: 5px;
  --body-pad: 5px;
  --tool-pad: 5px;
  --page-pad: 4px;
  --page-gap: 5px;
}

/* =======================================================================
 *   Base layout
 *   ======================================================================= */

*{ box-sizing: border-box; }

body{
  min-height: 100vh;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
  radial-gradient(1200px 600px at 20% -10%, var(--bg-glow-a), transparent 60%),
  radial-gradient(800px 500px at 90% 0%,  var(--bg-glow-b), transparent 55%),
  var(--bg);
  color: var(--text);
  font-size: var(--font-base);
}

main{
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--page-pad) var(--page-pad) calc(24px + var(--page-bottom-pad));
  display: grid;
  gap: var(--page-gap);
}

.workspaceNav,
.workspaceStatusBar{ display: none; }
.workspaceContent{ display: contents; }
.mobileBrand{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 2px 12px 4px;
  border-bottom: 1px solid var(--border);
}
.resinToolsLogo{display:block;width:min(100%,280px);height:auto;color:var(--text)}
.resinToolsLogo .resinToolsWord{fill:currentColor}
.resinToolsLogo .rtBracket{fill:none;stroke:#689d6a;stroke-width:10;stroke-linecap:square;stroke-linejoin:miter}
.resinToolsLogo .rtPellet{fill:#fabd2f}
.resinToolsLogo .rtDivider{fill:#d65d0e}
.resinToolsLogo .resinToolsWord text{font:900 70px/1 "Arial Narrow","Roboto Condensed",Arial,sans-serif;letter-spacing:-3px}
.resinToolsSidebarIcon{display:block;width:110px;height:auto;color:var(--text);overflow:visible}
.resinToolsSidebarIcon .rtInk{fill:currentColor}
.resinToolsSidebarIcon .rtBracket{fill:none;stroke:#689d6a;stroke-width:8}
.resinToolsSidebarIcon .rtPellet{fill:#fabd2f}
:where(html,body)[data-theme="light"] :is(.resinToolsLogo,.resinToolsSidebarIcon),
:where(html,body)[data-theme="mse"] :is(.resinToolsLogo,.resinToolsSidebarIcon),
:where(html,body)[data-theme="gruvbox-light"] :is(.resinToolsLogo,.resinToolsSidebarIcon),
:where(html,body)[data-theme="solarized-light"] :is(.resinToolsLogo,.resinToolsSidebarIcon),
:where(html,body)[data-theme="catppuccin-latte"] :is(.resinToolsLogo,.resinToolsSidebarIcon){
  color:#657784;
}
.workspaceBrandLogo{ display: block; width: min(100%, 196px); height: auto; }
.workspaceBrandLogo path{ stroke-linecap: round; stroke-linejoin: round; }
.workspaceBrandLogo [class^="polynFlow"]{ fill: none; stroke-width: 11; }
.workspaceBrandLogo .polynFlowRed{ stroke: var(--bad); }
.workspaceBrandLogo .polynFlowOrange{ stroke: var(--orange); }
.workspaceBrandLogo .polynFlowYellow{ stroke: var(--warn); }
.workspaceBrandLogo .polynFlowGreen{ stroke: var(--ok); }
.workspaceBrandLogo .polynFlowBlue{ stroke: var(--focus-border); }
.workspaceBrandLogo .polynWord{
  fill: var(--text);
  font: 900 76px/1 ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  letter-spacing: -7px;
}
.workspaceBrandLogo .polynTagline{
  fill: var(--muted);
  font: 800 17px/1 ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  letter-spacing: .8px;
}
.mobileBrand .workspaceBrandLogo{ width: min(100%, 190px); }
.statusPreferences{position:relative;align-self:center;margin-left:auto}
.statusPreferences > summary{display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border:0;border-radius:0;background:transparent;color:var(--text);font-size:20px;line-height:1;cursor:pointer;list-style:none}
.statusPreferences > summary::-webkit-details-marker{display:none}
.statusPreferences > summary:hover,.statusPreferences[open] > summary{background:transparent;color:var(--title)}
.statusPreferences > summary:focus-visible{outline:2px solid var(--focus-border);outline-offset:-3px}
.statusPreferencesPanel{position:absolute;top:calc(100% + 8px);right:0;z-index:60;width:min(390px,calc(100vw - 24px));padding:14px;border:1px solid var(--border2);border-radius:var(--radius-row);background:var(--panelOpen);box-shadow:var(--shadow2)}
.statusPreferencesHead{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin-bottom:12px;padding-bottom:9px;border-bottom:1px solid var(--border)}
.statusPreferencesHead strong{font-size:14px}.statusPreferencesHead small{color:var(--muted);font-size:var(--font-tiny)}

@media (min-width: 901px){
  .mobileBrand{ display: none; }
  main{
    max-width: 1320px;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
  }
  main > .site-header{
    position: relative;
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-start;
    width: 100%;
    height: 74px;
    padding: 0 220px 0 0;
    overflow: hidden;
  }
  main > .site-header svg{
    flex: 0 0 auto;
    width: 100%;
    height: auto;
  }
  main > .site-header .headerWordmark{ display: none; }
  main > .modeBar{
    z-index: 2;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
  }
  .workspaceNav{
    position: sticky;
    top: 14px;
    display: grid;
    grid-column: 1;
    grid-row: 1;
    gap: 5px;
    padding: 5px;
    border: 1px solid transparent;
    border-radius: var(--radius-row);
    background: var(--panel);
    box-shadow: none;
  }
  .workspaceStatusBar{
    position: sticky;
    top: 14px;
    z-index: 5;
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:10px;
    min-height:34px;
    padding:0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-row);
    background: var(--readonly-bg);
    box-shadow: none;
  }
  .workspaceContent{
    display: grid;
    grid-column: 2;
    grid-row: 1;
    gap: var(--page-gap);
    min-width: 0;
  }
  .workspaceStatusItem{
    display:flex;
    align-items:center;
    gap:7px;
    min-height:0;
    padding:0;
    border:0;
    border-radius:0;
    background:transparent;
    line-height:1;
    white-space:nowrap;
  }
  .workspaceStatusItem span{
    color: var(--muted);
    font-size: var(--font-tiny);
  }
  .workspaceStatusItem strong{
    color: var(--text);
    font-size: var(--font-small);
    line-height:1;
  }
  .workspaceNextAction{
    min-width: 0;
    margin-left: auto;
  }
  .workspaceNextAction strong{
    overflow: hidden;
    max-width: 270px;
    text-overflow: ellipsis;
  }
  .workspaceNextAction small{
    display: none;
  }
  .workspaceBrand{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px 12px;
    border-bottom: 1px solid var(--border);
    user-select: none;
  }
  .workspaceNavButton{
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: calc(var(--radius-row) - 4px);
    background: transparent;
    color: var(--muted);
    text-align: left;
    box-shadow: none;
  }
  .workspaceNavButton span{
    display: flex;
    align-items: center;
    gap: 7px;
    color: inherit;
    font-size: 13px;
    font-weight: 850;
  }
  .workspaceNavButton > span::before{
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--muted);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--muted) 14%, transparent);
    flex: 0 0 auto;
  }
  .workspaceNavButton[data-status="info"] > span::before{
    background: var(--focus-border);
    box-shadow: 0 0 0 2px var(--focus-ring);
  }
  .workspaceNavButton[data-status="ok"] > span::before{
    background: var(--ok);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 16%, transparent);
  }
  .workspaceNavButton[data-status="warn"] > span::before{
    background: var(--warn);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 16%, transparent);
  }
  .workspaceNavButton[data-status="bad"] > span::before{
    background: var(--bad);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 16%, transparent);
  }
  .workspaceNavButton small{
    justify-self: start;
    overflow: hidden;
    max-width: 100%;
    padding: 2px 7px;
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    border-radius: 999px;
    color: var(--muted);
    font-size: var(--font-tiny);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .workspaceNavButton[data-status="info"] small{ color: var(--focus-border); }
  .workspaceNavButton[data-status="ok"] small{ color: var(--ok); }
  .workspaceNavButton[data-status="warn"] small{ color: var(--warn); }
  .workspaceNavButton[data-status="bad"] small{ color: var(--bad); }
  .workspaceNavButton:hover{
    border-color: var(--border2);
    background: var(--row-bg);
  }
  .workspaceNavButton.active{
    border-color: var(--focus-border);
    background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
    color: var(--title);
  }
  .workspaceContent > .workspacePanel{
    min-width: 0;
  }
  .workspaceContent > .workspacePanel:not(.desktop-active){ display: none !important; }
  .workspaceContent > .workspacePanel.card,
  .workspaceContent > .workspacePanel.card[open]{
    border: 1px solid transparent;
    background: var(--panel);
    box-shadow: none;
  }
  .workspaceContent > .workspacePanel > summary{
    padding: 3px 0 12px;
    border-bottom: 1px solid var(--border);
    cursor: default;
  }
  .workspaceContent > .workspacePanel > summary .chev{ display: none; }
  .workspaceContent > .workspacePanel > summary .layerTitle{ font-size: 18px; }
  .workspaceContent > .workspacePanel > summary .layerMeta{
    margin-top: 3px;
    font-size: 13px;
  }
  .workspaceContent > details.block.workspacePanel[open] > summary .pill.summaryStatus{ display: inline-flex; }
  .workspaceContent > .workspacePanel > .blockBody{ padding: 14px 0 0; }
  .footerBar{ display: none; }
}

.lineSyncStatusItem strong[data-state="synced"]{ color: var(--ok); }
.lineSyncStatusItem strong[data-state="pending"],
.lineSyncStatusItem strong[data-state="offline"],
.lineSyncStatusItem strong[data-state="conflict"]{ color: var(--warn); }
.lineSyncStatusItem strong[data-state="error"]{ color: var(--bad); }

.lineSyncPanel{ overflow: visible; }
.lineSyncMetrics{ display:flex; flex-wrap:wrap; gap:8px; }
.lineSyncMetrics span{
  padding:5px 9px;
  border:1px solid var(--row-border);
  border-radius:999px;
  background:var(--row-bg);
  color:var(--muted);
  font-size:var(--font-small);
}
.lineSyncMetrics strong{ color:var(--text); }
.lineSyncJoin{
  display:grid;
  grid-template-columns:minmax(150px, 1fr) auto minmax(110px, auto);
  gap:10px;
  align-items:end;
}
.lineSyncCode{
  min-height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 14px;
  border:1px dashed var(--border);
  border-radius:var(--radius-input);
  font-size:1.25rem;
  font-weight:900;
  letter-spacing:.14em;
  color:var(--focus-border);
}
.lineSyncMembers{
  padding:12px;
  border:1px solid var(--border);
  border-radius:var(--radius-row);
  background:var(--panel2);
}
.lineSyncMember{
  display:grid;
  grid-template-columns:minmax(120px,1fr) auto auto;
  gap:8px;
  align-items:center;
  padding:8px 0;
  border-bottom:1px solid var(--border);
}
.lineSyncMember:last-child{ border-bottom:0; }
.lineSyncMemberActions{ display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.lineSyncMemberActions button{
  width:auto;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border-radius:var(--control-radius);
  font-size:var(--font-small);
}
.lineSyncConflictDialog{
  max-width:560px;
  color:var(--text);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius-row);
  box-shadow:var(--shadow2);
}
.lineSyncConflictDialog::backdrop{ background:rgba(0,0,0,.48); }
.mobileSyncLabel,
.mobileSyncOnly{ display: none; }

@media (max-width: 900px){
  .lineSyncPanel .desktopSyncOnly,
  .lineSyncPanel .desktopSyncLabel{ display: none !important; }
  .lineSyncPanel .mobileSyncLabel{ display: inline; }
  .lineSyncPanel .mobileSyncOnly{ display: block; }
  .lineSyncPanel:not(.mobileHasWorkspaces) .lineSyncCurrentLineField{ display: none; }
  .lineSyncPanel:not(.mobileHasLine) .lineSyncActionBar{ display: none; }
  .lineSyncPanel .lineSyncJoin{ display: none; }
  .lineSyncPanel .lineSyncJoin.mobileJoinVisible{
    display: grid;
    grid-template-columns: 1fr;
  }
  .lineSyncPanel .lineSyncJoin.mobileJoinVisible > div:first-child,
  .lineSyncPanel .lineSyncJoin.mobileJoinVisible .lineSyncCode{ grid-column: auto; }
}

@media (max-width: 720px){
  .lineSyncJoin{ grid-template-columns:1fr 1fr; }
  .lineSyncJoin > div:first-child,
  .lineSyncCode{ grid-column:1 / -1; }
  .lineSyncMember{ grid-template-columns:1fr; }
  .lineSyncMemberActions{ justify-content:flex-start; }
}

/* Small utility classes */
.mt10{ margin-top: 10px; }
.mt14{ margin-top: 14px; }
.gap10{ display: grid; gap: 10px; }
.hide{ display: none !important; }

/* =======================================================================
 *   Header image
 *   ======================================================================= */
.site-header[hidden]{ display: none !important; }
.site-header{
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.25rem 1rem; /* slightly less than 3rem */
}

/* Works for inline <svg class="logo"> OR <img class="logo"> */
.site-header .logo{
  display: block;      /* avoids baseline gaps */
  width: min(92vw, 900px);
  height: auto;
}

@media (max-width: 520px){
  .site-header{
    padding: 1.25rem 0.75rem;
  }
  .site-header .logo{
    width: 96vw;       /* lets it fill the screen */
    max-width: none;   /* remove the cap on small screens */
  }
}



/* =======================================================================
 *   Cards
 *   ======================================================================= */

.card{
  position: relative;
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: var(--radius2);
  padding: var(--pad-card);
  box-shadow: none;
  overflow: hidden;
}
.card::before{ display: none; }
.card > *{ position: relative; }

/* Typography helpers */
.layerTitle{
  font-weight: 900;
  font-size: var(--title-size);
  white-space: nowrap;
  color: var(--title, var(--text));
}
.layerMeta{
  color: var(--subtitle, var(--muted));
  font-size: var(--font-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted{ color: var(--muted); font-size: var(--font-small); }
.tiny{ font-size: var(--font-tiny); color: var(--muted); margin-top: 6px; line-height: 1.35; }
.mono{
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Documentation intro text (above nested cards) */
.docIntro{
  padding: 10px 12px 6px;
  font-size: var(--font-small);
  line-height: 1.45;
  color: var(--muted);
}

.docIntro + .blockBody{
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
/* =======================================================================
 *   Forms
 *   ======================================================================= */

label{ display: block; font-size: var(--font-small); color: var(--muted); margin-bottom: 6px; }

input, select, textarea{
  width: 100%;
  padding: var(--pad-input-y) var(--pad-input-x);
  border-radius: var(--radius-input);
  border: 1px solid var(--border2);
  background: var(--field-bg);
  color: var(--text);
  outline: none;
  font-size: var(--font-base);
  transition: box-shadow .12s ease, border-color .12s ease, transform .06s ease;
}

/* Sleek underline fields: compact without shrinking their readable text. */
input:not([type="checkbox"]):not([type="radio"]),
select{
  min-height:var(--control-height);
  padding:min(5px, var(--pad-input-y)) 2px;
  border-width:0 0 1px;
  border-radius:0;
  background:transparent;
}
select{ padding-right:24px; }

input:focus, select:focus, textarea:focus{
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus{
  box-shadow:0 2px 0 var(--focus-border);
}
input[aria-invalid="true"]{
  border-color: var(--bad);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent);
}
input:not([type="checkbox"]):not([type="radio"])[aria-invalid="true"]{
  box-shadow:0 2px 0 var(--bad);
}

textarea{ min-height: 120px; resize: vertical; }

/* Read-only inputs should NOT look editable */
input[readonly]{
  opacity: 0.75;
  cursor: not-allowed;
  background: transparent;
  border-color: var(--readonly-border);
  box-shadow: none;
}
input[readonly]:focus{
  border-color: var(--readonly-border);
  box-shadow: none;
}

.resinAutocomplete{
  position: fixed;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-input);
  background: var(--panelOpen);
  box-shadow: var(--shadow2);
}
.resinAutocompleteOption{
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--radius-input) - 4px);
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: var(--font-small);
  text-align: left;
}
.resinAutocompleteOption:hover,
.resinAutocompleteOption.active{
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color: var(--text);
}

/* =======================================================================
 *   Grids
 *   ======================================================================= */

.grid3{ display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px){ .grid3{ grid-template-columns: 1.2fr 1fr 1fr; } }

.grid2{ display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px){ .grid2{ grid-template-columns: 1fr 1fr; } }

.gridAuto{ display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px){ .gridAuto{ grid-template-columns: repeat(3, 1fr); } }

.setupSection + .setupSection{ margin-top: 18px; }
.setupSectionTitle{
  margin: 0 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
}
.setupSectionIntro{ margin:-3px 0 12px;color:var(--muted);font-size:var(--font-small); }
.setupFields{ display: grid; gap: var(--gap); grid-template-columns: 1fr; }
.setupNaming{ margin-top: var(--gap); max-width: 320px; }
.setupPreferenceFields{ display:grid;gap:10px;grid-template-columns:repeat(2,minmax(0,1fr)); }
.fieldRequirement{ display:block;margin-top:2px;color:var(--muted);font-size:var(--font-tiny);font-weight:600; }
.fieldRequirement{ color:var(--warn); }
@media (min-width: 720px){
  .setupFields{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width:600px){.setupPreferenceFields{grid-template-columns:1fr}}

/* =======================================================================
 *   Badges / pills
 *   ======================================================================= */

.pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--muted);
  font-size: var(--font-small);
  white-space: nowrap;
}

/* TEMP: hide right-side card labels */
details.block > summary .pill{ display: none; }
details.block:not([open]) > summary .summaryStatus{ display: inline-flex; }

.summaryStatus{
  max-width: 52%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summaryStatus.badge-ok{
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  font-weight: 700;
}

.pill.badge-warn{
  border-color: color-mix(in srgb, var(--warn) 55%, transparent);
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--text);
  font-weight: 650;
}

@media (max-width: 600px){
  .summaryStatus{ max-width: 48%; }
}

/* =======================================================================
 *   Status box
 *   ======================================================================= */

.status{
  margin-top: 10px;
  border-left: 4px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
}
.status.bad{
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}
.status.ok{
  border-left-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.status ul{ margin: 6px 0 0 0; padding-left: 18px; }
.statusTitle{ margin-bottom:6px; font-weight:950; }

/* =======================================================================
 *   Details blocks
 *   ======================================================================= */

details.block{
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius2);
  overflow: hidden;
  background: var(--panel2);
  box-shadow: none;
}
details.block[open]{ background: var(--panelOpen); }

/* Make nested blocks inside a card always span full width */
.blockBody > details.block{
  width: 100%;
  grid-column: 1 / -1;
  background: var(--readonly-bg);
}
.blockBody > details.block[open]{ background: var(--readonly-bg); }

summary{
  list-style: none;
  cursor: pointer;
  padding: var(--summary-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}
summary::-webkit-details-marker{ display: none; }

.sumLeft{ display: flex; align-items: center; gap: 10px; min-width: 0; }
.summaryText{ min-width:0; }
.nestedLayerTitle{ font-size:var(--font-small); }

.chev{
  width: 15px; height: 15px;
  border-right: 2px solid var(--chev);
  border-bottom: 2px solid var(--chev);
  transform: rotate(-45deg);
  transition: transform .15s ease, border-color .12s ease;
  flex: 0 0 auto;
  margin-left: 2px;
}
summary:hover .chev{ border-color: var(--focus-border); }
details[open] > summary .chev{ transform: rotate(45deg); }

.blockBody{ padding: 0 var(--body-pad) var(--body-pad); display: grid; gap: var(--gap); }

/* Small copy chip button */
.copyBtn{
  width: auto;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border-radius:var(--control-radius);
  border: 1px solid var(--btn-border);
  background: var(--btn-secondary-bg);
  color: var(--btn-text);
  font-weight: 900;
  font-size: var(--font-small);
  cursor: pointer;
  box-shadow: none;
  flex: 0 0 auto;
}

.hr{ height: 1px; background: var(--border); margin: 12px 0; }



/* =======================================================================
 *   Setup toggles
 *   ======================================================================= */


/* Setup toggle row (Line 9 hopper naming, etc.) */
.setupToggleRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--row-bg-2);
  border: 1px solid var(--row-border-2);
}

.setupToggleText{ min-width: 0; }
.setupToggleTitle{
  font-weight: 850;
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}
.setupToggleMeta{
  margin-top: 4px;
}
.hopperNamingChoice{
  display:inline-flex;
  flex:0 0 auto;
  overflow:hidden;
  border:1px solid var(--btn-secondary-border);
  border-radius:var(--control-radius);
  background:var(--btn-secondary-bg);
}
.hopperNamingChoice button{
  width:auto;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border:0;
  border-right:1px solid var(--btn-secondary-border);
  border-radius:0;
  background:transparent;
  color:var(--muted);
  font-size:var(--font-small);
  white-space:nowrap;
  box-shadow:none;
}
.hopperNamingChoice button:last-child{ border-right:0; }
.hopperNamingChoice button.active{
  background:linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color:var(--text);
}
.hopperNamingChoice button:focus-visible{
  position:relative;
  z-index:1;
  outline:2px solid var(--focus-border);
  outline-offset:-2px;
}

/* Make it stack nicely on small screens */
@media (max-width: 520px){
  .setupToggleRow{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .setupToggleRow .trackWrap{
    justify-content: space-between !important;
    width: 100%;
  }
  .hopperNamingChoice{
    align-self:stretch;
    width:100%;
  }
  .hopperNamingChoice button{ flex:1 1 50%; }
}
/* =======================================================================
 *   Hopper rows
 *   ======================================================================= */

.hopperList{ display: grid; gap: 10px; }

.hopperRow{
  display: grid;
  gap: calc(var(--gap) + 2px);
  padding: max(4px, var(--row-pad));
  border-radius: var(--radius-row);
  background: var(--row-bg);
  border: 1px solid var(--row-border);
  align-items: center;
  grid-template-columns: auto minmax(140px, 1fr) 88px 120px;
}

.hopperRow input{
  padding:
  max(4px, calc(var(--pad-input-y) - 2px))
  max(6px, calc(var(--pad-input-x) - 4px));
  font-size: var(--font-small);
}

@media (max-width: 520px){
  .hopperRow{
    grid-template-columns: auto minmax(120px, 1fr) 58px 55px;
    gap: 6px;
  }
  .hopperRow .trackLabel{ display: none; }
}

.splitsBulkModeBar{
  display: flex;
  justify-content: flex-end;
}
.splitsBulkModeBar button{
  padding:5px 9px;
  font-size: var(--font-small);
}
.splitsBulkBar{
  position:sticky;
  top:54px;
  z-index:7;
  display: grid;
  grid-template-columns:minmax(180px,1fr) minmax(150px,.7fr) minmax(180px,auto);
  gap: var(--gap);
  align-items: end;
  padding: 10px;
  border: 1px solid var(--row-border);
  border-radius: var(--radius-row);
  background: var(--readonly-bg);
}
.splitsBulkSteps{grid-column:1/-1;display:flex;align-items:center;gap:18px;padding-bottom:8px;border-bottom:1px solid var(--row-border)}
.splitsBulkSteps span{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:var(--font-small)}
.splitsBulkSteps b{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:999px;background:var(--btn-primary-a);color:var(--title);font-size:var(--font-tiny)}
.splitsBulkField{ margin: 0; }
.splitsBulkField > span:first-child{
  display: block;
  margin-bottom: 6px;
}
.splitsBulkPctInput{
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.splitsBulkPctInput > span{
  color: var(--muted);
  font-size: var(--font-small);
}
.splitsBulkApply{display:grid;align-content:end;gap:6px}
.splitsBulkApply button{width:100%}
.splitsBulkActions{grid-column:1/-1;display:flex;align-items:center;gap:12px;padding-top:4px;border-top:1px solid var(--row-border)}
.splitsBulkActions .bulkTextAction{width:auto;min-height:0;padding:3px 2px;border:0;background:transparent;color:var(--muted);box-shadow:none}
.splitsBulkActions .bulkTextAction:hover{color:var(--title);text-decoration:underline}
.splitsBulkActions .danger{margin-left:auto}
.splitsBulkNote{grid-column:1/-1;color:var(--muted)}
.splitsSelectionStatus{
  min-height: 1.2em;
}
.splitsSelectionStatus.ok{ color: var(--ok); }
.splitsSelectionStatus.warn{ color: var(--warn); }
.splitsMatrixActions{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:28px}
.splitsMatrixActionInfo{position:relative;display:flex;align-items:center;gap:8px;min-width:0}
.splitsInfo{position:relative}
.splitsInfo > summary{display:grid;place-items:center;width:24px;height:24px;border:0;border-radius:50%;background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer;list-style:none}
.splitsInfo > summary::-webkit-details-marker{display:none}
.splitsInfo > summary:hover,.splitsInfo[open] > summary{color:var(--title);background:var(--field-bg)}
.splitsInfo > summary:focus-visible{outline:2px solid var(--focus-border);outline-offset:1px}
.splitsInfoPanel{position:absolute;top:calc(100% + 6px);left:0;z-index:20;width:min(390px,calc(100vw - 48px));padding:10px 12px;border:1px solid var(--border2);border-radius:var(--control-radius);background:var(--panelOpen);color:var(--muted);font-size:var(--font-small);box-shadow:var(--shadow2)}
.splitsInfoPanel p{margin:0}.splitsInfoPanel p+p{margin-top:7px}.splitsInfoPanel strong{color:var(--text)}
#splitsArea{gap:6px}

.splitsMatrixSummary{
  padding: 2px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 850;
}
.splitsMatrixSummary.ok,
.splitColumnTotal.ok{ color: var(--ok); }
.splitsMatrixSummary.warn,
.splitColumnTotal.warn{ color: var(--warn); }

.splitsMobileLayerNav{ display: none; }

.splitsMatrixScroll{
  overflow-x: auto;
  border: 1px solid var(--row-border);
  border-radius: var(--radius-row);
  background: transparent;
}
.splitsMatrix{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.splitsMatrix th,
.splitsMatrix td{
  padding: 8px;
  border-right:1px solid color-mix(in srgb,var(--row-border) 64%,transparent);
  border-bottom: 1px solid var(--row-border-2);
}
.splitsMatrix tr:last-child > *{ border-bottom: 0; }
.splitsMatrix tr > *:last-child{ border-right: 0; }
#splitsArea:not(.bulk-editing) .splitsMatrix tr > :first-child{display:none}
.splitsMatrix thead th{
  min-width: 164px;
  padding-top:6px;
  padding-bottom:6px;
  vertical-align: top;
  background:color-mix(in srgb,var(--panelOpen) 72%,transparent);
}
.splitsMatrix th:first-child{
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 64px;
  width: 64px;
  background: var(--panelOpen);
  text-align: center;
}
.splitLayerMain{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:1px;
}
.splitLayerTitle{
  width: auto;
  padding: 4px 2px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size:20px;
  line-height:1;
  font-weight: 950;
  text-align: center;
  cursor: default;
}
.splitLayerPct{
  display:flex;
  align-items: center;
  gap:1px;
  margin:0;
}
.splitLayerPct input{
  width:32px;
  min-width:32px;
  padding:4px 3px;
  border-color:transparent;
  background:transparent;
  box-shadow:none;
  color:var(--muted);
  font-size:var(--font-small);
  font-variant-numeric:tabular-nums;
  text-align:right;
}
.splitLayerPct input:hover,.splitLayerPct input:focus{border-color:var(--border2);background:var(--field-bg)}
.splitLayerPct span,
.splitLayerMeta{
  color: var(--muted);
  font-size: var(--font-small);
}
.splitLayerMeta{ margin-top: 5px; text-align: center; }
.splitColumnTotal{
  margin-top: 5px;
  min-height: 1.2em;
  font-size: var(--font-tiny);
  text-align: center;
}
.splitCopyBtn{
  width:auto;
  min-height:0;
  margin:4px auto 0;
  padding:2px 5px;
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:var(--font-tiny);
  opacity:.62;
  box-shadow:none;
}
.splitCopyBtn:hover,.splitCopyBtn:focus-visible{background:transparent;color:var(--title);opacity:1;text-decoration:underline}
.splitRowHeader{
  color: var(--text);
  font-weight: 950;
}
.splitRowCorner{
  font-size:var(--font-tiny);
  line-height:1.15;
  white-space:normal;
}
.splitRowSelect{
  width: 100%;
  padding: 7px 8px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  cursor: default;
}
.splitMatrixCell{
  min-width: 164px;
  background: transparent;
  transition: background .12s ease, box-shadow .12s ease;
}
.splitsMatrix tbody tr:nth-child(even) .splitMatrixCell{background:color-mix(in srgb,var(--row-bg-2) 55%,transparent)}
.splitsMatrix tbody tr:hover .splitMatrixCell:not(.selected){background:color-mix(in srgb,var(--focus-ring) 34%,var(--row-bg-2))}
.splitsMatrix tbody .splitMatrixCell.tracked:not(.selected){
  background:color-mix(in srgb,var(--focus-ring) 52%,transparent);
  box-shadow:inset 3px 0 0 color-mix(in srgb,var(--title) 78%,var(--focus-border));
}
.splitsMatrix td.splitMatrixCell{padding:4px 6px}
.splitCellHeader{
  display:flex;
  align-items:center;
  gap:5px;
  min-height:15px;
  margin-bottom:1px;
  color:var(--muted);
  font-size:var(--font-tiny);
  font-weight:850;
  line-height:1;
}
.splitCellHopperName{ letter-spacing:.02em; }
.splitMatrixCell:not(.has-resin) .splitCellHopperName{opacity:.72}
.splitMatrixCell.selected{
  background: var(--btn-primary-a);
  box-shadow: inset 0 0 0 2px var(--focus-border);
}
.splitCellEditor{
  display:grid;
  grid-template-columns:minmax(78px,1fr) auto;
  gap:7px;
  align-items:center;
}
.splitCellTop{
  display:grid;
  grid-template-columns: minmax(0,1fr);
  gap: 5px;
  align-items: center;
}
.splitCellSelector{
  display: none;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
}
.bulk-editing .splitCellTop{
  grid-template-columns: 18px minmax(0,1fr);
}
.bulk-editing .splitCellSelector{ display: block; }
.bulk-editing .splitLayerTitle,
.bulk-editing .splitRowSelect{
  border-color:transparent;
  background:transparent;
  cursor: pointer;
}
.bulk-editing .splitRowSelect{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}
.bulk-editing .splitRowSelect::before{
  content:"";
  display:grid;
  place-items:center;
  width:14px;
  height:14px;
  flex:0 0 14px;
  border:1px solid var(--border-strong);
  border-radius:3px;
  background:var(--input-bg);
  color:var(--btn-text);
  font-family:system-ui,sans-serif;
  font-size:11px;
  font-weight:900;
  line-height:1;
}
.bulk-editing .splitRowSelect.partiallySelected::before{
  content:"−";
  border-color:var(--focus-border);
  background:var(--focus-ring);
}
.bulk-editing .splitRowSelect.selected::before{
  content:"✓";
  border-color:var(--focus-border);
  background:var(--focus-border);
  color:#fff;
}
.bulk-editing .splitLayerTitle:hover,.bulk-editing .splitRowSelect:hover{background:var(--row-bg-2);color:var(--title)}
.bulk-editing .splitLayerTitle.selected,
.bulk-editing .splitRowSelect.selected{
  border-color: var(--focus-border);
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color: var(--title);
}
.bulk-editing .splitLayerTitle.partiallySelected,
.bulk-editing .splitRowSelect.partiallySelected{
  border-color: color-mix(in srgb, var(--focus-border) 55%, var(--border));
  background: color-mix(in srgb, var(--focus-ring) 55%, transparent);
}
.bulk-editing .splitCopyBtn,.bulk-editing .splitTrackControl,.bulk-editing .splitsInfo{display:none}
.bulk-editing .splitMatrixCell .resinNameInput:disabled,.bulk-editing .splitMatrixCell .splitInput:disabled{opacity:.52;color:var(--muted);cursor:default}
.splitMatrixCell .resinNameInput{
  height:22px;
  min-height:22px;
  max-height:22px;
  padding:0 2px;
  border-color:transparent;
  background:transparent;
  box-shadow:none;
  color:var(--muted);
  font-size:calc(var(--font-small) + 2px);
  font-weight:700;
  line-height:21px;
  letter-spacing:.01em;
}
.splitMatrixCell.has-resin .resinNameInput{
  color:var(--text);
  font-weight:900;
}
.splitMatrixCell .resinNameInput:focus{
  border-color:var(--border2);
  background:var(--field-bg);
}
.splitMatrixCell.empty .splitCellHopperName{color:color-mix(in srgb,var(--muted) 72%,transparent)}
.splitMatrixCell.empty .resinNameInput:not(:focus),.splitMatrixCell.empty .splitPctControl input:not(:focus){border:0;background:transparent;box-shadow:none}
.splitMatrixCell.empty .splitPctControl{opacity:.62}
.splitMatrixCell.empty .splitPctControl > span{visibility:hidden}
.splitCellControls{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:4px;
  margin:0;
}
.splitPctControl{
  display:flex;
  align-items:center;
  gap:2px;
  min-width: 0;
  margin: 0;
}
.splitPctControl input{
  width:40px;
  height:22px;
  min-height:22px;
  max-height:22px;
  min-width: 0;
  padding:0 3px;
  border-color:transparent;
  background:transparent;
  box-shadow:none;
  color:var(--muted);
  text-align:right;
  font-size:calc(var(--font-small) + 3px);
  line-height:21px;
  font-variant-numeric:tabular-nums;
}
.splitPctControl input:hover,.splitPctControl input:focus{border-color:var(--border2);background:var(--field-bg);color:var(--text)}
.splitPctControl input:read-only{color:color-mix(in srgb,var(--muted) 78%,transparent)}
.splitPctControl > span{
  color: var(--muted);
  font-size:calc(var(--font-small) + 3px);
}
.splitTrackControl{
  display:inline-flex;
  align-items:center;
  margin:0;
  color: var(--muted);
  white-space: nowrap;
}
.splitTrackButton{
  display: inline-grid;
  place-items: center;
  width:23px;
  height:23px;
  min-height:23px;
  margin: 0;
  padding: 0;
  border:0;
  border-radius: 5px;
  background:transparent;
  color:var(--muted);
  opacity:.52;
  box-shadow: none;
}
.splitTrackButton svg{
  width:19px;
  height:19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.splitTrackButton:hover{
  background:var(--field-bg);
  color: var(--title);
  opacity:1;
}
.splitTrackButton:focus-visible{
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}
.splitTrackButton.active{
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color: var(--title);
  opacity:1;
}
@media (hover:hover){
  .splitMatrixCell.empty .splitTrackButton:not(.active){opacity:0}
  .splitMatrixCell.empty:hover .splitTrackButton,.splitMatrixCell.empty:focus-within .splitTrackButton{opacity:1}
}
@media (max-width: 700px){
  .splitsBulkBar{top:38px}
  .splitsBulkSteps{align-items:flex-start;flex-direction:column;gap:5px}
  .splitsMatrixActions{align-items:flex-start}.splitsMatrixActionInfo{align-items:flex-start;flex-direction:column;gap:2px}
  .splitsMobileLayerNav{
    position: sticky;
    top: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(var(--mobile-layer-count, 4), minmax(44px, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--row-border);
    border-radius: 999px;
    background: var(--panel);
    box-shadow: 0 5px 12px rgba(0,0,0,.22);
  }
  .splitsMobileLayerButton{
    min-width: 0;
    padding: 8px 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
  }
  .splitsMobileLayerButton.active{
    background: linear-gradient(180deg,var(--btn-primary-a),var(--btn-primary-b));
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--focus-border);
  }
  .splitsMatrixScroll{ overflow-x: hidden; }
  .splitsMatrix{ table-layout: fixed; }
  .splitsMatrix [data-layer-column]{ display: none; }
  .splitsMatrix [data-layer-column].mobile-layer-active{ display: table-cell; }
  .splitsMatrix thead th{ min-width: 0; }
  .splitsMatrix th:first-child{
    min-width: 52px;
    width: 52px;
  }
  .splitMatrixCell{ min-width: 0; }
  .splitsBulkBar{ grid-template-columns: 1fr; align-items: stretch; }
  .splitsSelectionStatus{ grid-column: 1; }
  .splitsBulkActions{display:grid;grid-template-columns:1fr 1fr}
  .splitsBulkActions .danger{grid-column:1/-1;margin-left:0}
}

.hopperBadge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--readonly-border);
  background: var(--readonly-bg);
  font-weight: 950;
  font-size: var(--badge-font);
  width: fit-content;
}

.resinNameInput{ font-size: var(--font-base); }
.splitInput{ font-size: var(--font-base); text-align: right; }

.trackWrap{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  user-select: none;
}
.trackLabel{ font-size: var(--font-small); color: var(--muted); white-space: nowrap; }
.resultsToggleControls{ justify-content:flex-start; flex-wrap:wrap; }

.toggle{
  position: relative;
  width: var(--toggle-w);
  height: var(--toggle-h);
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 24%, transparent);
  cursor: pointer;
  flex: 0 0 auto;
}
.toggle::after{
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: var(--toggle-knob);
  height: var(--toggle-knob);
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 82%, var(--panel));
  transition: transform .15s ease;
}
.toggle.on{
  background: var(--toggle-on-bg);
  border-color: var(--toggle-on-border);
}
.toggle.on::after{
  transform: translateX(calc(var(--toggle-w) - var(--toggle-knob) - 6px));
}

/* =======================================================================
 *   Weights
 *   ======================================================================= */

.weightsGrid{ display: grid; gap: var(--gap); }
.weightsBulkBar{
  display: grid;
  grid-template-columns:minmax(180px,1fr) minmax(180px,auto);
  gap: var(--gap);
  align-items: end;
  padding: 10px;
  border: 1px solid var(--row-border);
  border-radius: var(--radius-row);
  background: var(--readonly-bg);
}
.weightsBulkSteps{grid-column:1/-1;display:flex;align-items:center;gap:18px;padding-bottom:8px;border-bottom:1px solid var(--row-border)}
.weightsBulkSteps span{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:var(--font-small)}
.weightsBulkSteps b{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:999px;background:var(--btn-primary-a);color:var(--title);font-size:var(--font-tiny)}
.weightsBulkField{ margin: 0; }
.weightsBulkField > span:first-child{display:block;margin-bottom:6px}
.weightsInputWithUnit{
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.weightsInputWithUnit > span{
  color: var(--muted);
  font-size: var(--font-small);
}
.weightsBulkApply{display:grid;align-content:end;gap:6px}
.weightsBulkApply button{width:100%}
.weightsBulkActions{grid-column:1/-1;display:flex;align-items:center;gap:12px;padding-top:4px;border-top:1px solid var(--row-border)}
.weightsBulkActions .bulkTextAction{width:auto;min-height:0;padding:3px 2px;border:0;background:transparent;color:var(--muted);box-shadow:none}
.weightsBulkActions .bulkTextAction:hover{color:var(--title);text-decoration:underline}
.weightsBulkNote{grid-column:1/-1;color:var(--muted)}
.weightsSelectionStatus{min-height:1.2em}

.weightsMatrixScroll{
  overflow-x: auto;
  border: 1px solid var(--row-border);
  border-radius: var(--radius-row);
  background: transparent;
}
.weightsMatrix{
  width: 100%;
  min-width: 520px;
  border-collapse: separate;
  border-spacing: 0;
}
.weightsMatrix th,
.weightsMatrix td{
  padding: 7px;
  border-right: 1px solid var(--row-border-2);
  border-bottom: 1px solid var(--row-border-2);
  text-align: center;
}
.weightsMatrix tr:last-child > *{ border-bottom: 0; }
.weightsMatrix tr > *:last-child{ border-right: 0; }
.weightsMatrix thead th{
  background: transparent;
  color: var(--text);
}
.weightsMatrix th:first-child{
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 76px;
  background:var(--panelOpen);
}
.weightsRowCorner{font-size:var(--font-tiny);line-height:1.15;white-space:normal}
.weightsSelectHeader{
  width: 100%;
  padding: 7px 8px;
  border-color:transparent;
  background:transparent;
  box-shadow: none;
  white-space: nowrap;
}
.weightsSelectHeader:hover{background:var(--row-bg-2);color:var(--title)}
.weightsMatrix tbody th .weightsSelectHeader{display:flex;align-items:center;justify-content:center;gap:7px}
.weightsMatrix tbody th .weightsSelectHeader::before{
  content:"";display:grid;place-items:center;width:14px;height:14px;flex:0 0 14px;
  border:1px solid var(--border-strong);border-radius:3px;background:var(--input-bg);
  color:var(--btn-text);font-family:system-ui,sans-serif;font-size:11px;font-weight:900;line-height:1;
}
.weightsMatrix tbody th .weightsSelectHeader.partiallySelected::before{content:"−";border-color:var(--focus-border);background:var(--focus-ring)}
.weightsMatrix tbody th .weightsSelectHeader.selected::before{content:"✓";border-color:var(--focus-border);background:var(--focus-border);color:#fff}
.weightsSelectHeader.selected{
  border-color: var(--focus-border);
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color: var(--title);
}
.weightsSelectHeader.partiallySelected{
  border-color: color-mix(in srgb, var(--focus-border) 55%, var(--border));
  background: color-mix(in srgb, var(--focus-ring) 55%, transparent);
}
.weightsMatrixCell{
  min-width: 130px;
  background:transparent;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}
.weightsMatrix tbody tr:nth-child(even) .weightsMatrixCell{background:color-mix(in srgb,var(--row-bg-2) 55%,transparent)}
.weightsMatrixCell.selected{
  background: var(--toggle-on-bg);
  box-shadow: inset 0 0 0 2px var(--focus-border);
}
.weightsCellSelector{
  width: 18px;
  height: 18px;
  margin: 0 6px 0 0;
  padding: 0;
  display: inline-block;
  vertical-align: middle;
}
.weightsMatrixCell .weightsInputWithUnit{
  display: inline-grid;
  width: calc(100% - 30px);
  vertical-align: middle;
}
.weightsMatrixCell .weightsInputWithUnit input{
  min-width: 0;
  text-align: right;
  border:0;
  background:transparent;
  box-shadow:none;
}
@media (max-width: 600px){
  .weightsBulkBar{ grid-template-columns: 1fr; align-items: stretch; }
  .weightsBulkSteps{align-items:flex-start;flex-direction:column;gap:5px}
  .weightsBulkActions{display:flex}
}

/* =======================================================================
 *   Results
 *   ======================================================================= */

.resultGrid{ display: grid; gap: var(--gap); }

.resultRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  padding: var(--row-pad);
  border-radius: var(--radius-row);
  background: var(--row-bg-2);
  border: 1px solid var(--row-border-2);
  transition: opacity .12s ease, filter .12s ease, transform .08s ease;
}
.resultRow:hover{ transform: translateY(-1px); }
.resultIdentity{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.resultTiming{ min-width:120px; text-align:right; white-space:nowrap; }
.resultTimingLabel{ font-size:var(--font-small); }
.resultTimingValue{ font-weight:950; }
.resultRow.late .resultTimingValue{ color:var(--warn); }

.resultRow .meta{
  color: var(--muted);
  font-size: var(--font-small);
  margin-top: 4px;
  line-height: 1.35;
}
.resultRow.done{ opacity: 0.42; filter: grayscale(1); }

.checkWrap{
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--font-small);
  user-select: none;
}
.checkWrap input{ width: 18px; height: 18px; padding: 0; margin: 0; border-radius: 6px; }

/* Timeline appearance choices */
body[data-timeline-style="event-rail"] .resultGrid{
  position:relative;
  gap:0;
  padding-left:22px;
}
body[data-timeline-style="event-rail"] .resultGrid::before{
  content:"";
  position:absolute;
  top:13px;
  bottom:13px;
  left:8px;
  width:1px;
  background:var(--row-border);
}
body[data-timeline-style="event-rail"] .resultRow{
  position:relative;
  grid-template-columns:minmax(92px,auto) minmax(0,1fr);
  align-items:center;
  min-height:58px;
  padding:7px 5px 7px 9px;
  border:0;
  border-bottom:1px solid var(--row-border-2);
  border-radius:0;
  background:transparent;
}
body[data-timeline-style="event-rail"] .resultRow:last-child{ border-bottom:0; }
body[data-timeline-style="event-rail"] .resultRow::before{
  content:"";
  position:absolute;
  left:-20px;
  width:8px;
  height:8px;
  border:3px solid var(--panel);
  border-radius:50%;
  background:var(--focus-border);
}
body[data-timeline-style="event-rail"] .resultRow.late::before{ background:var(--warn); }
body[data-timeline-style="event-rail"] .resultTiming{
  grid-column:1;
  grid-row:1;
  min-width:0;
  text-align:left;
}
body[data-timeline-style="event-rail"] .resultMain{ grid-column:2; grid-row:1; }
body[data-timeline-style="event-rail"] .checkWrap{ justify-content:flex-start; }

body[data-timeline-style="data-strips"] .resultGrid{ gap:0; }
body[data-timeline-style="data-strips"] .resultRow{
  min-height:42px;
  padding:5px 8px;
  border-width:0 0 1px;
  border-radius:0;
  background:transparent;
}
body[data-timeline-style="data-strips"] .resultRow:first-child{ border-top:1px solid var(--row-border-2); }
body[data-timeline-style="data-strips"] .resultRow .meta{ margin-top:2px; }
body[data-timeline-style="data-strips"] .resultIdentity .pill{
  padding:2px 6px;
  border-color:transparent;
  background:transparent;
}
body[data-timeline-style="data-strips"] .resultHopper{ color:var(--title); font-weight:950; }

body[data-timeline-style="priority-lane"] .resultGrid{ gap:0; }
body[data-timeline-style="priority-lane"] .resultRow{
  grid-template-columns:minmax(108px,auto) minmax(0,1fr);
  align-items:center;
  padding:8px 10px;
  border-width:0 0 1px 3px;
  border-radius:0;
  background:var(--row-bg-2);
}
body[data-timeline-style="priority-lane"] .resultRow:first-child{ border-radius:8px 8px 0 0; }
body[data-timeline-style="priority-lane"] .resultRow:last-child{ border-bottom:0; border-radius:0 0 8px 8px; }
body[data-timeline-style="priority-lane"] .resultRow.late{ border-left-color:var(--warn); }
body[data-timeline-style="priority-lane"] .resultTiming{
  grid-column:1;
  grid-row:1;
  min-width:0;
  text-align:left;
}
body[data-timeline-style="priority-lane"] .resultMain{ grid-column:2; grid-row:1; }
body[data-timeline-style="priority-lane"] .resultTimingValue{ font-size:calc(var(--font-base) + 2px); }
body[data-timeline-style="priority-lane"] .checkWrap{ justify-content:flex-start; }

body[data-timeline-style="divided-list"] .resultGrid{ gap:0; }
body[data-timeline-style="divided-list"] .resultRow{
  padding:9px 2px;
  border-width:0 0 1px;
  border-radius:0;
  background:transparent;
}
body[data-timeline-style="divided-list"] .resultRow:last-child{ border-bottom:0; }
body[data-timeline-style="divided-list"] .resultHopper{ color:var(--title); font-weight:950; }

body[data-timeline-style="command-rows"] .resultRow{
  position:relative;
  min-height:48px;
  padding:6px 9px 6px 17px;
  border-radius:7px;
  background:var(--panel);
}
body[data-timeline-style="command-rows"] .resultRow::before{
  content:"";
  position:absolute;
  top:5px;
  bottom:5px;
  left:5px;
  width:5px;
  border-radius:4px;
  background:var(--focus-border);
}
body[data-timeline-style="command-rows"] .resultRow.done::before{ background:var(--row-border); }
body[data-timeline-style="command-rows"] .resultRow.late::before{ background:var(--warn); }
body[data-timeline-style="command-rows"] .resultHopper{ font-size:calc(var(--font-base) + 1px); font-weight:950; }

@media (max-width:600px){
  .resultRow{ grid-template-columns:1fr; }
  .resultTiming{ min-width:0; text-align:left; }
  .checkWrap{ justify-content:flex-start; }
  body[data-timeline-style="event-rail"] .resultRow,
  body[data-timeline-style="priority-lane"] .resultRow{
    grid-template-columns:minmax(78px,auto) minmax(0,1fr);
  }
  body[data-timeline-style="event-rail"] .resultIdentity,
  body[data-timeline-style="priority-lane"] .resultIdentity{ gap:5px; }
  body[data-timeline-style="data-strips"] .resultTiming,
  body[data-timeline-style="divided-list"] .resultTiming,
  body[data-timeline-style="command-rows"] .resultTiming{
    display:flex;
    align-items:center;
    gap:8px;
  }
  body[data-timeline-style="data-strips"] .checkWrap,
  body[data-timeline-style="divided-list"] .checkWrap,
  body[data-timeline-style="command-rows"] .checkWrap{ margin-top:0; }
}

/* =======================================================================
 *   Resin totals
 *   ======================================================================= */

.calcTable{ margin-top: 10px; display: grid; gap: var(--gap); }

.calcRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--row-pad);
  border-radius: var(--radius-row);
  background: var(--row-bg-2);
  border: 1px solid var(--row-border-2);
}
.calcValue{ font-weight:950; }

.calcLeft{ display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.calcName{ font-weight: 950; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calcMeta{ font-size: var(--font-small); color: var(--muted); }

/* Inline layer % in the splits summary */
.layerPctInline{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.layerPctInline input{
  width: 92px;
  text-align: right;
  padding:
  max(4px, calc(var(--pad-input-y) - 2px))
  max(6px, calc(var(--pad-input-x) - 4px));
  font-size: var(--font-small);
}

/* =======================================================================
 *   Buttons
 *   ======================================================================= */

button{
  min-height:var(--control-height);
  border-radius:var(--control-radius);
  padding:var(--btn-pad-y) var(--btn-pad-x);
  border: 1px solid var(--btn-border);
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color: var(--btn-text);
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: filter .12s ease, transform .06s ease;
}
button:hover{ filter: brightness(1.05); }
button:active{ transform: translateY(1px); }
button:focus-visible{
  border-color:var(--focus-border);
  outline:2px solid var(--focus-border);
  outline-offset:2px;
}
button:disabled{
  opacity: .5;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

button.secondary{
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
}
button.primary{
  background:linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  border-color:var(--btn-border);
  color:var(--text);
}
button.danger{
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-border);
}
button.compactAction{
  width:auto;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border-radius:var(--control-radius);
  font-size:var(--font-small);
}

/* Two-tier segmented toolbars keep related commands compact and visible. */
.segmentedActionToolbar{
  display:grid;
  justify-items:start;
  gap:8px;
}
.segmentedActionRow{
  display:inline-flex;
  max-width:100%;
  overflow-x:auto;
  border:1px solid var(--btn-secondary-border);
  border-radius:var(--control-radius);
  background:var(--btn-secondary-bg);
}
.segmentedActionRow button{
  flex:0 0 auto;
  width:auto;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border:0;
  border-right:1px solid var(--btn-secondary-border);
  border-radius:0;
  background:transparent;
  color:var(--muted);
  font-size:var(--font-small);
  white-space:nowrap;
  box-shadow:none;
}
.segmentedActionRow button:last-child{ border-right:0; }
.segmentedActionRow button.primary{
  background:linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
  color:var(--text);
}
.segmentedActionRow button.danger{
  background:transparent;
  color:var(--bad);
}
.segmentedActionRow button:hover{ background-color:var(--row-bg); }
.segmentedActionDivider{
  width:min(100%, 520px);
  height:1px;
  background:var(--border);
}
/* Button-like links (works for <a> and <button>) */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--btn-radius);

  border: 1px solid var(--btn-border, rgba(255,255,255,.16));
  background: linear-gradient(
    180deg,
    var(--btn-primary-a, rgba(74,163,255,.22)),
                              var(--btn-primary-b, rgba(74,163,255,.10))
  );

  color: var(--btn-text, var(--text));
  font-weight: 700;
  font-size: var(--font-base);
  text-decoration: none;

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  transition: filter .12s ease, transform .06s ease;
}

.btn:hover{ filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); }

.btn.secondary{
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
}

.btn.danger{
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-border);
}


/* =======================================================================
 *   Footer bar (Next Pump Off)
 *   ======================================================================= */

.footerBar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  padding: 8px 12px;
  background: var(--footer-bg);
  border-top: 1px solid var(--footer-border);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.footerNextHopper{
  min-width: 0;
  flex: 1 1 auto;
}

.footerMsg{
  overflow: hidden;
  color: var(--title, var(--text));
  font-size: 13px;
  font-weight: 950;
  letter-spacing: .2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footerSub{
  overflow: hidden;
  margin-top: 2px;
  color: var(--subtitle, var(--muted));
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloudSyncFooterStatus{
  display: grid;
  flex: 0 0 auto;
  gap: 1px;
  min-width: 82px;
  padding-left: 12px;
  border-left: 1px solid var(--footer-border);
  text-align: left;
}
.cloudSyncFooterStatus span{
  color: var(--subtitle, var(--muted));
  font-size: 10px;
  font-weight: 650;
}
.cloudSyncFooterStatus strong{
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.cloudSyncFooterStatus[data-state="synced"] strong{ color: var(--ok); }
.cloudSyncFooterStatus[data-state="pending"] strong,
.cloudSyncFooterStatus[data-state="offline"] strong,
.cloudSyncFooterStatus[data-state="conflict"] strong{ color: var(--warn); }
.cloudSyncFooterStatus[data-state="error"] strong{ color: var(--bad); }

@media (max-width: 420px){
  .footerBar{ gap: 8px; padding-inline: 9px; }
  .cloudSyncFooterStatus{ min-width: 74px; padding-left: 8px; }
  .cloudSyncFooterStatus span{ font-size: 9px; }
  .cloudSyncFooterStatus strong{ font-size: 10px; }
}

@media (min-width: 901px){
  .footerBar{ display: none; }
}

/* =======================================================================
 *   Formula helpers
 *   ======================================================================= */

.formulaGroup{ display: grid; gap: 8px; }

.f-label{ color: var(--text); font-weight: 900; }
.f-var1{ color: var(--f-var1); }
.f-var2{ color: var(--f-var2); }
.f-var3{ color: var(--f-var3); }
.f-const{ color: var(--f-const); }


/* Results (Timeline) toggle row */
.resultsToggleRow{
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--row-bg-2);
  border: 1px solid var(--row-border-2);
}

/* =======================================================================
 *   Tools
 *   ======================================================================= */
.toolPanel{
  padding: var(--tool-pad);
  border: 1px solid transparent;
  border-radius: var(--radius-row);
  background: var(--panel2);
}
.toolPanel + .toolPanel{ margin-top: var(--gap); }
.toolsWorkspace{
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}
.toolsIndex{
  display: grid;
  align-content: start;
  gap: 6px;
  position: sticky;
  top: 70px;
}
.toolsIndexButton{
  width: 100%;
  min-height:var(--control-height);
  padding:var(--btn-pad-y) var(--btn-pad-x);
  border: 1px solid transparent;
  border-radius:var(--control-radius);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  text-align: left;
}
.toolsIndexButton:hover{
  border-color: var(--border2);
  background: var(--row-bg);
  color: var(--text);
}
.toolsIndexButton.active{
  border-color: var(--focus-border);
  background: var(--btn-primary-a);
  color: var(--text);
  font-weight: 850;
  box-shadow: inset 3px 0 0 var(--title);
}
.toolsWorkspaceContent{ min-width: 0; }
.toolWorkspacePanel[hidden]{ display: none !important; }
.toolsWorkspaceContent .toolPanel + .toolPanel{ margin-top: 0; }
@media (max-width: 720px){
  .toolsWorkspace{ grid-template-columns: 1fr; }
  .toolsIndex{
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolsIndexButton{ text-align: center; }
  .toolsIndexButton.active{ box-shadow: inset 0 -3px 0 var(--title); }
}
.toolResult{
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--readonly-border);
  border-radius: var(--radius-input);
  background: var(--readonly-bg);
}
.toolResult > span:first-child{ font-weight: 850; }
.toolResult strong{
  color: var(--title);
  font-size: 1.1em;
}
.toolResult .muted{ text-align: right; }
.resinLookupSearch{ position: relative; }
.resinLookupSuggestions{
  position: fixed;
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-input);
  background: var(--panelOpen);
  box-shadow: var(--shadow2);
}
.resinLookupOption{
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--radius-input) - 4px);
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}
.resinLookupOption:hover,
.resinLookupOption.active{
  background: linear-gradient(180deg, var(--btn-primary-a), var(--btn-primary-b));
}
.resinLookupOptionCode{
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resinLookupOptionDescription{
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
input.resinLookupValue[readonly]{
  width: 100%;
  color: var(--title);
  font-weight: 800;
  opacity: 1;
  cursor: default;
}
.resinLookupDensityField{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items:end;
  gap:6px;
}
.resinLookupCopyButton{
  min-width:52px;
  min-height:var(--control-height);
  padding:max(3px, calc(var(--btn-pad-y) - 3px)) var(--btn-pad-x);
  border-radius:var(--control-radius);
  box-shadow: none;
}
input.resinLookupDensity.copied[readonly]{
  border-color: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}
.resinLookupCopyStatus:not(:empty){ min-height: 1.35em; }
.resinLookupInformation textarea{
  min-height: 148px;
  border-color: var(--readonly-border);
  background: var(--readonly-bg);
  line-height: 1.5;
  resize: none;
  opacity: 1;
  cursor: default;
  box-shadow: none;
}
.resinLookupInformation textarea:focus{
  border-color: var(--readonly-border);
  box-shadow: none;
}
@media (max-width: 600px){
  .toolResult{ grid-template-columns: 1fr auto; }
  .toolResult .muted{
    grid-column: 1 / -1;
    text-align: left;
  }
  input.resinLookupValue[readonly]{
    min-height: 44px;
    font-size: 16px;
  }
  .resinLookupOption{ grid-template-columns: 1fr; gap: 2px; }
}

/* =======================================================================
 *   Help guide
 *   ======================================================================= */
.helpGuide{ gap: 14px; }
.helpTopics{ display: grid; gap: 10px; }
.helpTopic{
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-row);
  background: var(--row-bg);
}
.helpTopic > summary{
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 12px 42px 12px 14px;
}
.helpTopic > summary::after{
  content: "+";
  position: absolute;
  top: 50%;
  right: 15px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 500;
  transform: translateY(-50%);
}
.helpTopic[open] > summary::after{ content: "−"; }
.helpTopic[open] > summary{ border-bottom: 1px solid var(--row-border); }
.helpTopic > summary span{
  color: var(--title);
  font-weight: 900;
}
.helpTopic > summary small{
  overflow: hidden;
  color: var(--muted);
  font-size: var(--font-small);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.helpTopicBody{
  padding: 12px 16px 14px;
  color: var(--text);
  line-height: 1.55;
}
.helpTopicBody ol,
.helpTopicBody ul{ margin: 0; padding-left: 22px; }
.helpTopicBody li + li{ margin-top: 7px; }
.helpTopicBody h3{
  margin: 16px 0 8px;
  color: var(--title);
  font-size: 14px;
}
.helpTip{
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: var(--radius-input);
  background: var(--readonly-bg);
  color: var(--muted);
}

@media (max-width: 600px){
  .helpTopic > summary{ grid-template-columns: 1fr; }
  .helpTopic > summary small{ text-align: left; }
  .helpTopicBody{ padding-inline: 13px; }
}

/* =======================================================================
 *   Surface styles
 *   Layered Flat is the base treatment; these selectors provide alternatives.
 *   ======================================================================= */
body[data-surface-style="elevated"] .card{
  border-color: var(--border);
  box-shadow: var(--shadow2);
}
body[data-surface-style="elevated"] .card::before{
  content: "";
  display: block;
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--card-glow-a), var(--card-glow-b), transparent 60%);
  opacity: .55;
  pointer-events: none;
  filter: blur(14px);
}
body[data-surface-style="elevated"] details.block{
  border-color: var(--border);
  box-shadow: 0 8px 18px rgba(0,0,0,.20);
}
body[data-surface-style="elevated"] .blockBody > details.block{ background: var(--panel2); }
body[data-surface-style="elevated"] .workspaceNav,
body[data-surface-style="elevated"] .workspaceStatusBar{
  border-color: var(--border);
  box-shadow: var(--shadow2);
}
body[data-surface-style="elevated"] .workspaceNav{ background: var(--panel2); }
body[data-surface-style="elevated"] .workspaceStatusBar{
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(10px);
}
@media (min-width: 901px){
  body[data-surface-style="elevated"] .workspaceContent > .workspacePanel.card,
  body[data-surface-style="elevated"] .workspaceContent > .workspacePanel.card[open]{
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }
}

body[data-surface-style="flat"] .card,
body[data-surface-style="flat"] details.block,
body[data-surface-style="flat"] .workspaceNav,
body[data-surface-style="flat"] .workspaceStatusBar,
body[data-surface-style="flat"] .toolPanel,
body[data-surface-style="flat"] .helpTopic{
  border-color: var(--border);
  box-shadow: none;
}
body[data-surface-style="flat"] .blockBody > details.block{ background: var(--panel2); }
body[data-surface-style="flat"] .workspaceStatusBar{ background: var(--panel); }
body[data-surface-style="flat"] .workspaceContent > .workspacePanel.card,
body[data-surface-style="flat"] .workspaceContent > .workspacePanel.card[open]{
  border-color: var(--border);
  background: var(--panel);
}

body[data-surface-style="accent-frame"] .workspaceContent > .workspacePanel.card,
body[data-surface-style="accent-frame"] .workspaceContent > .workspacePanel.card[open]{
  border-left: 5px solid var(--title);
}
body[data-surface-style="accent-frame"] .workspaceStatusBar{
  border-color: color-mix(in srgb, var(--focus-border) 52%, transparent);
}
body[data-surface-style="accent-frame"] .blockBody > details.block,
body[data-surface-style="accent-frame"] .toolPanel,
body[data-surface-style="accent-frame"] .helpTopic{
  border-left: 3px solid color-mix(in srgb, var(--focus-border) 72%, transparent);
}

body[data-surface-style="divided"] .workspaceContent > .workspacePanel.card,
body[data-surface-style="divided"] .workspaceContent > .workspacePanel.card[open]{
  border: 0;
  border-radius: 0;
  background: transparent;
}
body[data-surface-style="divided"] .blockBody > details.block,
body[data-surface-style="divided"] .toolPanel,
body[data-surface-style="divided"] .helpTopic{
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
body[data-surface-style="divided"] .workspaceNav,
body[data-surface-style="divided"] .workspaceStatusBar{
  border-color: transparent;
  border-radius: 0;
}

body[data-surface-style="low-elevation"] .card,
body[data-surface-style="low-elevation"] details.block,
body[data-surface-style="low-elevation"] .workspaceNav,
body[data-surface-style="low-elevation"] .workspaceStatusBar,
body[data-surface-style="low-elevation"] .toolPanel,
body[data-surface-style="low-elevation"] .helpTopic{
  border-color: color-mix(in srgb, var(--focus-border) 18%, var(--border));
  box-shadow: 0 1px 2px rgba(0,0,0,.14);
}

/* Unified surface contract: every selection styles the same panel families. */
body{
  --surface-main-bg:var(--panel);
  --surface-main-border:transparent;
  --surface-main-radius:var(--radius2);
  --surface-main-shadow:none;
  --surface-inner-bg:var(--panel2);
  --surface-inner-border:transparent;
  --surface-inner-radius:var(--radius-row);
  --surface-inner-shadow:none;
  --surface-chrome-bg:var(--panel);
  --surface-chrome-border:transparent;
  --surface-chrome-radius:var(--radius-row);
  --surface-chrome-shadow:none;
  --surface-accent-width:0px;
}
body[data-surface-style="elevated"]{
  --surface-main-bg:var(--panel);
  --surface-main-border:var(--border);
  --surface-main-shadow:var(--shadow2);
  --surface-inner-bg:var(--panel2);
  --surface-inner-border:var(--border);
  --surface-inner-shadow:0 5px 14px rgba(0,0,0,.16);
  --surface-chrome-bg:var(--panel2);
  --surface-chrome-border:var(--border);
  --surface-chrome-shadow:var(--shadow2);
}
body[data-surface-style="flat"]{
  --surface-main-bg:var(--panel);
  --surface-main-border:var(--border);
  --surface-inner-bg:var(--panel2);
  --surface-inner-border:var(--border);
  --surface-chrome-bg:var(--panel);
  --surface-chrome-border:var(--border);
}
body[data-surface-style="accent-frame"]{
  --surface-main-bg:var(--panel);
  --surface-main-border:var(--border);
  --surface-inner-bg:var(--panel2);
  --surface-inner-border:var(--border);
  --surface-chrome-bg:var(--panel);
  --surface-chrome-border:color-mix(in srgb, var(--focus-border) 45%, var(--border));
  --surface-accent-width:3px;
}
body[data-surface-style="divided"]{
  --surface-main-bg:transparent;
  --surface-main-border:transparent;
  --surface-main-radius:0;
  --surface-inner-bg:transparent;
  --surface-inner-border:var(--border);
  --surface-inner-radius:0;
  --surface-chrome-bg:transparent;
  --surface-chrome-border:transparent;
  --surface-chrome-radius:0;
}
body[data-surface-style="low-elevation"]{
  --surface-main-bg:var(--panel);
  --surface-main-border:color-mix(in srgb, var(--focus-border) 18%, var(--border));
  --surface-main-shadow:0 1px 2px rgba(0,0,0,.14);
  --surface-inner-bg:var(--panel2);
  --surface-inner-border:color-mix(in srgb, var(--focus-border) 18%, var(--border));
  --surface-inner-shadow:0 1px 2px rgba(0,0,0,.12);
  --surface-chrome-bg:var(--panel);
  --surface-chrome-border:color-mix(in srgb, var(--focus-border) 18%, var(--border));
  --surface-chrome-shadow:0 1px 2px rgba(0,0,0,.14);
}

body[data-surface-style="elevated"] .card::before{ display:none; }
body[data-surface-style] .workspaceContent > .workspacePanel.card,
body[data-surface-style] .workspaceContent > .workspacePanel.card[open]{
  border-color:var(--surface-main-border);
  border-radius:var(--surface-main-radius);
  background:var(--surface-main-bg);
  box-shadow:var(--surface-main-shadow);
}
body[data-surface-style] .blockBody > details.block,
body[data-surface-style] .blockBody > details.block[open],
body[data-surface-style] .toolPanel,
body[data-surface-style] .helpTopic{
  border-color:var(--surface-inner-border);
  border-radius:var(--surface-inner-radius);
  background:var(--surface-inner-bg);
  box-shadow:var(--surface-inner-shadow);
}
body[data-surface-style] .workspaceNav,
body[data-surface-style] .workspaceStatusBar{
  border-color:var(--surface-chrome-border);
  border-radius:var(--surface-chrome-radius);
  background:var(--surface-chrome-bg);
  box-shadow:var(--surface-chrome-shadow);
}
body[data-surface-style="accent-frame"] .workspaceContent > .workspacePanel.card,
body[data-surface-style="accent-frame"] .workspaceContent > .workspacePanel.card[open]{
  border-left:5px solid var(--title);
  box-shadow:var(--surface-main-shadow);
}
body[data-surface-style="accent-frame"] .blockBody > details.block,
body[data-surface-style="accent-frame"] .blockBody > details.block[open],
body[data-surface-style="accent-frame"] .toolPanel,
body[data-surface-style="accent-frame"] .helpTopic{
  border-left:var(--surface-accent-width) solid var(--focus-border);
}
body[data-surface-style="divided"] .blockBody > details.block,
body[data-surface-style="divided"] .blockBody > details.block[open],
body[data-surface-style="divided"] .toolPanel,
body[data-surface-style="divided"] .helpTopic{
  border:0;
  border-top:1px solid var(--surface-inner-border);
}

/* =======================================================================
 *   Everyday / Advanced mode
 *   ======================================================================= */
.modeBar{display:flex;align-items:center;justify-content:flex-end}
.modeSwitch{display:inline-grid;grid-template-columns:1fr 1fr;flex:0 0 auto;padding:3px;border:1px solid var(--border2);border-radius:999px;background:var(--field-bg)}
.modeBtn{min-width:96px;padding:8px 13px;border:0;border-radius:999px;background:transparent;color:var(--muted);box-shadow:none}
.modeBtn.active{background:linear-gradient(180deg,var(--btn-primary-a),var(--btn-primary-b));color:var(--text);box-shadow:inset 0 0 0 1px var(--focus-border)}
.statusModeSwitch{ display:none;align-self:center; }
.workspaceStatusBar .statusModeSwitch{border:0}
.workspaceStatusBar .modeBtn.active{box-shadow:none}
.mobileTimelineModeBtn{ display:none; }
.statusModeSwitch .modeBtn{
  min-width:66px;
  padding:5px 9px;
  font-size:var(--font-tiny);
}
@media (max-width:900px){
  body[data-ui-mode="everyday"] .advancedOnly{display:none!important}
  .mobileBrand{
    margin-bottom:calc(0px - var(--page-gap));
    border-bottom:0;
  }
  .workspaceStatusBar{
    position:sticky;
    top:0;
    z-index:40;
    display:flex;
    justify-content:center;
    min-height:34px;
    padding:0 var(--page-pad);
    border-bottom:1px solid var(--surface-chrome-border);
    background:var(--surface-chrome-bg);
    box-shadow:var(--surface-chrome-shadow);
    backdrop-filter:blur(10px);
  }
  .statusPreferences{position:absolute;right:var(--page-pad);margin-left:0}
  .statusPreferencesPanel{position:fixed;top:38px;right:var(--page-pad)}
  .workspaceStatusBar .workspaceStatusItem{ display:none; }
  .statusModeSwitch{
    display:inline-grid;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    width:min(calc(100% - 48px), 290px);
  }
  .statusModeSwitch .modeBtn{ min-width:0; }
  .mobileTimelineModeBtn{ display:block; }
  body[data-mobile-timeline-only="true"] .workspaceContent > .workspacePanel:not(#resultsBlock){ display:none !important; }
  body[data-mobile-timeline-only="true"] #resultsBlock{ display:block !important; }
}
@media (max-width:600px){
  .modeSwitch:not(.statusModeSwitch){width:100%}
  .modeBtn{min-width:0}
}
