:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e7e8e2;
  color: #151515;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #e7e8e2;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px;
  background: #fbfaf6;
  border-right: 1px solid #d7d5cc;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin: 8px 0 0;
  color: #66645e;
  font-size: 13px;
}

.control-group,
.field,
.grid {
  display: grid;
  gap: 8px;
}

.control-label,
.field > span,
.swatches span,
.active-part-title span,
.meta span {
  color: #5d5a53;
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid #cbc8bd;
  border-radius: 6px;
  background: #eceae2;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #4d4a44;
}

.segmented button.active {
  background: #fff;
  color: #171816;
  box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
}

.part-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.part-tabs button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid #c9c6bb;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: #292a27;
  text-align: left;
}

.part-tabs button > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5e3da;
  color: #59564f;
  font-size: 11px;
}

.part-tabs button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-tabs button.active {
  border-color: #1d6f5f;
  box-shadow: inset 0 0 0 1px #1d6f5f;
}

.part-tabs button.active > span {
  background: #1d6f5f;
  color: #fff;
}

.part-tabs button:disabled {
  opacity: 0.45;
  cursor: default;
}

.active-part-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 3px;
  border-bottom: 1px solid #dedbd2;
}

.active-part-title strong {
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c9c6bb;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: #141414;
}

input[type="range"] {
  min-height: 30px;
  padding: 0;
  accent-color: #1d6f5f;
}

input[type="color"] {
  padding: 4px;
}

output {
  float: right;
  color: #292a27;
  font-variant-numeric: tabular-nums;
}

.row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
}

.row button,
.actions button {
  min-height: 40px;
  border: 1px solid #26352f;
  border-radius: 6px;
  background: #1f2a25;
  color: #fff;
}

.row button:hover,
.actions button:hover {
  background: #314139;
}

.part-transform-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  border-top: 1px solid #dedbd2;
  padding-top: 8px;
}

.part-transform-row span {
  color: #66645e;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.part-transform-row button {
  min-height: 30px;
  border: 1px solid #c9c6bb;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: #3d3b36;
  font-size: 11px;
}

.global-controls {
  padding-top: 14px;
  border-top: 1px solid #dedbd2;
}

.color-editor,
.canvas-controls {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #dedbd2;
}

.color-editor-header,
.canvas-control-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.color-editor-header strong,
.canvas-control-header strong {
  color: #292a27;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.character-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.character-selector button {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border: 1px solid #c9c6bb;
  border-radius: 5px;
  padding: 0 9px;
  background: #fff;
  color: #292a27;
}

.character-selector button.active {
  border-color: #1d6f5f;
  background: #1d6f5f;
  color: #fff;
}

.color-value-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.color-value-row input {
  height: 40px;
}

.color-value-row output {
  display: grid;
  align-items: center;
  min-height: 40px;
  border: 1px solid #c9c6bb;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  float: none;
}

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

.tech-palette button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid #c9c6bb;
  border-radius: 5px;
  padding: 5px 8px;
  background: #fff;
  color: #353630;
  text-align: left;
}

.tech-palette button:hover,
.tech-palette button.active {
  border-color: #1d6f5f;
}

.tech-palette i {
  display: block;
  width: 22px;
  height: 22px;
  border: 1px solid rgb(0 0 0 / 18%);
  border-radius: 4px;
  background: var(--swatch);
}

.tech-palette span {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.canvas-presets button,
.canvas-size-inputs > button {
  min-height: 34px;
  border: 1px solid #c9c6bb;
  border-radius: 5px;
  background: #fff;
  color: #3d3b36;
  font-size: 11px;
}

.canvas-presets button.active {
  border-color: #1d6f5f;
  background: #e7f1ed;
  color: #155548;
}

.canvas-size-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  align-items: end;
  gap: 7px;
}

.canvas-size-inputs label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
}

.canvas-size-inputs label span {
  color: #66645e;
  font-size: 11px;
}

.canvas-size-inputs input {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 12px;
}

.swatches > label:first-child {
  display: grid;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  color: #3d3b36;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(440px, 1fr) auto minmax(240px, 34vh);
  gap: 14px;
  min-width: 0;
  max-height: 100vh;
  padding: 24px;
}

.stage-area {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 440px;
  border: 1px solid #cfcdc4;
  background: #dfe1dc;
}

.stage {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  border: 1px solid #d2cfc4;
  box-shadow: 0 9px 24px rgb(25 29 26 / 12%);
  background-color: #f6f3ee;
  background-image:
    linear-gradient(45deg, rgb(0 0 0 / 3%) 25%, transparent 25%),
    linear-gradient(-45deg, rgb(0 0 0 / 3%) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgb(0 0 0 / 3%) 75%),
    linear-gradient(-45deg, transparent 75%, rgb(0 0 0 / 3%) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.resize-handle {
  position: absolute;
  z-index: 4;
  border: 0;
  padding: 0;
  background: transparent;
}

.resize-e {
  top: 18px;
  right: -7px;
  bottom: 18px;
  width: 14px;
  cursor: ew-resize;
}

.resize-e::after {
  position: absolute;
  top: 50%;
  left: 5px;
  width: 3px;
  height: 38px;
  border-radius: 2px;
  background: rgb(29 111 95 / 42%);
  content: "";
  transform: translateY(-50%);
}

.resize-s {
  right: 18px;
  bottom: -7px;
  left: 18px;
  height: 14px;
  cursor: ns-resize;
}

.resize-s::after {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 38px;
  height: 3px;
  border-radius: 2px;
  background: rgb(29 111 95 / 42%);
  content: "";
  transform: translateX(-50%);
}

.resize-e:hover::after,
.resize-s:hover::after {
  background: #1d6f5f;
}

.resize-se {
  right: -8px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #1d6f5f;
  box-shadow: 0 1px 5px rgb(0 0 0 / 25%);
  cursor: nwse-resize;
}

.stage.resizing {
  user-select: none;
}

.logo-lockup {
  --fit-scale: 1;
  --rotation: 0deg;
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  transform: translate(-50%, -50%) rotate(var(--rotation)) scale(var(--fit-scale));
  transform-origin: center;
}

.logo-lockup.horizontal {
  flex-direction: row;
}

.logo-lockup.vertical {
  flex-direction: column;
}

.logo-lockup.single .logo-part[data-part="B"] {
  display: none;
}

.logo-part {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  line-height: 0.9;
  white-space: nowrap;
  text-align: center;
  transform-origin: center;
  text-rendering: geometricPrecision;
  cursor: move;
  touch-action: none;
}

.logo-char {
  display: inline-block;
  flex: 0 0 auto;
}

.logo-part.active {
  outline: 1px dashed #1d6f5f;
  outline-offset: 8px;
}

.part-resize-handle {
  position: absolute;
  right: -14px;
  bottom: -14px;
  z-index: 3;
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  padding: 0;
  background: #1d6f5f;
  box-shadow: 0 1px 4px rgb(0 0 0 / 28%);
  cursor: nwse-resize;
  touch-action: none;
}

.logo-part.active .part-resize-handle {
  display: block;
}

.stage.transforming,
.stage.transforming .logo-part {
  user-select: none;
}

.meta {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 34px;
  color: #56534d;
  font-size: 13px;
}

.meta > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.meta > span:last-child {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.font-browser-header {
  display: flex;
  justify-content: space-between;
  padding: 0 2px 9px;
}

.font-browser-header span {
  color: #66645e;
  font-size: 12px;
}

.samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: 82px;
  gap: 9px;
  min-height: 0;
  overflow-y: auto;
  padding: 1px 5px 5px 1px;
}

.sample {
  display: grid;
  align-content: center;
  width: 100%;
  min-width: 0;
  height: 82px;
  border: 1px solid #d2cfc4;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfaf6;
  color: #171816;
  text-align: left;
}

.sample:hover {
  border-color: #8b887f;
}

.sample.active {
  border-color: #1d6f5f;
  box-shadow: inset 0 0 0 1px #1d6f5f;
}

.sample.broken .sample-preview {
  color: #9a3f3f;
  font-family: ui-sans-serif, system-ui, sans-serif !important;
  font-size: 13px;
}

.sample-preview {
  overflow: hidden;
  min-width: 0;
  white-space: nowrap;
  font-size: 30px;
  line-height: 1.05;
  text-overflow: ellipsis;
}

.sample-name {
  overflow: hidden;
  margin-top: 7px;
  color: #6b6860;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

  .panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid #d7d5cc;
  }

  .workspace {
    grid-template-rows: minmax(360px, 1fr) auto 320px;
    max-height: none;
  }

  .stage-area {
    min-height: 440px;
  }
}

@media (max-width: 520px) {
  .panel,
  .workspace {
    padding: 16px;
  }

  .swatches,
  .actions {
    grid-template-columns: 1fr;
  }

  .tech-palette {
    grid-template-columns: 1fr;
  }

  .canvas-presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .meta {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .meta > span:last-child {
    text-align: left;
  }
}
