body,
html {
  /* Light theme variables */
  --bg-primary: #f5f7f9;
  --bg-secondary: #fff;
  --text-primary: #404247;
  --text-secondary: #818489;
  --border-color: #e2e8ed;
  --nav-bg: #404247;
  --button-primary: #24c7ed;
  --button-hover: #3eddf7;
  --table-bg: #fff;
  --table-hover: #f5f7f9;
  --table-active: #24c7ed;
  --input-bg: #e2e8ed;
  --input-border: #c8cedb;
  --input-text: #7b879e;
  --message-bg: rgba(255, 255, 255, 0.9);
  --nest-bg: #404247;
  --progress-bg: #cdd8e0;

  /* Default to light theme */
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  border: 0;
  font:
    normal 14px/1.4 "LatoLatinWeb",
    helvetica,
    arial,
    verdana,
    sans-serif;
  overflow: hidden;
  --nav-width: 4.375em;
  -webkit-user-select: none;
  user-select: none;
}

/* Dark theme */
body.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #818489;
  --border-color: #404040;
  --nav-bg: #000000;
  --button-primary: #1a98b8;
  --button-hover: #1fb3d8;
  --table-bg: #2d2d2d;
  --table-hover: #3d3d3d;
  --table-active: #1a98b8;
  --input-bg: #3d3d3d;
  --input-border: #505050;
  --input-text: #ffffff;
  --message-bg: rgba(45, 45, 45, 0.9);
  --nest-bg: #1a1a1a;
  --progress-bg: #404040;
}

a {
  color: #24c7ed;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.5em;
  font-family: "LatoLatinWebLight", helvetica, arial, verdana, sans-serif;
  font-weight: normal;
  margin: 1.2em 0 0.5em 0;
  cursor: default;
}

h2 {
  font-size: 1.1em;
  font-weight: bold;
  margin: 1em 0 0.5em 0;
}

h3 {
  font-size: 1em;
  font-weight: bold;
  margin: 1em 0 0.2em 0;
}

h1,
h2,
h3 {
  color: var(--text-secondary);
}

/* Sidebar navigation */
#sidenav {
  width: var(--nav-width);
  height: 100%;
  background-color: var(--nav-bg);
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  -webkit-app-region: drag;
  display: flex;
  flex-direction: column;
}

#sidenav li {
  width: var(--nav-width);
  height: var(--nav-width);
  list-style: none;
  margin: 0;
  padding: 0;
  -webkit-app-region: no-drag;
  display: flex;
  justify-content: center;
  align-items: center;
}

#sidenav li:hover {
  background-color: #53575e;
}

#sidenav li.active {
  background-color: #000;
  filter: brightness(0.6) invert(100%);
}

#sidenav #home_tab {
  height: calc(var(--nav-width) - 0.625em);
  background-image: url(img/logosmall.svg);
  background-repeat: no-repeat;
  background-size: 1.75em 1.75em;
  background-position: 50%;
}

#config_tab {
  background-image: url(img/settings.svg);
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  background-position: 50%;
}

#account_tab {
  background-image: url(img/shop.svg);
  background-repeat: no-repeat;
  background-size: 1.4em 1.4em;
  background-position: 50%;
}

#info_tab {
  background-image: url(img/info.svg);
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  background-position: 50%;
}

#darkmode_tab {
  background-image: url(img/dark_mode.svg);
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  background-position: 50%;
}

.page {
  width: calc(100% - var(--nav-width));
  height: 100%;
  position: absolute;
  top: 0;
  left: var(--nav-width);
  background-color: var(--bg-primary);
  display: none;
}

.page.active {
  display: block;
}

.topnav {
  width: 100%;
  height: calc(var(--nav-width) - 0.625em);
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  overflow: hidden;
  -webkit-app-region: drag;
  position: relative;
  z-index: 10;
}

#progressbar_wrapper {
  position: absolute;
  top: calc(var(--nav-width) - 0.625em);
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--progress-bg);
}

#progressbar {
  width: 0;
  height: 100%;
  background-color: #24c7ed;
  transition: width 0.5s;
}

#nest .topnav {
  background-color: #575960;
  border: none;
  overflow: visible;
}

#nest .topnav .back {
  margin-left: auto;
  margin-right: 1em;
  background-color: #717377;
  background-image: url(img/arrow_right.svg);
  background-repeat: no-repeat;
  padding-right: 4em;
  background-size: 1.2em 1.2em;
  background-position: 80% 50%;
}

.topnav li {
  -webkit-app-region: no-drag;
}

.button {
  display: inline-flex;
  align-items: center;
  list-style: none;
  margin: 0.78em 0 0 1.25em;
  padding: 0.6em 3em;
  color: #fff;
  background-color: var(--button-primary);
  border-radius: 5em;
  cursor: default;
  font-size: 0.875em;
}

.button:hover {
  text-decoration: none;
  background-color: #3eddf7;
}

.button.start {
  background-image: url(img/start.svg);
  background-repeat: no-repeat;
  background-size: 1.6em 1.6em;
  background-position: 2.25em 50%;
  padding-left: 4.625em;
}

.button.stop {
  background-image: url(img/spin.svg);
  background-repeat: no-repeat;
  background-size: 1.6em 1.6em;
  background-position: 2.25em 50%;
  padding-left: 4.625em;
}

.button.import {
  background-image: url(img/import.svg);
  background-repeat: no-repeat;
  background-size: 1.2em 1.2em;
  background-position: 2.2em 50%;
  padding-left: 4em;
}

.button.spinner {
  background: #fff url(img/spin.svg) no-repeat;
  background-size: 1.4em 1.4em;
  background-position: 1.8em 50%;
  padding-left: 3.7em;
}

.button.import.spinner,
.button.export.spinner {
  background-color: #24c7ed;
  background-image: url(img/spin.svg);
  background-size: 1.4em 1.4em;
  background-position: 1.8em 50%;
  padding-left: 4em;
}

.button.delete {
  background-image: url(img/delete.svg);
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 50%;
  padding: 0.6em 2em;
}

.button.addsheet {
  background-image: url(img/add_sheet.svg);
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 50%;
  padding: 0.6em 2em;
}

.button.export {
  background-image: url(img/download.svg);
  background-repeat: no-repeat;
  background-size: 1em 1em;
  background-position: 2.2em 50%;
  padding-left: 4em;
}

.button.code {
  background: #fff url(img/code.svg) no-repeat;
  background-size: 1.2em 1.2em;
  background-position: 2em 50%;
  padding-left: 3.9em;
}

.button.config {
  background: #fff url(img/settings.svg) no-repeat;
  background-size: 1.2em 1.2em;
  background-position: 2em 50%;
  padding-left: 3.9em;
}

.button.close {
  background-image: url(img/close.svg);
  background-repeat: no-repeat;
  background-size: 2em 2em;
  background-position: 1.8em 50%;
}

.button.zoomin {
  background: #fff url(img/zoomin.svg) no-repeat;
  background-size: 1.5em 1.5em;
}

.button.zoomout {
  background: #fff url(img/zoomout.svg) no-repeat;
  background-size: 1.5em 1.5em;
}

.button:active {
  background-color: #404247;
  cursor: default;
}

.button.disabled {
  background-color: #333;
  cursor: default;
  filter: invert(100%) contrast(10%) brightness(1.5);
}

/* export dropdown */
#export_wrapper {
  position: relative;
  display: inline-block;
  margin: 0.78em 0 0 1.25em;
}

#export {
  margin: 0;
  overflow: visible;
  position: relative;
  z-index: 20;
}

#export_wrapper.active:hover ul.dropdown {
  opacity: 1;
  height: 5em;
}

ul.dropdown {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 1em 0 0 0;
  background-color: var(--bg-secondary);
  position: absolute;
  top: 1.4em;
  left: 0;
  width: 100%;
  z-index: 10;
  color: var(--text-secondary);
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  cursor: default;
  overflow: hidden;
  opacity: 0;
  height: 0;
  transition: height 0.2s;
}

ul.dropdown li {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0 1em;
  height: 2.5em;
}

ul.dropdown li:hover {
  background-color: var(--table-hover);
  color: var(--text-primary);
}

#homecontent {
  width: 100%;
  height: 100%;
  display: flex;
  position: relative; /* Create a positioning context */
  overflow: hidden; /* Prevent scrollbars at container level */
  flex-direction: row;
  flex-wrap: wrap;
}

#parts {
  background-color: var(--table-bg);
  border-right: 0.2em solid var(--border-color);
  width: 32em;
  height: 100%;
  overflow: hidden; /* Keep hidden - this prevents double scrollbars */
  box-sizing: border-box;
  position: relative;
  z-index: 5;
  min-width: 26em;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  order: 1;
}

/* Make sure #partscroll takes available space and shows scrollbars when needed */
#partscroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  margin-bottom: calc(100% - calc(28em)); /* Leave space for #partstools */
}

#imports {
  position: relative; /* Change from absolute to relative */
  height: 100%;
  background-color: var(--bg-primary);
  flex: 1; /* Take remaining space */
  order: 2; /* Place after #parts */
}

/* config */

#configform {
  width: 40%;
  height: 100%;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0 2%;
  min-width: 23em;
  overflow: auto;
}

#config dl {
  display: flex;
  flex-direction: column;
  margin: 0 0 2em 0;
  padding: 0;
  width: 100%;
  cursor: default;
}

#config dl dt,
#config dl dd {
  margin: 0.7em 0;
  padding: 0;
}

#config dl dt {
  width: 100%;
  min-height: 2em;
  line-height: 2em;
}

#config dl dd {
  width: 100%;
  color: #7b879e;
  background-color: var(--bg-secondary);
  position: relative;
  min-height: 2em;
  line-height: 2em;
  display: flex;
  align-items: center;
}

@media (min-width: 768px) {
  #config dl {
    flex-direction: row;
    flex-wrap: wrap;
  }

  #config dl dt {
    width: 50%;
  }

  #config dl dd {
    width: 50%;
  }
}

#config span,
#config i {
  cursor: default;
}

#config dl dd .spinner {
  width: 1.4em;
  height: 1.4em;
  background: #f00;
  position: absolute;
  top: 0.2em;
  left: -2em;
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.63, 0.01, 0.9, 0.32);
  background: transparent url(img/spin.svg) no-repeat;
  background-size: 1.4em 1.4em;
  background-position: 50%;
  filter: invert(100%);
}

#config dl dd.progress .spinner {
  opacity: 0.4;
  transition-property: none;
}

#config .radiolabel {
  padding-right: 0.7em;
}

#config input[type="text"],
#config input[type="number"] {
  width: 5em;
  height: 2.5em;
  line-height: 2.5em;
  background-color: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: 3px;
  color: var(--input-text);
  margin-top: -0.4em;
  padding: 0 0.5em 0 1em;
}

#config input:invalid,
#config input:out-of-range {
  border-color: hsl(0, 50%, 50%);
  background: hsl(0, 50%, 90%);
}

#config input[type="text"]:focus,
#config input[type="number"]:focus {
  background-color: #f4f7f9;
  border-color: #26a9e0;
}

#config i {
  font-style: normal;
  margin-left: 0.5em;
}

.config_explain {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  width: 25em;
  padding: 5em 2% 0 5%;
}

.config_explain.active {
  display: block;
}

#config svg {
  width: 100%;
  height: auto;
}

#config svg * {
  stroke-width: 2px !important;
  vector-effect: non-scaling-stroke !important;
  stroke-linejoin: round !important;
  stroke-linecap: round !important;
  stroke-dasharray: 1450;
  stroke-dashoffset: 1450;
  animation: dash 3s linear forwards;
}

/* info page */
#info {
  height: 100%;
  background-color: var(--bg-secondary);
  padding: 0 5%;
  min-width: 22em;
  flex: 1;
}

#info.active svg g.logo path,
#info.active svg g.logo line,
#info.active svg g.logo rect,
#info.active svg g.logo circle {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: dash 5s linear forwards;
}

#info.active svg path.fill {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: dash 20s linear forwards;
}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
    fill: #f00 !important;
  }
}

@keyframes fill {
  to {
    fill: #f00 !important;
  }
}

/* part table */
#parts table {
  width: 100%;
  min-width: 28em;
  margin: 0;
  padding: 0;
  color: var(--text-secondary);
  border-collapse: collapse;
  cursor: default;
  font-size: 0.9em;
}

#parts table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--table-bg);
}

#parts table thead tr {
  padding: 0 1em;
}

#parts table thead tr th,
#parts table tbody tr td {
  font-weight: normal;
  text-align: left;
  margin: 0;
  padding: 0.4em 0.5em;
}

#parts table thead tr th {
  height: 3em;
  line-height: 3em;
  padding: 0;
  border-bottom: 1px solid var(--border-color);
}

#parts table thead tr th span {
  display: block;
  width: 100%;
  height: 3em;
  line-height: 3em;
  padding: 0 0.1em;
  box-sizing: border-box;
  background-color: var(--table-bg);
  color: var(--text-secondary);
}

#parts table thead tr th:first-child span {
  padding-left: 0.5em;
}

#parts table thead tr th:hover span {
  background-color: var(--table-hover);
}

#parts table thead tr th.asc span {
  background-image: url(img/arrow_up.svg);
  background-repeat: no-repeat;
  background-size: 0.5em 0.5em;
  background-position: 90% 50%;
}

#parts table thead tr th.desc span {
  background-image: url(img/arrow_down.svg);
  background-repeat: no-repeat;
  background-size: 0.5em 0.5em;
  background-position: 90% 50%;
}

#parts table tbody tr td:first-child {
  padding-left: 0.2em;
}

#parts table tbody tr:hover td {
  background-color: var(--table-hover);
}

#parts table tbody tr.active td {
  background-color: var(--table-active);
  color: var(--text-primary);
}

#parts table tbody tr.active td input {
  color: #fff;
}

#parts table tbody tr.active td input:focus {
  color: #000;
}

#parts table input[type="text"],
#parts table input[type="number"] {
  background-color: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0.2em 0.3em;
  font-size: 1em;
}

#parts table input[type="text"]:focus,
#parts table input[type="number"]:focus {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Fix for dark mode input visibility in non-active rows */
body.dark-mode #parts table tbody tr:not(.active) td input[type="text"],
body.dark-mode #parts table tbody tr:not(.active) td input[type="number"] {
  color: var(--text-primary);
}

body.dark-mode #parts table tbody tr.active td input {
  color: #fff;
}

/* Improved focus styles for both active and non-active rows in dark mode */
body.dark-mode #parts table tbody tr td input[type="text"]:focus,
body.dark-mode #parts table tbody tr td input[type="number"]:focus {
  background-color: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--button-primary);
  outline: none;
}

/* parts table svg */
#parts table svg {
  max-width: 4em;
  max-height: 3em;
  display: block;
  margin: 0 auto;
}

#parts table svg * {
  fill: #fff !important;
  fill-opacity: 0 !important;
  stroke: #404247 !important;
  stroke-width: 1px !important;
  vector-effect: non-scaling-stroke !important;
  stroke-linejoin: round !important;
}

#parts table tbody tr.active svg * {
  stroke: #fff !important;
}

/* parts tools */
#partstools {
  position: relative;
  bottom: calc(var(--nav-width) - 0.625em);
  width: 100%;
  height: calc(var(--nav-width) - 0.625em);
  background-color: var(--progress-bg);
  transition: height 0.5s;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0; /* Prevent shrinking */
}
#partstools > div {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  top: -4px; /* Adjust for top border */
}
/* Style buttons to be side by side */
#partstools > div > a {
  display: flex; /* Use flex instead of inline-flex */
  margin-right: 15px; /* More space between buttons */
}

/* When active (showing sheet dialog), switch to block layout */
#partstools.active {
  height: 17em;
  display: block; /* Switch to block layout when showing dialogs */
  padding-top: 10px; /* Add some top padding when in active mode */
}

/* Preserve spacing in active state */
#partstools.active > div > a {
  /*display: inline-block;*/ /* Display as inline-block in active state */
  margin-left: 1.25em;
  margin-bottom: 10px; /* Add some bottom margin in active state */
}

#sheetdialog {
  margin: 0 1.5em 1.5em 1.5em;
  display: block; /* Change to block to match original */
  width: auto; /* Allow natural width */
}
#partstools.active > a {
  display: inline-block; /* Display as inline-block in active state */
  margin-left: 1.25em;
  margin-bottom: 10px; /* Add some bottom margin in active state */
}
#partstools #sheetdialog {
  display: none;
}

#partstools.active #sheetdialog {
  display: block;
}

#sheetdialog .row {
  width: 100%;
  margin: 0.3em 0 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  flex-direction: row;
  align-content: center;
}

#sheetdialog .button.add {
  margin-left: 0;
}

#sheetdialog .label {
  display: inline-block;
  width: 7em;
}

#sheetdialog .button {
  display: inline-block;
  padding-left: 2em;
  padding-right: 2em;
  margin-top: 1em;
}

#sheetdialog input {
  width: 5em;
  height: 2em;
  line-height: 2em;
  padding: 0 0.5em;
  background-color: #fff;
  border: 2px solid #c1ccd3;
  border-radius: 3px;
  color: #7b879e;
  margin: 0 0.2em;
}

#sheetdialog input:out-of-range,
#sheetdialog input.error {
  border-color: hsl(0, 50%, 50%);
  background: hsl(0, 50%, 90%);
}

/* imports */

#importsnav {
  position: absolute;
  width: 100%;
  height: 2.7em;
  left: 0;
  margin: 0;
  padding: 0;
  cursor: default;
  background-color: var(--progress-bg);
  display: flex;
}

#importsnav li {
  list-style: none;
  margin: 0.4em 0 0 0;
  padding: 0 0.75em 0 1.5em;
  height: 2.3em;
  line-height: 2.3em;
  background-color: var(--bg-secondary);
  border-bottom: none;
  display: flex;
  align-items: center;
  color: whitesmoke;
}

.dark-mode #importsnav li {
  color: #404247;
}

#importsnav li:first-child {
  border-top-left-radius: 5px;
  margin-left: 0.8em;
}

#importsnav li:last-child {
  border-top-right-radius: 5px;
}

#importsnav li:hover {
  background-color: #b8c3c9;
  border-color: #b8c3c9;
}

#importsnav li.active {
  background-color: #f5f7f9;
  border-color: #e4e8ed;
}

#importsnav li .close {
  display: inline-block;
  background: orangered url(img/close_dark.svg) no-repeat;
  background-size: 0.75em 0.75em;
  background-position: 50%;
  width: 0.75em;
  height: 0.75em;
  border-radius: 0.75em;
  margin-left: 0.5em;
  position: relative;
  cursor: default;
}

#importsnav li .close:hover {
  background-color: #fff;
}

#imports .import {
  width: 100%;
  height: 100%;
  display: none;
}

#imports .import.active {
  display: block;
}

.zoomtools {
  position: absolute;
  display: flex;
  top: calc(var(--nav-width) - 0.625em);
  right: 1em;
  z-index: 10;
}

.zoomtools a {
  width: 1.5em;
  height: 1.5em;
  background-color: var(--bg-secondary);
  cursor: default;
  background-position: 50%;
  background-size: 0.8em 0.8em;
  background-repeat: no-repeat;
  display: flex;
  justify-content: center;
  align-items: center;
}

.zoomtools a:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border-right: 1px solid #cdd8e0;
}

.zoomtools a:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  border-left: 1px solid #cdd8e0;
}

.zoomtools a:hover {
  background-color: #cdd8e0;
}

.zoomtools a:active {
  filter: invert(100%);
}

.zoomin {
  background-image: url(img/plus.svg);
}

.zoomout {
  background-image: url(img/minus.svg);
}

.zoomreset {
  background-image: url(img/reset.svg);
  background-size: 1.1em 1.1em;
}

/* svg styles*/

#imports svg,
#bins svg {
  width: 100%;
  height: 100%;
  margin: 0;
  display: block;
  overflow: visible;
}

#imports svg * {
  fill: #fff !important;
  fill-opacity: 0 !important;
  stroke: #404247 !important;
  stroke-width: 1px !important;
  vector-effect: non-scaling-stroke !important;
  stroke-linejoin: round !important;
}

#imports svg *.active {
  stroke: #10ccff !important;
  stroke-width: 2px !important;
}

#imports svg *.error {
  stroke: #f00 !important;
}

#bins svg {
  margin-bottom: 2em;
}

#bins svg.grid {
  float: left;
  width: 45%;
  margin-right: 5%;
  min-width: 20em;
}

#bins svg * {
  fill: #8498d1 !important;
  stroke: #617bb5 !important;
  stroke-width: 2px !important;
  vector-effect: non-scaling-stroke !important;
  stroke-linejoin: round !important;
}

#bins svg .bin {
  fill: #ffffff !important;
  stroke: #8498d1 !important;
}

#bins svg .hole {
  fill: #ffffff !important;
  stroke: #617bb5 !important;
}

/* messages */

#messagewrapper {
  position: absolute;
  top: calc(var(--nav-width) - 0.625em);
  right: 0;
  z-index: 21;
  padding: 1.2em 3em 1.2em 10em;
  background-image: linear-gradient(
    to right top,
    rgba(255, 255, 255, 0),
    var(--message-bg)
  );
  opacity: 0;
  transition: opacity 0.5s;
  cursor: default;
  display: flex;
  align-items: center;
  pointer-events: none; /* Prevent interaction when no message is displayed */
}

#messagewrapper.active {
  opacity: 1;
  pointer-events: auto; /* Allow interaction when a message is displayed */
}

#messagewrapper .close {
  border-radius: 5em;
  width: 1.8em;
  height: 1.8em;
  padding: 0;
  margin: 0 0 0 1.5em;
  background-position: 50%;
}

#messagecontent {
  margin-right: auto;
}

#message.error {
  color: #ff314e;
  font-weight: bold;
}

/* nest slide in */
#main,
#nest {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  transition: left 0.2s;
}

#main {
  left: 100%;
}

#main.active {
  left: 0;
}

#nest {
  left: -100%;
  background-color: #404247;
}

#nest.active {
  left: 0;
}

/* nest page */
#nestcontent {
  background-color: transparent;
  color: #ccc;
  width: 100%;
  height: calc(100% - 2 * (var(--nav-width) - 0.625em));
  position: relative;
  display: flex;
}

#nestinfo {
  width: 15%;
  height: 100%;
  padding: 5em 5%;
  position: absolute;
  left: -50%;
  display: flex;
  flex-direction: column;
}

#nestinfo.active {
  transition: left 1.5s;
  left: 0;
}

#nestinfo h1 {
  margin-bottom: 0em;
}

#nestlist {
  width: 100%;
  margin-top: 1em;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.nest {
  display: block;
  width: 100%;
  height: 2em;
  margin-bottom: 1.5em;
  border-radius: 3em;
  background-color: #2d2e30;
}

.nest_inner {
  width: 100%;
  height: 2em;
  display: flex;
  flex-direction: row;
  border-radius: 3em;
  overflow: hidden;
}

.nest i {
  display: block;
  height: 100%;
  flex: 1;
}

.nest i:last-child {
  margin: 0;
}

/* fade out nests */

#nestlist .nest:nth-child(2) {
  opacity: 0.9;
}

#nestlist .nest:nth-child(3) {
  opacity: 0.8;
}

#nestlist .nest:nth-child(4) {
  opacity: 0.7;
}

#nestlist .nest:nth-child(5) {
  opacity: 0.6;
}

#nestlist .nest:nth-child(6) {
  opacity: 0.5;
}

#nestlist .nest:nth-child(7) {
  opacity: 0.4;
}

#nestlist .nest:nth-child(8) {
  opacity: 0.3;
}

#nestlist .nest:nth-child(9) {
  opacity: 0.2;
}

#nestlist .nest:nth-child(10) {
  opacity: 0.1;
}

#nestlist .nest:nth-child(n + 10) {
  display: none;
}

.nest:hover {
  border: 2px solid #24c7ed;
  margin-top: -2px;
  margin-left: -2px;
  margin-bottom: calc(1.5em - 2px);
}

.nest.active {
  border: 3px solid #1c1d1e;
  margin-top: -3px;
  margin-left: -3px;
  margin-bottom: calc(1.5em - 3px);
}

#nestdisplay {
  width: 75%;
  height: 100%;
  position: absolute;
  right: 0;
  bottom: 0;
  overflow: scroll;
  height: calc(100% - 2 * (var(--nav-width) - 0.625em));
}

#nestdisplay svg {
  width: 95%;
  height: auto;
  margin: 0 5% 0 0;
  display: block;
  overflow: visible;
}

#nestdisplay svg g.sheet,
#nestdisplay svg g.part {
  opacity: 0;
  /*transition: 1.5s;*/
}

#nestdisplay svg g.sheet.active,
#nestdisplay svg g.part.active {
  opacity: 1;
}

#nestdisplay svg * {
  stroke: #fff;
  stroke-width: 1px !important;
  vector-effect: non-scaling-stroke !important;
  stroke-linejoin: round !important;
}

#nestdisplay line.merged {
  opacity: 0;
  transition: opacity 2s;
  stroke: #a4f2ff;
  stroke-width: 3px !important;
}

#nestdisplay line.merged.active {
  opacity: 1;
  animation: pulsate 2s ease-out;
  animation-iteration-count: infinite;
}

/* progress */
li.progress {
  list-style: none;
  margin: 0.15em 0.5em 0 auto;
  width: calc(var(--nav-width) - 2.8em);
  height: calc(var(--nav-width) - 2.8em);
  opacity: 0;
  transition: opacity 1.5s;
  display: flex;
  justify-content: center;
  align-items: center;
}

li.progress.active {
  opacity: 1;
}

li.progress svg {
  width: 100%;
}

li.progress svg .bar {
  stroke-dasharray: 111;
  stroke-dashoffset: 111;
}

/* login */

.topnav .account {
  margin-left: auto;
  margin-right: 3em;
  padding: 0 0 0 2em;
  height: 3.7em;
  line-height: 3.7em;
  background: transparent url(img/account_dark.svg) no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 0 50%;
  cursor: default;
  display: flex;
  align-items: center;
}

.topnav .account a {
  cursor: pointer;
}

.topnav .account.spinner {
  background: transparent url(img/spin_dark.svg) no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 0 50%;
}

.account_credits,
.account_purchase,
.account_unlimited {
  margin: 0 1em;
  padding-left: 2em;
  height: 3.7em;
  display: inline-block;
}

.account_credits {
  margin-left: 2em;
  background: transparent url(img/credits.svg) no-repeat;
  background-size: 1.6em 1.6em;
  background-position: 0 50%;
}

.account_purchase {
  margin-left: 1.2em;
  margin-right: 1em;
  background: transparent url(img/shop_dark.svg) no-repeat;
  background-size: 1.4em 1.4em;
  background-position: 0 50%;
}

.account_unlimited {
  padding-left: 2.2em;
  background: transparent url(img/unlimited.svg) no-repeat;
  background-size: 1.8em 1.8em;
  background-position: 0 50%;
}

#nest .account {
  background: transparent url(img/account.svg) no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 0 50%;
  color: #fff;
}

#nest .account.spinner {
  background: transparent url(img/spin.svg) no-repeat;
  background-size: 1.5em 1.5em;
  background-position: 0 50%;
}

#nest .account_credits {
  background: transparent url(img/credits_light.svg) no-repeat;
  background-size: 1.6em 1.6em;
  background-position: 0 50%;
}

#nest .account_purchase {
  background: transparent url(img/shop.svg) no-repeat;
  background-size: 1.4em 1.4em;
  background-position: 0 50%;
}

#nest .account_unlimited {
  padding-left: 2.2em;
  background: transparent url(img/unlimited_light.svg) no-repeat;
  background-size: 1.8em 1.8em;
  background-position: 0 50%;
}

/* animations taken from animate.css */

.animated {
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@keyframes pulsate {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@-webkit-keyframes bounce {
  from,
  20%,
  53%,
  80%,
  to {
    -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }

  40%,
  43% {
    -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    -webkit-transform: translate3d(0, -30px, 0);
    transform: translate3d(0, -30px, 0);
  }

  70% {
    -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    -webkit-transform: translate3d(0, -15px, 0);
    transform: translate3d(0, -15px, 0);
  }

  90% {
    -webkit-transform: translate3d(0, -4px, 0);
    transform: translate3d(0, -4px, 0);
  }
}

@keyframes bounce {
  from,
  20%,
  53%,
  80%,
  to {
    -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }

  40%,
  43% {
    -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    -webkit-transform: translate3d(-30px, 0, 0);
    transform: translate3d(-30px, 0, 0);
  }

  70% {
    -webkit-animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
    -webkit-transform: translate3d(-15px, 0, 0);
    transform: translate3d(-15px, 0, 0);
  }

  90% {
    -webkit-transform: translate3d(0, -4px, 0);
    transform: translate3d(-4px, 0, 0);
  }
}

.bounce {
  /*-webkit-animation-name: bounce;*/
  animation-name: bounce;
  -webkit-transform-origin: center bottom;
  transform-origin: center bottom;
}

@-webkit-keyframes slideInUp {
  from {
    -webkit-transform: translate3d(0, 100%, 0);
    transform: translate3d(0, 100%, 0);
    visibility: visible;
  }

  to {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInUp {
  from {
    -webkit-transform: translate3d(0, 100%, 0);
    transform: translate3d(0, 100%, 0);
    visibility: visible;
  }

  to {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

.slideInUp {
  -webkit-animation-name: slideInUp;
  animation-name: slideInUp;
}

.button:hover {
  background-color: var(--button-hover);
}
/* Update table styles */
#parts table input[type="text"],
#parts table input[type="number"] {
  background-color: transparent;
  color: var(--text-primary);
}
/* SVG styles for dark mode */
body.dark-mode #parts table svg * {
  stroke: var(--text-primary) !important;
}
body.dark-mode #bins svg * {
  fill: #4a5a8d !important;
  stroke: #3a4a7d !important;
}
body.dark-mode #nestdisplay svg * {
  stroke: var(--text-primary);
}
/* Navigation */
#sidenav {
  background-color: var(--nav-bg);
}
#sidenav li:hover {
  background-color: var(--button-hover);
}
/* Config form */
#configform {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
#config input[type="text"],
#config input[type="number"] {
  background-color: var(--input-bg);
  border-color: var(--input-border);
  color: var(--input-text);
}
/* SVG elements */
#parts table svg * {
  stroke: var(--text-primary) !important;
}
#imports svg * {
  stroke: var(--text-primary) !important;
}
/* Message wrapper */
#messagewrapper {
  background-image: linear-gradient(
    to right top,
    rgba(var(--bg-primary), 0),
    var(--message-bg)
  );
}
/* Nest view */
#nest {
  background-color: var(--nest-bg);
}
.nest {
  background-color: var(--bg-secondary);
}
/* Progress bar */
#progressbar_wrapper {
  background-color: var(--progress-bg);
}
/* Buttons */
.button {
  background-color: var(--button-primary);
  color: var(--text-primary);
}
.button:hover {
  background-color: var(--button-hover);
}
.button.disabled {
  opacity: 0.5;
  background-color: var(--text-secondary);
}
/* Dropdown */
ul.dropdown {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
ul.dropdown li:hover {
  background-color: var(--button-hover);
}
/* Info page */
#info {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
/* Import section */
#imports {
  background-color: var(--bg-primary);
}
#importsnav {
  background-color: var(--progress-bg);
}
#importsnav li {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
/* Zoom tools */
.zoomtools a {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}
.zoomtools a:hover {
  background-color: var(--button-hover);
}
/* Form elements */
input,
select,
textarea {
  padding: 5px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--input-text);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--button-primary);
  outline: none;
}
/* Chrome, Edge and Safari */
*::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
*::-webkit-scrollbar-track {
  /*border-radius: 5px;*/
  background-color: #384f71;
}

*::-webkit-scrollbar-track:hover {
  background-color: #4a4d4e;
}

*::-webkit-scrollbar-track:active {
  background-color: #3e556a;
}

*::-webkit-scrollbar-thumb {
  /*border-radius: 0px;*/
  background-color: #3276a4;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: #327aa3;
}

*::-webkit-scrollbar-thumb:active {
  background-color: #3774a3;
}

body.dark-mode .unit-label {
  color: var(--text-primary);
}
body.dark-mode #configform dl.formgroup * {
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
}
/* body.dark-mode #home * {
  color: var(--text-secondary);
} */

body.dark-mode #home .topnav li.button {
  color: var(--text-primary);
}

body.dark-mode #home .topnav li.button.disabled {
  color: var(--text-secondary);
}

#parts .button {
  background-color: var(--button-primary);
  color: var(--text-primary);
}

#parts .button:hover {
  background-color: #c6bda3;
}

#parts .button:active {
  background-color: #404247;
}

#parts .button.disabled {
  background-color: #999;
}

/* Preset styles */
#presets-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

#presetSelect {
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 3px;
  height: 32px;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: var(--bg-secondary);
  margin: 15% auto;
  padding: 20px;
  border: 1px solid var(--border-color);
  width: 300px;
  min-height: 150px;
  border-radius: 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .modal-content {
  background-color: #2d2d2d;
  color: #e6e6e6;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
}

body.dark-mode .close:hover,
body.dark-mode .close:focus {
  color: #fff;
}

#presetName {
  width: 100%;
  padding: 8px;
  margin: 10px 0 15px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 3px;
}

body.dark-mode #presetName {
  background-color: #3d3d3d;
  color: #e6e6e6;
  border-color: #555;
}

#confirmSavePreset {
  float: right;
}

#deletePresetBtn.delete {
  color: #e74c3c;
}

/* Prevent interaction while modal is shown */
.modal-open {
  overflow: hidden;
}
