/* The original tablist owns navigation and the visibility of every panel. */
body:is([data-study-palette="d2-neutral"],[data-study-palette="pine-white"]) #customization-options.has-swatch-library {
  --ks-ink: #2a352a;
  --ks-muted: #536055;
  --ks-line: #ccd0c8;
  --ks-active: #3f6543;
  --ks-stage: #f0f1ec;

  & .ks-panel-content {
    width: 100%;
    max-width: 1040px;
    min-width: 0;
    margin-inline: auto;
    color: var(--ks-ink);
  }
  & .ks-supplier { margin: 0 0 16px; color: var(--ks-muted); line-height: 1.5; }
  & .ks-grid { display: grid; gap: 16px 12px; margin: 0; padding: 0; }
  & .ks-grid[data-kind="materials"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  & .ks-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    color: var(--ks-ink);
    font: inherit;
    text-align: center;
    letter-spacing: normal;
    text-transform: none;
    appearance: none;
    cursor: pointer;
  }
  & .ks-face { position: relative; display: grid; place-items: center; width: 100%; min-width: 0; box-sizing: border-box; background: var(--ks-stage); border-radius: 3px; overflow: hidden; }
  & [data-kind="materials"] .ks-face { aspect-ratio: 220 / 124; background: #eeede7; }
  & .ks-face svg { display: block; min-width: 0; min-height: 0; }
  & .ks-caption { color: inherit; font-size: .93rem; font-weight: 500; line-height: 1.3; overflow-wrap: break-word; }
  & [aria-pressed="true"] .ks-face { outline: 2px solid var(--ks-active); outline-offset: -2px; }
  & .ks-choice[aria-pressed="true"]::before, & .ks-choice[aria-pressed="true"]::after {
    content: ''; position: absolute; z-index: 3; pointer-events: none;
  }
  & .ks-choice[aria-pressed="true"]::before { top: 5px; right: 5px; width: 18px; height: 18px; border-radius: 50%; background: var(--ks-active); }
  & .ks-choice[aria-pressed="true"]::after { top: 10px; right: 10px; width: 8px; height: 4px; border: solid white; border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg); }

  & #option-panel-lenses .ks-panel-content { max-width: 880px; }
  & .ks-grid[data-kind="lenses"] {
    --ks-disc: clamp(100px, 12vw, 146px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding-block-start: 5px;
  }
  & [data-kind="lenses"] .ks-choice { gap: 6px; padding: 14px 0 16px; }
  & [data-kind="lenses"] .ks-face {
    height: var(--ks-disc);
    background: transparent;
    border-radius: 0;
    overflow: visible;
    outline: none;
  }
  & [data-kind="lenses"] .ks-face > :first-child { max-width: var(--ks-disc); max-height: var(--ks-disc); }
  & [data-kind="lenses"] .ks-caption { align-self: center; padding-inline: 4px; }
  & [data-kind="lenses"] .ks-choice[aria-pressed="true"] .ks-caption { color: #325938; text-decoration: underline; text-underline-offset: .22em; }
  & [data-kind="lenses"] .ks-choice[aria-pressed="true"]::before { top: 20px; right: calc(50% - var(--ks-disc) * .46); box-shadow: 0 0 0 2px var(--study-paper); }
  & [data-kind="lenses"] .ks-choice[aria-pressed="true"]::after { top: 25px; right: calc(50% - var(--ks-disc) * .46 + 5px); }

  & :is(.ks-choice, .ks-discuss):focus-visible { z-index: 4; outline: 2px solid var(--ks-active); outline-offset: 2px; }
  & .ks-brief { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 20px; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--ks-line); }
  & .ks-note { max-width: 68ch; margin: 0; color: var(--ks-muted); font-size: .875rem; line-height: 1.5; }
  & .ks-discuss { display: inline-flex; min-height: 44px; align-items: center; color: var(--ks-active); font-size: .94rem; font-weight: 600; text-decoration: underline; text-underline-offset: .25em; }
  @media (hover: hover) {
    & .ks-choice:hover .ks-caption { text-decoration: underline; text-underline-offset: .22em; }
  }
  @media (max-width: 600px) {
    & .ks-grid { gap: 14px 8px; }
    & .ks-grid[data-kind="materials"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    & .ks-grid[data-kind="lenses"] {
      --ks-disc: clamp(54px, 18vw, 94px);
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0;
    }
    & [data-kind="lenses"] .ks-choice { padding-block: 10px 12px; }
    & [data-kind="lenses"] .ks-choice[aria-pressed="true"]::before { top: 14px; }
    & [data-kind="lenses"] .ks-choice[aria-pressed="true"]::after { top: 19px; }
    & .ks-caption { font-size: .875rem; }
  }
}

/* Plate samples are filed behind shared slot edges. Their enlarged face uses
   the same artwork, with a drilled corner and visible sheet thickness. */
body:is([data-study-palette="d2-neutral"],[data-study-palette="pine-white"]) #option-panel-materials {
  & .ks-material-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    align-items: start;
    gap: clamp(24px, 4vw, 54px);
  }
  & .ks-material-box {
    --chip-height: clamp(44px, 4.5vw, 66px);
    --case: #efefeb;
    container-type: inline-size;
    min-width: 0;
    padding: clamp(14px, 2vw, 25px);
    background: var(--case);
    border: 1px solid #c9cbc3;
    border-radius: 5px;
    box-shadow: inset 0 0 0 3px #f7f7f3, 0 3px 0 -1px #d9dbd3;
  }
  & .ks-bin + .ks-bin { margin-top: 22px; }
  & .ks-bin-title { margin: 0 0 7px; font-family: inherit; font-size: .92rem; font-weight: 650; line-height: 1.4; letter-spacing: 0; }
  & .ks-bin-slots {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px 0;
    padding-top: 8px;
  }
  & .ks-bin-slots[data-family="other"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  & .ks-material-chip {
    position: relative;
    display: grid;
    grid-template-rows: var(--chip-height) auto;
    align-content: start;
    align-self: stretch;
    justify-items: center;
    min-width: 0;
    padding: 0 0 4px;
    border: 0;
    border-radius: 0;
    appearance: none;
    background: transparent;
    color: var(--ks-ink);
    font: inherit;
    cursor: pointer;
  }
  /* The partition sits in front of the bottom of each stored chip. Its edge
     continues across adjacent slots, including those with wrapped captions. */
  & .ks-material-chip::before {
    content: '';
    position: absolute;
    z-index: 2;
    pointer-events: none;
    inset: calc(var(--chip-height) - 5px) 0 auto;
    height: 6px;
    background: linear-gradient(#dbddd5 0 1px, #f6f7f3 1px 3px, #c8ccc2);
    border-bottom: 1px solid #a8ada1;
  }
  & .ks-chip-face {
    display: block;
    position: relative;
    align-self: end;
    width: 75%;
    height: 86%;
    min-width: 0;
    border-radius: 4px 4px 1px 1px;
    overflow: hidden;
    transform: perspective(180px) rotateX(10deg) rotate(-2deg);
    transform-origin: 50% 100%;
    box-shadow: inset 0 0 0 1px #16201525, 1px 1px 0 #7a8077, 3px 2px 0 #c3c5bd, 0 3px 4px #2e342923;
    transition: transform .18s ease-out;
  }
  & [data-family="other"] .ks-chip-face { width: 56%; }
  & :is(.ks-chip-face, .ks-detail-stage) > :is(svg,img,canvas) {
    display: block;
    height: 100%;
    width: 100%;
    max-width: none;
    object-fit: cover;
  }
  & .ks-chip-face::after, & .ks-detail-stage::after {
    content: '';
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
  }
  & .ks-chip-face::after { top: 9%; left: 7%; width: 4px; background: var(--case); box-shadow: inset 0 1px 1px #282d2599; }
  & .ks-chip-name {
    align-self: start;
    padding: 6px 4px 0;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.32;
    text-wrap: balance;
    overflow-wrap: anywhere;
  }
  & .ks-material-chip[aria-pressed="true"] .ks-chip-face {
    transform: translateY(-5px) rotate(0);
    box-shadow: 1px 1px 0 #778172, 2px 2px 0 #b7bcaf, 0 3px 5px #39403433;
  }
  & .ks-material-chip[aria-pressed="true"] .ks-chip-name { color: #2f5536; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
  & .ks-material-chip[data-added="true"] .ks-chip-name::after {
    display: inline-block;
    content: '';
    width: 7px;
    height: 4px;
    margin: 0 0 3px 4px;
    border: solid var(--ks-active);
    border-width: 0 0 1.5px 1.5px;
    transform: rotate(-45deg);
  }
  & .ks-material-detail { min-width: 0; scroll-margin-top: 90px; padding-top: 3px; }
  & .ks-detail-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1.25;
    overflow: hidden;
    border-radius: 9px 9px 6px 6px;
    background: #f3f3ef;
    box-shadow: 0 1px 0 #797c71, 0 3px 0 #b6b9b0, 0 6px 8px -5px #343d3040;
  }
  & .ks-detail-stage::after { width: 2.4%; top: 6%; left: 5%; background: var(--study-paper,#fafaf8); box-shadow: inset 0 1px 2px #34392caa, 0 1px 0 #ffffff69; }
  & .ks-detail-meta { margin-top: 18px; }
  & .ks-detail-family { display: block; color: var(--ks-muted); font-size: .8rem; line-height: 1.4; }
  & .ks-detail-title { margin: 4px 0 0; font: inherit; font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 580; line-height: 1.16; letter-spacing: -.02em; overflow-wrap: anywhere; }
  & .ks-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 15px; margin-top: 14px; }
  & :is(.ks-add-material,.ks-back-to-box) { min-height: 44px; border: 0; box-shadow: none; font: inherit; font-size: .9rem; line-height: 1.3; font-weight: 600; cursor: pointer; }
  & .ks-add-material { padding: 9px 17px; border: 1px solid var(--ks-active); border-radius: 4px; background: var(--ks-active); color: #fff; }
  & .ks-add-material[aria-pressed="true"] { background: transparent; color: var(--ks-active); }
  & .ks-back-to-box { display: none; padding: 6px 2px; background: transparent; color: var(--ks-ink); text-decoration: underline; text-underline-offset: .22em; }
  & :is(.ks-material-chip,.ks-back-to-box,.ks-add-material):focus-visible { outline: 2px solid var(--ks-active); outline-offset: 2px; }
  @media (hover: hover) {
    & .ks-material-chip[aria-pressed="false"]:hover .ks-chip-face { transform: translateY(-3px) rotate(-1deg); }
    & .ks-add-material:hover { background: #315239; color: white; }
  }
  @media (max-width: 700px) {
    & .ks-material-workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    & .ks-material-detail { grid-row: 1; padding: 0; }
    & .ks-detail-stage { aspect-ratio: auto; height: clamp(124px, 39vw, 236px); border-radius: 6px; }
    & .ks-detail-meta { margin-top: 11px; }
    & .ks-detail-title { font-size: 1.32rem; }
    & .ks-detail-actions { margin-top: 6px; gap: 4px 10px; }
    & .ks-add-material { padding-inline: 12px; }
    & .ks-back-to-box { display: inline-block; }
    & .ks-material-box { --chip-height: clamp(42px, 11vw, 58px); padding: 12px; }
    & .ks-chip-face { width: 78%; }
    & .ks-chip-name { font-size: .8rem; }
    & .ks-bin + .ks-bin { margin-top: 16px; }
  }
  @media (max-width: 359px) {
    & .ks-bin-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    & [data-family="other"] .ks-chip-face { width: 78%; }
  }
  @container (max-width: 366px) {
    html[lang^="en"] & .ks-bin-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    html[lang^="en"] & [data-family="other"] .ks-chip-face { width: 75%; }
    html[lang^="en"] & .ks-chip-name { padding-inline: 1px; font-size: .8rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    & .ks-chip-face { transition: none; }
  }
}

/* The index stays flat so the curves, highlights and bevels live on the large samples. */
body:is([data-study-palette="d2-neutral"],[data-study-palette="pine-white"]) #customization-options.has-swatch-library #option-panel-shapes {
  & .ks-shape-instruction {
    margin: 0 0 12px;
    color: var(--ks-muted);
    font: inherit;
    font-size: .94rem;
    line-height: 1.5;
  }
  & .ks-grid[data-kind="shapes"] {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px 8px;
  }
  & .ks-choice {
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    padding: 3px 0 10px;
    border-bottom: 1px solid var(--ks-line);
  }
  & .ks-face {
    height: clamp(52px, 5.6vw, 74px);
    background: none;
    border-radius: 0;
    outline: 0;
  }
  & .ks-face path[fill="#F8F8F3"] { fill: none; }
  & .ks-choice[aria-pressed="true"] {
    border-bottom-color: var(--ks-active);
    box-shadow: inset 0 -1px var(--ks-active);
    color: var(--ks-active);
  }
  & .ks-choice[aria-pressed="true"]::before,
  & .ks-choice[aria-pressed="true"]::after { content: none; }
  & .ks-choice[aria-pressed="true"] .ks-caption {
    font-weight: 650;
  }
  & .ks-choice[aria-pressed="true"] .ks-caption::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 4px;
    margin: 0 5px .22em 0;
    transform: rotate(-45deg);
    border: solid currentColor;
    border-width: 0 0 1.6px 1.6px;
  }
  & .ks-shape-models {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 28px;
    margin-block: clamp(20px, 2.6vw, 38px) 20px;
    --compare-gutter: clamp(15px, 2.1vw, 32px);
  }
  & .ks-shape-model {
    display: block;
    min-width: 0;
    margin: 0;
    padding-inline-end: var(--compare-gutter);
  }
  & .ks-shape-model:nth-child(even) {
    position: relative;
    padding-inline: var(--compare-gutter) 0;
  }
  & .ks-shape-model:nth-child(even)::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    border-inline-start: 1px solid var(--ks-line);
  }
  & .ks-shape-model:only-child {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 630px);
    padding: 0;
  }
  & .ks-shape-zoom {
    appearance: none;
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 5px 0 21px;
    color: var(--ks-muted);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: zoom-in;
  }
  & :is(.ks-shape-zoom, .ks-shape-close):focus-visible {
    outline: 2px solid var(--ks-active);
    outline-offset: 2px;
  }
  & :is(.ks-shape-zoom img, .ks-shape-dialog-image) {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
  }
  & .ks-shape-expand {
    position: absolute;
    right: 2px;
    bottom: 1px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    pointer-events: none;
  }
  & .ks-shape-expand svg { display: block; width: 16px; height: 16px; }
  & .ks-shape-model figcaption { padding: 6px 0 0; text-align: start; }
  & .ks-shape-example {
    display: block;
    margin: 0 0 3px;
    color: var(--ks-muted);
    font-weight: 500;
    font-size: .78rem;
    line-height: 1.4;
  }
  & :is(.ks-shape-name, .ks-shape-dialog-title) {
    margin: 0;
    color: var(--ks-ink);
    font-family: inherit;
    font-size: clamp(1.22rem, 2vw, 1.7rem);
    font-weight: 580;
    line-height: 1.24;
    letter-spacing: -.022em;
  }
  & .ks-shape-note {
    margin: 5px 0 0;
    color: var(--ks-muted);
    font-size: .94rem;
    line-height: 1.5;
    overflow-wrap: break-word;
  }
  & .ks-shape-dialog {
    box-sizing: border-box;
    inset: 0;
    width: min(920px, calc(100% - 36px));
    max-width: none;
    max-height: calc(100dvh - 36px);
    margin: auto;
    padding: clamp(18px, 3vw, 40px);
    color: var(--ks-ink);
    background: var(--study-paper, #fafaf8);
    border: 0;
    border-radius: 3px;
    overflow: auto;
  }
  & .ks-shape-dialog::backdrop { background: rgb(25 31 27 / 54%); }
  & .ks-shape-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-block-end: 15px;
  }
  & .ks-shape-close {
    appearance: none;
    min-width: 44px;
    min-height: 44px;
    padding: 4px 6px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: var(--ks-active);
    background: transparent;
    font: inherit;
    font-size: .94rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: .22em;
    cursor: pointer;
  }
  & .ks-shape-dialog-image { max-height: 58dvh; }
  @media (max-width: 800px) {
    & .ks-grid[data-kind="shapes"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  @media (max-width: 600px) {
    & .ks-grid[data-kind="shapes"] { gap: 8px 5px; }
    & .ks-shape-instruction { margin-bottom: 8px; font-size: .9rem !important; }
    & .ks-choice { gap: 2px; padding: 2px 0 6px; }
    & .ks-face { height: clamp(35px, 10vw, 54px); }
    & .ks-caption { font-size: .8rem; line-height: 1.36; }
    & .ks-shape-models { --compare-gutter: 8px; margin-block: 21px 16px; row-gap: 20px; }
    & .ks-shape-name { font-size: 1.12rem; }
    & .ks-shape-note { margin-top: 4px; font-size: .875rem !important; }
    & .ks-shape-zoom { padding: 1px 0 18px; }
    & .ks-shape-expand { width: 16px; height: 16px; }
    & .ks-shape-expand svg { width: 14px; height: 14px; }
    & .ks-shape-model figcaption { padding-top: 4px; }
    & .ks-shape-dialog { width: calc(100% - 24px); padding: 16px 12px; }
    & .ks-shape-dialog-head { margin-bottom: 10px; }
  }
  @media (max-width: 359px) {
    & .ks-grid[data-kind="shapes"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
}
