:root {
  color-scheme: light;
  --ink: #1e2320;
  --muted: #66716c;
  --line: #d9dfdc;
  --paper: #f6f4ef;
  --panel: #ffffff;
  --accent: #24705d;
  --accent-dark: #16483d;
  --canvas-active-highlight: #f2b705;
  --shadow: 0 24px 70px rgba(28, 35, 31, 0.18);
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/silkscreen-400.ttf") format("truetype");
}

@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/silkscreen-700.ttf") format("truetype");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Silkscreen", ui-sans-serif, system-ui, sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: min(2.4vh, 24px) clamp(16px, 3vw, 44px) min(5vh, 44px);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button,
.primary-button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #eef2ef;
  color: #34413b;
  cursor: pointer;
  font-weight: 700;
}

.tab-button:hover,
.primary-button:hover {
  background: #dfe9e4;
}

.tab-button.is-active {
  background: var(--accent-dark);
  color: #fff;
}

.tab-panel[hidden] {
  display: none;
}

.eyebrow,
.meta-label,
.popover-head p {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 4.1rem;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.app-summary,
.section-heading p,
#combinationSummary,
#selectedValues {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.84fr) minmax(400px, 1.16fr);
  gap: 28px;
  align-items: start;
}

.picker-panel,
.details-panel,
.combination-panel {
  min-width: 0;
}

.details-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  max-height: calc(100dvh - 118px);
  min-height: 0;
}

.section-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.harmony-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 620px);
  margin: 0 auto 12px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.harmony-controls span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  min-width: 190px;
}

.segmented-control button {
  min-width: 0;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #eef2ef;
  color: #34413b;
  cursor: pointer;
  font-weight: 760;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--accent-dark);
  color: #fff;
}

.wheel-wrap {
  position: relative;
  width: min(100%, clamp(260px, calc(100dvh - 300px), 660px));
  min-width: 240px;
  margin: 0 auto;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

#colorWheel {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 16px 44px rgba(35, 44, 39, 0.16);
}

.selection-marker {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 3px 10px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.selected-color {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.save-control {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.15;
  text-align: center;
}

.save-slot-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 7;
  display: grid;
  gap: 10px;
  width: 210px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.save-slot-popover[hidden] {
  display: none;
}

.save-slot-popover h3 {
  font-size: 0.86rem;
}

.save-slot-list {
  display: grid;
  gap: 6px;
}

.save-slot-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.save-palette-button {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 6px;
}

.save-palette-button::before,
.save-palette-button::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.save-palette-button::after {
  inset: auto 14px 10px 14px;
  height: 8px;
  border-top: 2px solid currentColor;
  background: currentColor;
}

.selected-swatch {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.geometry-panel {
  min-height: 0;
}

.picker-palette-bank {
  display: grid;
  grid-template-columns: auto 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.picker-palette-bank .bank-heading {
  display: contents;
}

.picker-palette-bank .bank-heading h3 {
  font-size: 0.78rem;
  white-space: nowrap;
}

.picker-palette-bank .bank-heading .save-palette-button {
  width: 34px;
  height: 34px;
}

.picker-palette-bank .slot-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.geometry-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.geometry-swatch {
  position: relative;
  min-height: 92px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
}

.geometry-swatch:hover,
.geometry-swatch:focus {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.geometry-swatch-info {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  text-align: right;
  font-size: 0.76rem;
  line-height: 1.25;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.22);
}

.geometry-swatch-info strong,
.geometry-swatch-info span {
  display: block;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.combination-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2ef;
  color: #38433e;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

th:nth-child(1),
td:nth-child(1) {
  width: 116px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 82px;
}

.combo-row {
  cursor: pointer;
}

.combo-row:hover,
.combo-row:focus {
  background: #f2f7f4;
  outline: none;
}

.strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  height: 42px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
}

.strip span {
  min-width: 0;
}

.color-list {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.palette-popover {
  position: absolute;
  inset: 5%;
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.palette-popover[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.popover-head {
  padding-right: 42px;
}

.palette-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  min-height: 0;
}

.palette-color {
  position: relative;
  min-height: 180px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.14);
  cursor: pointer;
}

.palette-color:hover,
.palette-color:focus {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.palette-color-info {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  text-align: right;
  font-size: 0.88rem;
  line-height: 1.28;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
}

.palette-color-info strong,
.palette-color-info span {
  display: block;
}

.icon-button,
.help-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.help-button:hover {
  background: #edf5f1;
}

.save-palette-button {
  border-radius: 6px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-weight: 800;
}

.help-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  width: 48px;
  height: 48px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 12px 34px rgba(22, 72, 61, 0.3);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding: 20px;
  background: rgba(20, 25, 22, 0.38);
}

.about-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(620px, calc(100vh - 40px));
  overflow: auto;
  padding: 24px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.about-panel h2 {
  margin-bottom: 16px;
  font-size: 1.6rem;
}

.about-panel p {
  margin: 0 44px 12px 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty-row td {
  color: var(--muted);
  padding: 24px 14px;
}

.tool-panel {
  display: grid;
  gap: 18px;
  min-height: 0;
  max-height: calc(100dvh - 118px);
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent-dark);
}

.image-editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.asset-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 12px;
  min-height: 0;
}

.palette-bank,
.text-bank,
.emoji-bank,
.draw-tools-bank,
.image-controls {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.text-bank {
  position: relative;
}

.tool-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tool-button {
  min-width: 0;
  min-height: 34px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
}

.tool-button.is-active {
  border-color: var(--canvas-active-highlight);
  background: var(--canvas-active-highlight);
  color: var(--ink);
  box-shadow: 0 0 0 2px rgba(30, 35, 32, 0.12);
}

.draw-palette-colors {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.image-controls {
  grid-column: 1 / -1;
}

.bank-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bank-heading h3 {
  font-size: 0.92rem;
}

.text-bank-actions {
  display: inline-grid;
  grid-template-columns: repeat(2, 34px);
  gap: 6px;
}

.add-text-button,
.trash-button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.add-text-button {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.trash-button {
  position: relative;
}

.trash-button::before,
.trash-button::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  border: 2px solid currentColor;
}

.trash-button::before {
  top: 9px;
  height: 3px;
  border-bottom: 0;
}

.trash-button::after {
  top: 14px;
  bottom: 8px;
  border-top: 0;
  border-radius: 0 0 2px 2px;
}

.trash-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.bank-heading .save-palette-button {
  width: 34px;
  height: 34px;
}

.slot-list {
  display: grid;
  gap: 8px;
}

.slot-button {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.slot-button.is-active {
  border-color: var(--accent-dark);
  box-shadow: inset 0 0 0 2px rgba(22, 72, 61, 0.18);
}

.text-slot.is-active,
.emoji-slot.is-active {
  border-color: var(--canvas-active-highlight);
  box-shadow: inset 0 0 0 2px var(--canvas-active-highlight), 0 0 0 2px rgba(30, 35, 32, 0.08);
}

.slot-button.is-compact {
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 34px;
  padding: 4px;
  gap: 4px;
}

.slot-button.is-compact .slot-label {
  font-size: 0.62rem;
  text-align: center;
}

.slot-button.is-compact .slot-strip {
  height: 22px;
}

.slot-label {
  min-width: 0;
  font-size: 0.74rem;
}

.slot-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(12px, 1fr);
  height: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  place-items: center;
}

.slot-strip span {
  width: 100%;
  height: 100%;
}

.text-slot-color {
  justify-self: end;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}

.emoji-search-field {
  gap: 6px;
}

.emoji-dropdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  max-height: 154px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
}

.emoji-option {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.56rem;
}

.emoji-option.is-active {
  border-color: var(--accent-dark);
  box-shadow: inset 0 0 0 2px rgba(22, 72, 61, 0.18);
}

.emoji-option img {
  width: 28px;
  height: 28px;
  image-rendering: auto;
}

.emoji-option span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-slot-symbol {
  justify-self: end;
  width: 30px;
  height: 30px;
}

.text-editor-popover {
  position: absolute;
  top: 48px;
  right: 10px;
  left: 10px;
  z-index: 6;
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.text-editor-popover[hidden] {
  display: none;
}

.text-editor-popover h3 {
  padding-right: 40px;
  font-size: 0.95rem;
}

.editor-form {
  display: grid;
  gap: 10px;
}

.color-choice-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.color-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.color-choice {
  min-height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  cursor: pointer;
}

.color-choice.is-active {
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--accent-dark);
}

.image-canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-canvas-wrap.is-canvas-active {
  border-color: var(--canvas-active-highlight);
  box-shadow: inset 0 0 0 2px var(--canvas-active-highlight);
}

#imageCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 206px);
  object-fit: contain;
  cursor: grab;
}

#imageCanvas:active {
  cursor: grabbing;
}

.primary-button {
  background: var(--accent-dark);
  color: #fff;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .details-panel,
  .tool-panel {
    max-height: none;
  }

  .table-wrap {
    max-height: none;
  }

  h1 {
    font-size: 3.4rem;
  }

  .image-editor-grid {
    grid-template-columns: 1fr;
  }

  .asset-controls {
    grid-template-columns: 1fr 1fr;
  }

  #imageCanvas {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 12px;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.3rem;
  }

  .harmony-controls {
    display: grid;
  }

  .segmented-control {
    min-width: 0;
  }

  .wheel-wrap {
    width: min(100%, clamp(230px, calc(100dvh - 320px), 620px));
    min-width: 220px;
  }

  th,
  td {
    padding: 10px;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 86px;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: 62px;
  }

  .selected-color {
    grid-template-columns: 56px minmax(0, 1fr) 58px;
  }

  .selected-color .save-palette-button {
    width: 38px;
    height: 38px;
  }

  .selected-swatch {
    width: 56px;
    height: 56px;
  }

  .asset-controls {
    grid-template-columns: 1fr;
  }

  .palette-popover {
    inset: 0;
    padding: 14px;
  }

  .palette-blocks {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .palette-color {
    min-height: 150px;
  }
}

@media (max-height: 760px) and (min-width: 981px) {
  h1 {
    font-size: 3rem;
  }

  .section-heading {
    margin-bottom: 8px;
  }

  .selected-color {
    grid-template-columns: 54px minmax(0, 1fr) 58px;
    padding: 10px;
  }

  .selected-color .save-palette-button {
    width: 34px;
    height: 34px;
  }

  .selected-swatch {
    width: 54px;
    height: 54px;
  }

  .geometry-swatch {
    min-height: 74px;
  }
}
