/* Visual preview only. The original Derby Stacker remains unchanged. */

:root {
  --preview-bg: #f3f1ec;
  --preview-surface: #fffdfa;
  --preview-surface-soft: #ebe7e0;
  --preview-ink: #28252b;
  --preview-muted: #706a73;
  --preview-line: #d8d3ca;
  --preview-purple: #60457d;
  --preview-purple-soft: #eee8f3;
  --preview-green: #557052;
  --preview-red: #a05151;
  --preview-radius: 12px;
}

:root[data-theme="dark"] {
  --preview-bg: #18161a;
  --preview-surface: #211f23;
  --preview-surface-soft: #2a272d;
  --preview-ink: #f1ede6;
  --preview-muted: #b9b1bb;
  --preview-line: #3b373e;
  --preview-purple: #bca4d2;
  --preview-purple-soft: #30283a;
  --preview-green: #91b18b;
  --preview-red: #df9292;
}

html { background: var(--preview-bg); }

body {
  background: var(--preview-bg) !important;
  color: var(--preview-ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.tool-sidebar {
  background: color-mix(in srgb, var(--preview-surface) 92%, var(--preview-bg));
  border-right: 1px solid var(--preview-line);
  bottom: 0;
  display: flex;
  flex-direction: column;
  left: 0;
  padding: 22px 14px 18px;
  position: fixed;
  top: 0;
  width: 232px;
  z-index: 100;
}

.mobile-menu-toggle, .sidebar-backdrop { display: none; }

.sidebar-brand { align-items: center; display: flex; gap: 11px; padding: 0 8px 24px; text-decoration: none; }
.sidebar-brand img { height: 38px; object-fit: contain; width: 38px; }
.sidebar-brand span { display: grid; line-height: 1.15; }
.sidebar-brand strong { color: var(--preview-ink); font-size: 15px; }
.sidebar-brand small { color: var(--preview-muted); font-size: 11px; margin-top: 3px; }
.sidebar-nav { display: grid; gap: 3px; }
.sidebar-label { color: var(--preview-muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; margin: 18px 10px 7px; text-transform: uppercase; }
.sidebar-nav a {
  align-items: center;
  border-radius: 8px;
  color: var(--preview-muted);
  display: grid;
  font-size: 13px;
  font-weight: 650;
  gap: 11px;
  grid-template-columns: 30px minmax(0, 1fr);
  min-height: 45px;
  padding: 6px 9px;
  text-decoration: none;
}
.sidebar-nav a:hover { background: var(--preview-surface-soft); color: var(--preview-ink); }
.sidebar-nav a.active { background: var(--preview-purple-soft); color: var(--preview-purple); }
.sidebar-nav img, .sidebar-glyph { height: 30px; object-fit: contain; width: 30px; }
.sidebar-glyph { align-items: center; background: var(--preview-surface-soft); border-radius: 7px; display: flex; font-family: Georgia, serif; font-size: 10px; font-weight: 700; justify-content: center; }
.sidebar-foot { border-top: 1px solid var(--preview-line); display: grid; gap: 10px; margin-top: auto; padding: 17px 9px 0; }
.sidebar-foot a { color: var(--preview-ink); display: flex; font-size: 12px; font-weight: 750; justify-content: space-between; text-decoration: none; }
.sidebar-foot small { color: var(--preview-muted); font-size: 10px; }
.sidebar-profile {
  align-items: center;
  background: var(--preview-surface-soft);
  border: 1px solid var(--preview-line);
  border-radius: 10px;
  display: grid;
  gap: 9px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  margin-top: auto;
  min-height: 62px;
  padding: 9px;
  text-decoration: none;
}
.sidebar-profile img { border-radius: 8px; height: 34px; object-fit: cover; width: 34px; }
.sidebar-profile > span { display: grid; gap: 2px; min-width: 0; }
.sidebar-profile strong { color: var(--preview-ink); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile small { color: var(--preview-muted); font-size: 10px; }
.sidebar-profile b { color: var(--preview-muted); font-size: 20px; font-weight: 400; }
.sidebar-profile:hover { border-color: var(--preview-purple); }
.sidebar-profile + .sidebar-foot { margin-top: 10px; }

.planner-tabbtn .tab-lock { color: var(--preview-muted); font-size: 10px; margin-left: 5px; }
.planner-tabbtn .tab-level { color: var(--preview-muted); display: block; font-size: 9px; font-weight: 650; margin-top: 2px; }

.tool-header {
  border-bottom: 1px solid var(--preview-line);
  max-width: none;
  padding-left: max(24px, calc((100vw - 1160px) / 2));
  padding-right: max(24px, calc((100vw - 1160px) / 2));
  margin-left: 232px;
}

.tool-header .tool-brand { visibility: hidden; }

.tool-header nav {
  background: transparent;
  border: 0;
  gap: 22px;
  padding: 0;
}

.tool-header nav a,
.tool-header nav .nav-disabled {
  background: transparent !important;
  color: var(--preview-muted);
  font-size: 13px;
  min-height: auto;
  padding: 8px 0;
}

.tool-header nav a:hover { color: var(--preview-ink); }
.tool-brand strong { color: var(--preview-ink); }
.theme-toggle, .cloud-login, .cloud-profile { border-radius: 7px; min-height: 38px; }
.tool-header .site-account { margin-left: 0; position: relative; width: auto; }
.tool-header .site-account-login,
.tool-header .site-account-profile {
  align-items: center;
  border-radius: 7px;
  box-sizing: border-box;
  display: inline-flex;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  gap: 7px;
  height: 38px;
  line-height: 1;
  margin: 0;
  max-width: 160px;
  min-height: 38px;
  overflow: hidden;
  padding: 4px 9px 4px 5px;
  text-decoration: none;
  width: auto;
}
.tool-header .site-account-login { background: #5865f2; border: 1px solid rgba(255,255,255,.18); color: #fff; padding: 0 11px; }
.tool-header .site-account-profile { background: var(--preview-surface-soft); border: 1px solid var(--preview-line); color: var(--preview-ink); cursor: pointer; }
.tool-header .site-account-profile img { border-radius: 6px; flex: 0 0 28px; height: 28px !important; max-height: 28px; max-width: 28px; object-fit: cover; padding: 0; width: 28px !important; }
.tool-header .site-account-profile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-header .discord-mark { display: inline-flex; height: 18px; width: 18px; }
.tool-header .discord-mark svg { display: block; height: 18px; width: 18px; }
.tool-header .site-account-menu { background: var(--preview-surface); border: 1px solid var(--preview-line); border-radius: 8px; box-shadow: 0 14px 34px rgba(0,0,0,.32); display: grid; gap: 5px; min-width: 190px; padding: 8px; position: absolute; right: 0; top: calc(100% + 6px); z-index: 120; }
.tool-header .site-account-menu[hidden],.tool-header .site-account-profile[hidden],.tool-header .site-account-login[hidden],.staff-sidebar-links[hidden]{display:none!important}
.tool-header .site-account-menu span { color: var(--preview-muted); font-size: 12px; font-weight: 800; padding: 5px 7px; }
.tool-header .site-account-menu button,.tool-header .site-account-menu a { background: transparent; border: 0; border-radius: 6px; color: var(--preview-ink); cursor: pointer; display: block; font: inherit; font-size: 12px; font-weight: 750; margin: 0; padding: 8px 7px; text-align: left; text-decoration: none; width: 100%; }
.tool-header .site-account-menu button:hover,.tool-header .site-account-menu a:hover { background: var(--preview-surface-soft); }
.staff-sidebar-links{display:grid;gap:3px}

main {
  display: grid;
  gap: 18px;
  max-width: 1120px;
  padding: 46px 24px 90px;
  margin-left: max(232px, calc(50vw - 328px));
  margin-right: max(0px, calc(50vw - 560px));
}

.stacker-intro {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 26px 4px 38px;
}

.stacker-intro img { height: 92px; object-fit: contain; width: 92px; }
.page-kicker, .section-kicker {
  color: var(--preview-purple);
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: 9px;
  text-transform: uppercase;
}

.stacker-intro h1 {
  color: var(--preview-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6vw, 66px);
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1;
  margin: 0;
  text-shadow: none;
}

.stacker-intro p { color: var(--preview-muted); font-size: 17px; margin: 16px 0 0; }

.support-dock {
  background: var(--preview-surface);
  border: 1px solid var(--preview-line);
  border-radius: var(--preview-radius);
  box-shadow: none;
  padding: 7px;
  position: sticky;
  top: 10px;
  z-index: 80;
}

.support-toolbar { gap: 5px; }
.support-level-control {
  align-items: center;
  background: var(--preview-surface-soft);
  border: 1px solid var(--preview-line);
  border-radius: 7px;
  box-sizing: border-box;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 62px;
  min-height: 40px;
  min-width: 0;
  padding: 4px 5px 4px 12px;
}
.support-level-control span {
  color: var(--preview-muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.support-level-control input {
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 750;
  height: 30px;
  margin: 0;
  min-width: 0;
  padding: 0 7px;
  text-align: center;
  width: 100%;
}
.support-tab {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--preview-muted);
  font-size: 13px;
  min-height: 40px;
}
.support-tab:hover, .support-tab[aria-expanded="true"] { background: var(--preview-purple-soft); color: var(--preview-purple); }
.support-tab span { color: inherit; font-weight: 500; }

.tool-section,
.summary-panel,
.inventory-panel,
.data-panel,
.tutorial-panel,
.stack-plan-panel {
  background: var(--preview-surface) !important;
  border: 1px solid var(--preview-line) !important;
  border-radius: var(--preview-radius) !important;
  box-shadow: none !important;
  color: var(--preview-ink);
  margin: 0 !important;
}

.tool-section { padding: clamp(20px, 4vw, 34px); }
.tool-section h2 {
  color: var(--preview-ink) !important;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4vw, 44px) !important;
  font-weight: 500;
  letter-spacing: -.035em;
  margin: 0 0 8px;
  text-shadow: none !important;
}
.section-help { color: var(--preview-muted) !important; font-size: 14px; margin-top: 0 !important; }
.section-divider { display: none; }

.quick-add {
  background: var(--preview-surface-soft);
  border: 1px solid var(--preview-line);
  border-radius: 9px;
  margin: 24px 0 16px;
  padding: 12px;
}

input, select, button, .import-label {
  border-color: var(--preview-line) !important;
  border-radius: 7px !important;
  font-family: inherit;
}

input, select {
  background: var(--preview-surface) !important;
  color: var(--preview-ink) !important;
}

input:focus, select:focus { border-color: var(--preview-purple) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--preview-purple) 14%, transparent) !important; outline: none; }

.planner-tabs {
  background: transparent !important;
  border-bottom: 1px solid var(--preview-line);
  gap: 4px;
  padding: 0 0 10px !important;
}
.planner-tabs button { background: transparent !important; border: 0 !important; color: var(--preview-muted) !important; }
.planner-tabs button.active, .planner-tabs .planner-tabbtn.active { background: var(--preview-purple-soft) !important; color: var(--preview-purple) !important; }

.planner-control-row { margin: 16px 0; }
.planner-toggle { background: var(--preview-surface-soft) !important; border: 1px solid var(--preview-line) !important; padding: 3px; }
.planner-toggle button, .compact-toggle { background: transparent !important; color: var(--preview-muted) !important; }
.planner-toggle button.active { background: var(--preview-surface) !important; box-shadow: 0 1px 3px rgba(0,0,0,.08); color: var(--preview-ink) !important; }

.compact-toggle::before { content: "View" !important; }
.compact-toggle.active,
.compact-toggle[aria-pressed="true"] { background: var(--preview-purple-soft) !important; border-color: var(--preview-purple) !important; color: var(--preview-purple) !important; }
.compact-toggle.active::before,
.compact-toggle[aria-pressed="true"]::before { background: transparent !important; color: inherit !important; }

.planner-actions { gap: 8px; }
.planner-action, #addRow, #addRowTop {
  background: var(--preview-purple) !important;
  border: 1px solid var(--preview-purple) !important;
  color: var(--preview-surface) !important;
  font-weight: 750;
  min-height: 42px;
}
.secondary-action, #clearCounts, #clearAll, .copy-stack-action {
  background: transparent !important;
  border-color: var(--preview-line) !important;
  color: var(--preview-muted) !important;
}

.reservation-bridge {
  align-items: end;
  background: var(--preview-surface-soft) !important;
  border: 1px solid var(--preview-line) !important;
  border-radius: 10px;
  box-sizing: border-box;
  gap: 12px;
  grid-template-columns: minmax(190px, 1.2fr) minmax(170px, .8fr) minmax(150px, .7fr) auto;
  margin: 16px 0 4px;
  max-width: 100%;
  padding: 14px;
  width: 100%;
}
.reservation-bridge > div:first-child {
  align-self: center;
  min-width: 0;
}
.reservation-bridge > div:first-child strong {
  color: var(--preview-ink);
  display: block;
  font-size: 14px;
  line-height: 1.2;
}
.reservation-bridge small {
  color: var(--preview-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 5px;
}
.reservation-bridge label {
  color: var(--preview-muted);
  font-size: 10px;
  gap: 6px;
  letter-spacing: .08em;
  min-width: 0;
}
.reservation-bridge select {
  box-sizing: border-box;
  font-size: 14px;
  min-width: 0;
  width: 100%;
}
.reservation-hood-picker {
  background: var(--preview-surface) !important;
  border: 1px solid var(--preview-line) !important;
  border-radius: 8px;
  box-sizing: border-box;
  grid-template-columns: 36px minmax(0, 1fr);
  min-width: 0;
  padding: 6px;
}
.reservation-hood-picker img {
  background: var(--preview-surface-soft);
  height: 36px;
  width: 36px;
}
.reservation-farm-picker { min-width: 0; }
#reserveReadyStacks {
  background: var(--preview-purple) !important;
  border-color: var(--preview-purple) !important;
  box-sizing: border-box;
  min-height: 42px;
}
.reservation-status {
  color: var(--preview-muted);
  grid-column: 1 / -1;
  min-height: 0;
}
.reservation-status:empty { display: none; }

#plannerList { display: grid; gap: 9px; margin: 18px 0; }
#plannerList .planner-row,
body.compact-stacker #plannerList .compact-single-card,
body.compact-stacker #plannerList .compact-combo-card {
  background: var(--preview-surface) !important;
  border: 1px solid var(--preview-line) !important;
  border-left-width: 3px !important;
  border-radius: 9px !important;
  box-shadow: none !important;
}
#plannerList .planner-row.state-idle { border-left-color: var(--preview-line) !important; }
#plannerList .planner-row.state-active { border-left-color: var(--gold, #bd9448) !important; }
#plannerList .planner-row.state-complete { border-left-color: var(--preview-green) !important; }
.planner-row .row-status { background: transparent !important; border: 0 !important; }

body.compact-stacker #plannerList .compact-icon-panel { grid-template-rows: minmax(0, 1fr) auto; padding: 5px; }
body.compact-stacker #plannerList .compact-main-icon { height: 56px; width: 56px; }
.preview-task-name {
  color: var(--preview-ink);
  display: block;
  font-size: 11px;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compact-combo-summary .preview-task-name { margin-right: 8px; }

/* Superlight keeps the compact card behavior but strips it to the working essentials. */
body.superlight-stacker #plannerList { gap: 5px; grid-template-columns: 1fr; }
body.superlight-stacker #plannerList .planner-row { border-left-width: 3px !important; }
body.superlight-stacker #plannerList .compact-single-card {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 44px minmax(70px, 1fr) auto auto;
  grid-template-rows: auto;
  min-height: 64px;
  padding: 7px 8px;
}
body.superlight-stacker #plannerList .compact-icon-panel { display: contents; }
body.superlight-stacker #plannerList .compact-main-icon { grid-column: 1; grid-row: 1; height: 42px; width: 42px; }
body.superlight-stacker #plannerList .preview-task-name { align-self: center; font-size: 12px; grid-column: 2; grid-row: 1; text-align: left; }
body.superlight-stacker #plannerList .compact-counter {
  display: grid;
  gap: 3px;
  grid-column: 3;
  grid-row: 1;
  grid-template-columns: 36px minmax(54px, 74px) 36px;
}
body.superlight-stacker #plannerList .compact-minus { grid-column: 1; grid-row: 1; }
body.superlight-stacker #plannerList .compact-current { grid-column: 2; grid-row: 1; width: 100%; }
body.superlight-stacker #plannerList .compact-plus { grid-column: 3; grid-row: 1; }
body.superlight-stacker #plannerList .compact-footer {
  display: grid;
  gap: 4px;
  grid-column: 4;
  grid-row: 1;
  grid-template-columns: 34px;
}
body.superlight-stacker #plannerList .compact-pill { display: none; }
body.superlight-stacker #plannerList .compact-delete,
body.superlight-stacker #plannerList .compact-done { height: 28px; width: 28px; }
body.superlight-stacker #plannerList .compact-delete { display: none; }

body.superlight-stacker #plannerList .compact-combo-card {
  box-sizing: border-box;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto auto auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 7px;
  width: 100%;
}
body.superlight-stacker #plannerList .compact-combo-summary {
  display: none;
}
body.superlight-stacker #plannerList .compact-combo-summary .preview-task-name {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  margin: 0;
  min-width: 0;
  text-align: left;
  width: 100%;
}
body.superlight-stacker #plannerList .compact-ingredients {
  gap: 5px;
  grid-column: 1;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
body.superlight-stacker #plannerList .compact-ingredient {
  box-sizing: border-box;
  gap: 7px;
  grid-template-columns: 32px minmax(0, 1fr) !important;
  max-width: 100%;
  min-width: 0;
  padding: 5px;
  width: 100%;
}
body.superlight-stacker #plannerList .compact-ingredient-icon { height: 30px; width: 30px; }
body.superlight-stacker #plannerList .compact-ingredient-controls {
  background: var(--preview-surface);
  border: 1px solid var(--preview-line);
  border-radius: 7px;
  gap: 0;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
body.superlight-stacker #plannerList .compact-ingredient-minus,
body.superlight-stacker #plannerList .compact-ingredient-plus {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--preview-ink) !important;
  height: 38px !important;
  min-height: 38px !important;
  min-width: 36px !important;
  width: 36px !important;
}
body.superlight-stacker #plannerList .compact-ingredient-minus { border-right: 1px solid var(--preview-line) !important; }
body.superlight-stacker #plannerList .compact-ingredient-plus { border-left: 1px solid var(--preview-line) !important; }
body.superlight-stacker #plannerList .compact-ingredient-minus:hover,
body.superlight-stacker #plannerList .compact-ingredient-plus:hover {
  background: var(--preview-purple-soft) !important;
  color: var(--preview-purple) !important;
}
body.superlight-stacker #plannerList .compact-ingredient-stack,
body.superlight-stacker #plannerList .compact-ingredient-input { min-width: 0; }
body.superlight-stacker #plannerList .compact-ingredient-stack {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 38px;
}
body.superlight-stacker #plannerList .compact-ingredient-input {
  box-sizing: border-box;
  height: 38px;
  width: 100%;
}
body.superlight-stacker #plannerList .compact-combo-card .compact-footer {
  display: none;
  grid-column: 1;
}
body.superlight-stacker #plannerList .planner-row.state-complete .compact-combo-card .compact-footer {
  display: flex;
  justify-content: flex-end;
}
body.superlight-stacker #plannerList .compact-combo-card .compact-done {
  background: var(--preview-green) !important;
  border: 0 !important;
  color: var(--preview-surface) !important;
  justify-self: end;
  min-height: 32px !important;
  min-width: 42px !important;
  width: 42px;
}

.summary-grid { gap: 1px; }
.summary-grid article { background: var(--preview-surface-soft) !important; border: 0 !important; }
.summary-grid strong { color: var(--preview-ink) !important; text-shadow: none !important; }

.filters {
  background: var(--preview-surface-soft) !important;
  border: 0 !important;
  border-radius: 9px;
  gap: 12px;
  padding: 14px !important;
}
.filters label { color: var(--preview-muted) !important; font-size: 12px; }
.task-cards { gap: 10px !important; }
.task-card { background: var(--preview-surface) !important; border: 1px solid var(--preview-line) !important; border-radius: 9px !important; box-shadow: none !important; }
.task-card:hover { border-color: var(--preview-purple) !important; transform: none !important; }

details > summary { color: var(--preview-ink) !important; }
details > summary strong { color: var(--preview-ink) !important; text-shadow: none !important; }
details > summary small, .support-panel-heading small { color: var(--preview-muted) !important; }
.about-btn { background: var(--preview-purple) !important; border: 0 !important; box-shadow: none !important; }

/* Keep picker controls inside their grid tracks at every width. */
.stack-plan-form,
.stack-plan-form label,
.stack-plan-machine-controls,
.stack-plan-machine-controls label {
  min-width: 0;
}

.stack-plan-form input,
.stack-plan-machine-controls input {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.stack-plan-form { grid-template-columns: repeat(4, minmax(90px, 1fr)) auto; }
.stack-plan-machine-controls { grid-template-columns: minmax(0, 1fr); }
.stack-plan-machine-actions { justify-content: flex-start; }

@media (max-width: 1050px) {
  .tool-sidebar {
    background: var(--preview-surface);
    border: 0;
    border-right: 1px solid var(--preview-line);
    bottom: 0;
    display: flex;
    height: auto;
    left: 0;
    overflow-y: auto;
    padding: 18px 12px;
    right: auto;
    top: 0;
    transform: translateX(-102%);
    transition: transform .2s ease;
    width: min(82vw, 300px);
    z-index: 130;
  }
  body.mobile-menu-open { overflow: hidden; }
  body.mobile-menu-open .tool-sidebar { transform: translateX(0); }
  .sidebar-brand { display: flex; padding-bottom: 18px; }
  .sidebar-label, .sidebar-foot { display: initial; }
  .sidebar-foot, .sidebar-profile { display: grid; }
  .sidebar-nav { display: grid; gap: 3px; min-width: 0; }
  .sidebar-nav a {
    display: grid;
    font-size: 13px;
    gap: 11px;
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 46px;
    padding: 7px 9px;
  }
  .sidebar-nav img, .sidebar-glyph { height: 30px; width: 30px; }
  .sidebar-backdrop {
    background: rgba(8, 7, 10, .62);
    border: 0 !important;
    border-radius: 0 !important;
    bottom: 0;
    cursor: default;
    display: block;
    left: 0;
    margin: 0;
    padding: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 120;
  }
  .sidebar-backdrop[hidden] { display: none; }

  .tool-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin-left: 0;
    padding: 10px 20px;
  }
  .mobile-menu-toggle {
    align-items: center;
    background: transparent;
    border: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    grid-column: 1;
    height: 38px;
    justify-content: center;
    margin: 0;
    padding: 0;
    width: 38px;
  }
  .mobile-menu-toggle span { background: var(--preview-ink); border-radius: 2px; display: block; height: 2px; width: 18px; }
  .tool-header .tool-brand { visibility: visible; }
  .tool-brand { grid-column: 2; justify-self: start; }
  .tool-header > nav { display: none; }
  .header-actions { grid-column: 3; }

  main {
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    max-width: 960px;
    min-width: 0;
    padding: 34px 20px 70px;
    width: 100%;
  }

  .stack-plan-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .stack-plan-form button { min-width: 0; width: 100%; }
  .reservation-bridge {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .reservation-bridge > div:first-child { grid-column: 1 / -1; }
  #reserveReadyStacks { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 620px) {
  .support-dock {
    box-sizing: border-box;
    border: 1px solid var(--preview-line) !important;
    border-radius: 10px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    overflow: visible !important;
    padding: 5px !important;
    position: static !important;
    width: 100%;
  }
  .support-toolbar {
    display: grid !important;
    gap: 4px;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  .support-tab {
    box-sizing: border-box;
    font-size: 12px;
    justify-content: center;
    min-width: 0;
    padding: 0 5px !important;
    text-align: center;
    width: 100%;
  }
  .support-tab:first-child {
    align-items: center;
    grid-column: auto !important;
  }
  .support-level-control {
    gap: 4px;
    grid-template-columns: minmax(0, 1fr) 48px;
    padding-left: 7px;
  }
  .support-level-control span { font-size: 11px; }
  .stack-plan-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-left: 14px;
    padding-right: 14px;
  }
  .stack-plan-form button { grid-column: 1 / -1; }
  .stack-plan-mode,
  .stack-plan-options,
  .stack-plan-actions,
  .stack-plan-results { padding-left: 14px; padding-right: 14px; }
  .stack-plan-actions button { width: 100%; }
  .reservation-bridge {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }
  .reservation-bridge > div:first-child,
  #reserveReadyStacks,
  .reservation-status { grid-column: 1; }
}

@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden !important;
    width: 100%;
  }
  body { padding-bottom: 0 !important; }
  .tool-sidebar {
    background: var(--preview-surface);
    border: 0;
    border-right: 1px solid var(--preview-line);
    bottom: 0;
    display: flex;
    height: auto;
    left: 0;
    overflow-y: auto;
    padding: 18px 12px;
    right: auto;
    top: 0;
    transform: translateX(-102%);
    transition: transform .2s ease;
    width: min(82vw, 300px);
    z-index: 130;
  }
  body.mobile-menu-open { overflow: hidden; }
  body.mobile-menu-open .tool-sidebar { transform: translateX(0); }
  .sidebar-brand { display: flex; padding-bottom: 18px; }
  .sidebar-label, .sidebar-foot { display: initial; }
  .sidebar-foot { display: grid; }
  .sidebar-profile { display: grid; }
  .sidebar-nav { display: grid; gap: 3px; min-width: 0; }
  .sidebar-nav a {
    display: grid;
    font-size: 13px;
    gap: 11px;
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 46px;
    padding: 7px 9px;
  }
  .sidebar-nav img, .sidebar-glyph { height: 30px; width: 30px; }
  .sidebar-backdrop {
    background: rgba(8, 7, 10, .62);
    border: 0 !important;
    border-radius: 0 !important;
    bottom: 0;
    cursor: default;
    display: block;
    left: 0;
    margin: 0;
    padding: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 120;
  }
  .sidebar-backdrop[hidden] { display: none; }

  .tool-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin-left: 0;
    padding: 10px 14px;
  }
  .mobile-menu-toggle {
    align-items: center;
    background: transparent;
    border: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
    grid-column: 1;
    height: 38px;
    justify-content: center;
    margin: 0;
    padding: 0;
    width: 38px;
  }
  .mobile-menu-toggle span { background: var(--preview-ink); border-radius: 2px; display: block; height: 2px; width: 18px; }
  .tool-header .tool-brand { visibility: visible; }
  .tool-brand { grid-column: 2; justify-self: start; }
  .tool-brand img { height: 30px; width: 30px; }
  .tool-brand strong { font-size: 14px; }
  .tool-header > nav { display: none; }
  .header-actions { gap: 6px; grid-column: 3; }
  .theme-toggle { color: transparent !important; font-size: 0 !important; min-height: 38px; overflow: hidden; padding: 0; position: relative; text-indent: -999px; width: 38px; }
  .theme-toggle::before { color: var(--preview-ink); content: "◐"; font-size: 17px; inset: 0; line-height: 38px; position: absolute; text-align: center; text-indent: 0; }
  .cloud-login { font-size: 12px; min-height: 38px; padding: 0 10px; }

  main {
    box-sizing: border-box;
    gap: 10px;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
    padding: 20px 8px 34px;
    width: 100%;
  }
  .stacker-intro { padding: 14px 8px 18px; }
  .stacker-intro h1 { font-size: clamp(36px, 11vw, 46px); }
  .stacker-intro img { height: 58px; width: 58px; }
  .stacker-intro p { font-size: 14px; line-height: 1.45; margin-top: 10px; max-width: 290px; }
  .page-kicker { font-size: 9px; margin-bottom: 7px; }

  .support-dock {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
    margin-left: -8px;
    margin-right: -8px;
    overflow-x: auto;
    max-width: calc(100% + 16px);
    padding: 6px 8px;
    position: sticky;
    scrollbar-width: none;
    top: 0;
  }
  .support-dock::-webkit-scrollbar { display: none; }
  .support-toolbar { display: flex; flex-wrap: nowrap; gap: 4px; min-width: max-content; }
  .support-tab { min-height: 38px; padding: 0 13px; white-space: nowrap; }
  .support-tab span { display: none; }

  .tool-section {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
    padding: 20px 12px;
    width: 100%;
  }
  #stacker {
    background: var(--preview-surface) !important;
    border: 1px solid var(--preview-line) !important;
    border-radius: var(--preview-radius) !important;
    min-width: 0;
    padding: 18px 12px;
  }
  .tool-section h2 { font-size: 34px !important; }
  .section-help { display: none; }
  .section-kicker { font-size: 9px; margin-bottom: 5px; }

  .quick-add { box-sizing: border-box; margin: 18px 0 12px; max-width: 100%; min-width: 0; padding: 10px; width: 100%; }
  #quickAddSearch { font-size: 16px; min-height: 48px; }
  .planner-tabs { margin-top: 4px; max-width: 100%; min-width: 0; overflow-x: auto; padding-top: 5px !important; width: 100%; }
  .planner-tabs button { min-height: 42px; }
  .planner-control-row { align-items: stretch; gap: 8px; margin: 12px 0; max-width: 100%; min-width: 0; width: 100%; }
  .planner-toggle { flex: 1; min-width: 0; }
  .planner-toggle button { min-height: 42px; }
  .compact-toggle { min-height: 42px; }
  .planner-actions.top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 100%; min-width: 0; width: 100%; }
  .planner-actions.top .planner-action { margin: 0; min-width: 0; width: 100%; }

  #plannerList { gap: 8px; margin: 12px 0; max-width: 100%; min-width: 0; width: 100%; }
  #plannerList .planner-row { box-sizing: border-box; max-width: 100%; min-width: 0; padding: 12px 10px !important; width: 100%; }
  #plannerList button { min-height: 42px; min-width: 42px; }

  #addRow,
  #addRow + .copy-stack-action { display: none !important; }
  #clearCounts, #clearAll { font-size: 12px; margin-top: 4px; min-height: 42px; }

  #sorter { margin-top: 8px !important; }
  .filters { grid-template-columns: 1fr 1fr !important; padding: 10px !important; }
  .filters label:last-child { grid-column: 1 / -1; }
  .filters input, .filters select { font-size: 16px; min-height: 46px; }

  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .summary-grid article { min-height: 72px; padding: 12px !important; }
  .about-btn { bottom: 14px !important; }

  body.superlight-stacker #plannerList .compact-single-card {
    grid-template-columns: 42px minmax(64px, 1fr) auto auto;
    min-height: 60px;
    padding: 6px;
  }
  body.superlight-stacker #plannerList .compact-main-icon { height: 40px; width: 40px; }
  body.superlight-stacker #plannerList .compact-counter { grid-template-columns: 34px minmax(46px, 64px) 34px; }
  body.superlight-stacker #plannerList .compact-plus,
  body.superlight-stacker #plannerList .compact-minus { height: 40px !important; min-height: 40px; min-width: 34px; width: 34px; }
  body.superlight-stacker #plannerList .compact-current { height: 40px; }
  body.superlight-stacker #plannerList .compact-done { min-height: 40px; width: 34px; }
}

@media (max-width: 390px) {
  .tool-brand strong { display: none; }
  .stacker-intro img { height: 52px; width: 52px; }
  .planner-control-row { display: grid !important; grid-template-columns: minmax(0, 1fr); }
  .planner-toggle {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100% !important;
  }
  .planner-toggle button { min-width: 0 !important; width: 100%; }
  .compact-toggle { justify-content: center; min-width: 0 !important; width: 100% !important; }
  .planner-actions.top { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: 1fr !important; }
  .filters label:last-child { grid-column: auto; }

  body.compact-stacker:not(.superlight-stacker) #plannerList {
    column-count: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-single-card {
    box-sizing: border-box;
    gap: 8px !important;
    grid-template-columns: minmax(0, 1fr) 58px !important;
    grid-template-rows: 96px 42px !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden;
    padding: 8px !important;
    width: 100% !important;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-icon-panel {
    max-width: 100%;
    min-width: 0 !important;
    width: 100% !important;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-counter {
    max-width: 58px;
    min-width: 0 !important;
    width: 58px !important;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-current {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0 !important;
    width: 100% !important;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-footer {
    grid-column: 1 / -1 !important;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-combo-card,
  body.compact-stacker:not(.superlight-stacker) #plannerList .compact-ingredients {
    grid-template-columns: minmax(0, 1fr) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  body.superlight-stacker #plannerList .compact-single-card {
    box-sizing: border-box;
    grid-template-columns: 42px minmax(0, 1fr) 34px;
    grid-template-rows: 42px 42px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    width: 100%;
  }
  body.superlight-stacker #plannerList .compact-main-icon { grid-column: 1; grid-row: 1; }
  body.superlight-stacker #plannerList .preview-task-name { grid-column: 2; grid-row: 1; }
  body.superlight-stacker #plannerList .compact-counter { grid-column: 1 / 3; grid-row: 2; justify-self: stretch; }
  body.superlight-stacker #plannerList .compact-footer { grid-column: 3; grid-row: 1 / 3; grid-template-columns: 34px; }
  body.superlight-stacker #plannerList .compact-pill { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
