
body {
  font-family: var(--font-family), monospace;
  font-size: var(--font-size-m);
  font-weight: 500;
  line-height: var(--space-20);
  letter-spacing: -0.01em;
  color: var(--color-black);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}
input, button, select, textarea {
  border: none;
  transition: background-color 0.2s;
}
::selection {
  background-color: var(--color-black) !important;
  color: var(--color-grey-82) !important;
}

/* ======= Utility Classes ======= */
.height-24 {
  height: var(--space-24) !important;
  min-height: var(--space-24) !important;
}
.full-width {
  width: 100% !important;
}
.padding-top-8 {
  padding-top: var(--space-08) !important;
}
.disabled {
  opacity: 0.25 !important;
  pointer-events: none;
  cursor: default;
}
.no-shrink {
  flex-shrink: 0;
}

.width-content {
  width: fit-content !important;
}


/* ======= Header ======= */

.header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-32);
  padding: var(--space-24);
}

.header-leading {
  height: var(--space-36);
  flex: 8 1 0;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-24);

  & > * {
    flex: 0 1 auto;
  }
}

.logo-group {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-08);
  font-weight: 600;
  font-size: var(--font-size-xl);
  user-select: none;
  & > span {
    padding-bottom: var(--space-04);
  }
}
.logo-icon {
  width: var(--space-20);
  height: var(--space-20);
  background-color: var(--color-black);
}

.cell-size-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-08);
}

.cell-controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--space-08);

  & > .slider-container {
    flex: 0 0 10rem !important;
    width: var(--space-48);
  }
}

.source-management-block {
  flex: 0 1 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  & > *:last-child {
    flex: 0 1 auto;
    padding-left: var(--space-24);

    & > * {
      flex: 0 0 auto;
    }
  }
}

.header-buttons {
  flex: 1 1 0;
  min-width: 240px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-12);

  & > button {
    height: var(--space-36);
  }
}

.preview-buttons {
  display: flex;
  flex-direction: row;
  gap: var(--space-08);
  width: 100%;
}


/* ======= Main Section & Preview ======= */
.app-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-08);
  height: 100vh;
}

.main-section {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  background-color: var(--color-white);
  padding: 0 var(--space-24) var(--space-24);
  gap: var(--space-24);
  overflow: hidden;
}

.preview-area {
  flex: 8 1 0;
  min-width: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: start;
  align-items: start;
  background-color: transparent;
  gap: var(--space-48);

}
.canvas-container {
  max-width: 1080px;
  max-height: 720px;
  width: 100%;
  height: 100%;
}

.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.info {
  height: fit-content;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: start;
  gap: var(--space-32);
  color: var(--color-grey-56);
  font-size: var(--font-size-xs);
  line-height: 1.1em;

  & > span:first-child {
    flex: 1 1 0;
    min-width: 0;
  }
  & > span:nth-child(2) {
    flex: 1 1 0;
    min-width: 0;
  }
  & > span:last-child {
    flex: 3 1 0;
    min-width: 0;
  }

    & > span > a {
      text-decoration: underline;
    &:hover {
      color: var(--color-black);
    }
  }
}


/* ======= Sidebar ======= */
.sidebar {
  flex: 3 1 0;
  min-width: 340px;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-08);
  background-color: transparent;
}
.layers-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-08);
}

.scroll-wrapper {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.scroll-wrapper::before,
.scroll-wrapper::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: var(--space-44);
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
  opacity: 0;
}

.scroll-wrapper::before {
  top: -1px;
  background: linear-gradient(to bottom, var(--color-white) 0%, transparent 100%);
}
.scroll-wrapper::after {
  bottom: -1px;
  background: linear-gradient(to top, var(--color-white) 0%, transparent 100%);
}

.scroll-wrapper.can-scroll-up::before { opacity: 1; }
.scroll-wrapper.can-scroll-down::after { opacity: 1; }

.scroll-container {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-08);

  scrollbar-width: none;
  -ms-overflow-style: none;
  &::-webkit-scrollbar {
    display: none;
  }
}


/* ======= Panels Common Styles ======= */
.layer-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  min-height: 0;
  padding: var(--space-20);
  overflow: hidden;
  background-color: var(--color-grey-94);
  will-change: height;
  transition: height 0.3s ease,
              gap 0.3s ease;

  & > *:not(.panel-header) {
    opacity: 1;
    transition: opacity 0.5s ease;
  }

}


/* ======= Panel Header ======= */
.panel-header {
  height: var(--space-24);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-header.layer-header {
  height: var(--space-20);
}

.header-title-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-08);
  font-weight: 600;
}

.header-title-group span {
  cursor: default;
}

/* ======= Panel Elements ======= */

.panel-divider {
  width: 100%;
  height: var(--space-01);
  min-height: var(--space-01);
  margin: var(--space-02) 0;
  background-color: var(--color-grey-86);
}

.control-row {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-08);
  opacity: 1;
  transition: opacity 0.2s ease;
  &.hidden {
    opacity: 0;
    transition: opacity 0.2s ease;
  }
}

/* ======= Controls / Main ======= */
.control-label {
  color: var(--color-black);
  cursor: default;
}

.toggle-label {
  color: var(--color-black);
  cursor: default;
}

.toggle-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-08);
}

/* ======= Controls / Text Field ======= */
.symb-text-field {
  width: 12rem;
  height: var(--space-20);
  padding: 0 var(--space-06);
  background-color: transparent;
  cursor: text;
  text-transform: uppercase;
  &:focus {
    outline: none;
  }
  &:hover {
    text-decoration: underline;
  }
}

/* ======= Controls / Color Picker ======= */
.color-picker-group {
  width: 9.2rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-08);
}

.color-picker-input {
  width: var(--space-56);
  height: var(--space-20);
  border: none;
  border-radius: 0;
  background-color: transparent;
  cursor: text;
  text-transform: uppercase;
  &:focus {
    outline: none;
  }
}

input.color-picker {
  width: var(--space-20);
  height: var(--space-20);
  border: none;
  border-radius: 0;
  background-color: transparent;
  cursor: pointer;
}

input.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
input.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 0;
  padding: 0;
}

/* ======= Controls / Segmented Group ======= */
.segmented {
  display: flex;
  gap: var(--space-16);
}
.segmented-item {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;

  & span {
  display: block;
  color: var(--color-grey-64);
  padding: 0 var(--space-04);
  transition: color 0.1s;
  }

  & span:hover {
    color: var(--color-black);
  }

  &:has(input:checked) span {
    color: var(--color-black);
    font-weight: 600;
  }
}
.segmented input {
  position: absolute;
  width: 0;
  left: 0;

  &::before {
    position: absolute;
    transform: translateX(calc(-1 * var(--space-12)));
    content: "/";
    color: var(--color-grey-64);
    user-select: none;
  }
}
.segmented-item:first-child input::before {
  content: none;
}

input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
}



/* ======= Controls / Buttons ======= */
button {
  z-index: 0;
  position: relative;
  height: var(--space-44);
  padding-bottom: var(--space-01);
  background-color: transparent;
  cursor: pointer;
  user-select: none;

  &::before {
    z-index: -1;
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0rem;
    transition: border-radius var(--duration-short) ease, 
                background-color var(--duration-short) ease 0.1s;
  }
  &:hover::before {
    border-radius: var(--space-22);
  }
  &:disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
    &:hover {
      cursor: default !important;
    }
  }
}

/* ======= Controls / Buttons / Primary ======= */
button.primary {
  color: var(--color-white);
  &::before {
    background-color: var(--color-black);
  }
}

/* ======= Controls / Buttons / Secondary ======= */
button.secondary {
  color: var(--color-black);
  &::before {
    background-color: var(--color-grey-86);
  }
  &:hover::before {
    background-color: var(--color-grey-82);
  }
}

/* ======= Controls / Buttons / Text ======= */
button.text-button {
  position: relative;
  height: auto;
  padding: 0 var(--space-04);
  color: var(--color-grey-64);
  transition: color 0.1s;
  &:hover {
    color: var(--color-black);
    border-radius: var(--space-24);
  }
}

/* ======= Controls / Toggle Button ======= */
.toggle-btn-group {
  width: 9.2rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-08);
}

/* ======= Controls / Buttons / Collapse ======= */
button.toggle-btn {
  position: relative;
  width: var(--space-20);
  height: var(--space-20);
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
  cursor: pointer;

}
.toggle-btn::before {
  content: " ";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-color: var(--color-black);
  border-radius: 0rem;
  transition: border-radius 0.2s ease,
              background-color 0.2s ease 0.1s;
}
.toggle-btn:hover::before {
  border-radius: var(--space-10);
}
.toggle-btn.off::before {
  background-color: var(--color-grey-48);
  border-radius: var(--space-10);
}
.toggle-btn.off:hover::before {
  background-color: var(--color-black);
}

.toggle-btn .svg-x-icon {
  width: var(--space-10);
  height: var(--space-10);
  transition: transform 0.35s var(--spring-bezier);
}
.svg-x-icon-path {
  transition: transform 0.35s var(--spring-bezier) 0.15s;
}

.toggle-btn.off .svg-x-icon {
  transform: rotate(-90deg);
}

.toggle-btn.off .hor {
  transform: scaleX(0);
}



/* ======= Controls / Slider ======= */
.slider-row .control-label {
  flex: 0 0 40%;
  min-width: 0;
}
.slider-container {
  flex: 0 0 calc(60% - var(--space-24));
  min-width: 0;
  padding: 0 var(--space-04);
}

.from-center .noUi-handle[data-handle="0"] {
    display: none;
}

/* ======= NoUiSlider Custom Styles ======= */
.noUi-target {
  height: var(--space-16) !important;
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
.noUi-base {
  top: 50% !important;
  transform: translateY(-50%) !important;
  border-radius: 0 !important;
  &:hover {
    cursor: pointer;

    & .noUi-connect {
      background: var(--color-grey-32) !important;
    }
    & .noUi-handle {
      background: var(--color-grey-32) !important;
    }
  }
  
}
.noUi-connects {
  height: var(--space-02) !important;
  background: var(--color-grey-82) !important;
  border-radius: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}
.noUi-connect {
  height: var(--space-02) !important;
  background: var(--color-black) !important;
  border-radius: 0 !important;
  transition: background-color 0.2s;
}
.noUi-base:has(.noUi-touch-area:hover) .noUi-connect,
.noUi-base:has(.noUi-touch-area:active) .noUi-connect {
  background: var(--color-grey-32) !important;
}

.noUi-handle {
  width: var(--space-02) !important;
  height: var(--space-16) !important;
  top: 50% !important;
  left: 100% !important;
  transform: translate(-50%, 0%) !important;

  background: var(--color-black) !important;
  cursor: pointer;
  transition: background-color 0.2s;

  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  &:hover {
    background: var(--color-grey-32) !important;
  }
  &:active {
    background: var(--color-grey-32) !important;
  }
}

.noUi-touch-area {
  width: var(--space-32) !important;
  transform: translate(-45%, -0.4rem) !important;
  height: 150% !important;
  cursor: pointer;
}

.noUi-handle.noUi-handle-lower {
  &::before {
    display: none;
  }
  &::after {
    display: none;
  }
}
.noUi-handle.noUi-handle-upper {
  &::before {
    display: none;
  }
  &::after {
    display: none;
  }
}

/* ======= Mobile Placeholder ======= */
.mobile-placeholder {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  justify-content: center;
  align-items: center;
  padding: var(--space-24);
}

.mobile-placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-24);
  text-align: center;
  max-width: 400px;
}

.mobile-placeholder-content .logo-icon {
  width: var(--space-32);
  height: var(--space-32);
  background-color: var(--color-black);
}
.mobile-placeholder-content h1 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-black);
  margin: 0;
}
.mobile-placeholder-content p {
  font-size: var(--font-size-m);
  color: var(--color-grey-56);
  margin: 0;
  line-height: 1.5;
}

/* Show placeholder on screens smaller than 768px */
@media (max-width: 800px) {
  .mobile-placeholder {
    display: flex;
  }
  
  .app-shell {
    display: none !important;
  }
}

/* Adaptive styles for buttons position */
@media (max-width: 1079px) {
  .header-buttons {
    display: none;
  }
  .preview-area {
    gap: var(--space-16);
  }
}
@media (max-width: 960px) {
  .info-text-pause {
    display: none;
  }
}