* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #161616;
  color: #e6e6e6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Cantarell, Helvetica, Arial, sans-serif;
  font-size: 13px;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

#status {
  height: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: #202020;
  border-bottom: 1px solid #2c2c2c;
}
.groups {
  display: flex;
  gap: 2px;
}

.group-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #8a8a8a;
  font: inherit;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
}

.group-btn.active {
  background: #3a3a3a;
  color: #ffffff;
}

.sep {
  width: 1px;
  height: 20px;
  background: #2c2c2c;
}

.mode-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #2c2c2c;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px #3a3a3a;
}

.mode-btn.dark {
  border-style: dashed;
  border-color: #e6e6e6;
}

.mode-btn.masked {
  border-style: dotted;
  border-color: #e6e6e6;
}

.mode-btn.annot {
  border-style: solid;
  border-color: #e6e6e6;
}

.mode-btn:disabled {
  cursor: default;
}

.info {
  margin-left: auto;
  color: #8a8a8a;
}

#stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#wrap {
  position: relative;
}

#wrap canvas {
  position: absolute;
  inset: 0;
  display: block;
}

#base {
  cursor: crosshair;
}

#overlay {
  pointer-events: none;
}

.text-editor {
  position: absolute;
  margin: 0;
  padding: 0;
  border: none;
  outline: 1px dashed rgba(255, 255, 255, .7);
  background: transparent;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  user-select: text;
  z-index: 5;
}

#hint {
  position: absolute;
  left: 50%;
  top: calc(50% + 18px);
  transform: translate(-50%, -50%);
  color: #8a8a8a;
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #2c2c2c;
  color: #e6e6e6;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
}

.profile-editor {
  position: fixed;
  z-index: 30;
  background: #202020;
  border: 1px solid #2c2c2c;
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 260px;
}

.pe-title {
  color: #e6e6e6;
  font-weight: 600;
}

.pe-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pe-label {
  width: 14px;
  color: #8a8a8a;
}

.pe-slider {
  flex: 1;
}

.pe-num {
  width: 64px;
  background: #161616;
  color: #e6e6e6;
  border: 1px solid #2c2c2c;
  border-radius: 3px;
  padding: 2px 4px;
  font: inherit;
  user-select: text;
}

.pe-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid #2c2c2c;
  border-radius: 3px;
  display: inline-block;
}

.pe-reset,
.pe-close {
  background: #2c2c2c;
  color: #e6e6e6;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}

.pe-reset {
  margin-left: auto;
}

.pe-section {
  color: #8a8a8a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.pe-mirror {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e6e6e6;
  cursor: pointer;
}

.pe-slider:disabled,
.pe-num:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.group-btn.reassign {
  outline: 1px dashed #3aa0ff;
  outline-offset: -1px;
}

.picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.picker {
  margin-top: 44px;
  background: #202020;
  border: 1px solid #2c2c2c;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
}

.picker-title {
  color: #e6e6e6;
  font-weight: 600;
  margin-bottom: 8px;
}

.picker-grid {
  display: grid;
  grid-template-columns: auto repeat(5, 28px);
  align-items: center;
  gap: 6px 8px;
}

.picker-rowlabel {
  color: #8a8a8a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.picker-cell {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  justify-self: center;
  box-shadow: inset 0 0 0 1px #3a3a3a;
}

.picker-cell.current {
  border-color: #8a8a8a;
}

.picker-cell.cursor {
  outline: 2px solid #3aa0ff;
  outline-offset: 2px;
}

.picker-digit {
  color: #8a8a8a;
  font-size: 11px;
  text-align: center;
}

.picker-foot {
  margin-top: 10px;
  color: #8a8a8a;
  font-size: 11px;
}

.picker-cell.empty {
  visibility: hidden;
}

.picker-cell.mask-noise {
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, .7) 0 2px, transparent 2px 4px);
}

.picker-cell.mask-pixelate {
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .55) 0 3px, transparent 3px 6px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .55) 0 3px, transparent 3px 6px);
}

.picker-cell.picker-shape {
  background: #2c2c2c;
  color: #e6e6e6;
  display: grid;
  place-items: center;
}

.picker-cell.picker-shape svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.theme-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  padding: 4px 6px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #e6e6e6;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.theme-row.current {
  border-color: #8a8a8a;
}

.theme-row.cursor {
  outline: 2px solid #3aa0ff;
  outline-offset: 2px;
}

.theme-name {
  flex: 1;
}

.theme-lock {
  color: #8a8a8a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.theme-dots {
  display: flex;
  gap: 3px;
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px #3a3a3a;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
}

.help-panel {
  display: flex;
  flex-direction: column;
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: #202020;
  border: 1px solid #2c2c2c;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
}

.help-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0 28px;
  overflow-y: auto;
  min-height: 0;
}

.help-col {
  flex: 1 1 420px;
  min-width: 0;
}

.help-col > .help-section:first-child {
  margin-top: 0;
}

.help-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.help-row {
  display: flex;
  gap: 12px;
  padding: 2px 0;
}

.help-keys {
  flex: 0 0 190px;
  color: #cfcfcf;
}

.help-desc {
  color: #8a8a8a;
}

.help-foot {
  flex: 0 0 auto;
  margin-top: 10px;
  color: #8a8a8a;
  font-size: 11px;
}

.help-link {
  color: #cfcfcf;
  cursor: pointer;
  text-decoration: underline;
  user-select: text;
}

.help-link:hover {
  color: #e6e6e6;
}

.help-section {
  margin-top: 12px;
  color: #e6e6e6;
  font-weight: 600;
}

.help-note {
  margin-top: 4px;
  max-width: none;
  color: #8a8a8a;
  line-height: 1.4;
}

.resize-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.rz-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rz-slider {
  flex: 1;
  min-width: 240px;
}

.rz-readout {
  color: #e6e6e6;
  font-variant-numeric: tabular-nums;
}
