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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  overflow: auto;
  background: #f4f5f7;
  border-right: 1px solid #c8cdd3;
  padding: 14px;
  font-size: 13px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}

.brand p,
.summary {
  color: #65707d;
  font-size: 13px;
}

#pixelSummary {
  margin: -3px 0 10px;
}

#pageDetail {
  margin-top: 5px;
}

#licenseSummary {
  margin-top: 6px;
}

.canvas-actions {
  margin-bottom: 12px;
}

.spotlight-note {
  margin: -4px 0 8px 28px;
}

.qr-note {
  margin: -3px 0 7px;
}

section {
  border-top: 1px solid #d7dbe0;
  padding-top: 13px;
  margin-top: 14px;
}

h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #4d5661;
}

label {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #3e4650;
}

input,
select,
button,
.button {
  border: 1px solid #b9c0c8;
  border-radius: 6px;
  background: #fff;
  color: #20242a;
  font: inherit;
  font-size: 13px;
  min-height: 32px;
}

input,
select {
  width: 100%;
  padding: 5px 8px;
}

textarea {
  width: 100%;
  min-height: 76px;
  padding: 7px 8px;
  border: 1px solid #b9c0c8;
  border-radius: 6px;
  background: #fff;
  color: #20242a;
  font: inherit;
  resize: vertical;
}

button,
.button {
  padding: 6px 10px;
  cursor: pointer;
  text-align: center;
  user-select: none;
}

button:hover,
.button:hover {
  border-color: #7c8794;
}

.primary-button {
  background: #0f6f78;
  border-color: #0f6f78;
  color: #fff;
}

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

.button input {
  display: none;
}

.button-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.button-row > label {
  margin-bottom: 0;
}

.project-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.project-actions button,
.project-actions .button {
  width: 100%;
}

.preset-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.preset-row label {
  margin-bottom: 0;
}

#flipCanvasBtn {
  min-width: 56px;
}

.page-order-actions {
  margin-top: 8px;
}

.page-order-actions button {
  flex: 1 1 calc(50% - 4px);
}

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

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

.check input {
  width: auto;
}

.page-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.page-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid #d1d6dc;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.page-item.active {
  border-color: #596574;
  background: #eef1f4;
}

.page-item input {
  width: auto;
  min-height: auto;
}

.page-jump {
  min-height: 26px;
  padding: 3px 8px;
}

.workspace {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 9px 14px;
  background: #eceff2;
  border-bottom: 1px solid #c8cdd3;
}

#status {
  color: #48525f;
  font-size: 14px;
}

.stage-wrap {
  overflow: auto;
  padding: 32px;
}

.stage {
  position: relative;
  width: fit-content;
  height: fit-content;
  margin: 0 auto;
  box-shadow: 0 12px 32px rgba(24, 31, 40, 0.22);
  background-image:
    linear-gradient(45deg, #c5cad0 25%, transparent 25%),
    linear-gradient(-45deg, #c5cad0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c5cad0 75%),
    linear-gradient(-45deg, transparent 75%, #c5cad0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

canvas {
  display: block;
  background: transparent;
  cursor: default;
}

.selection {
  position: absolute;
  pointer-events: none;
  outline: 2px solid #15191f;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95);
}

.rotate-handle {
  position: absolute;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(24, 28, 34, 0.95);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.32);
  cursor: grab;
  z-index: 4;
}

.rotate-handle:active {
  cursor: grabbing;
}

.rotate-handle::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 7px;
  top: 7px;
  border: 3px solid #fff;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-38deg);
}

.rotate-handle::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 18px;
  width: 0;
  height: 0;
  border-top: 6px solid #fff;
  border-right: 6px solid transparent;
  border-left: 2px solid transparent;
  transform: rotate(28deg);
}

.frame-control {
  position: absolute;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px;
  background: rgba(28, 32, 38, 0.92);
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  z-index: 3;
}

.frame-control input {
  min-height: 24px;
  padding: 0;
}

.frame-control button {
  min-height: 28px;
  padding: 4px 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 30, 36, 0.42);
}

.modal {
  width: min(440px, 100%);
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #c6ccd3;
  box-shadow: 0 18px 50px rgba(15, 20, 28, 0.28);
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 18px;
  text-transform: none;
  color: #20242a;
}

.modal p,
.modal li {
  margin: 0;
  color: #48525f;
  line-height: 1.45;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-heading h2 {
  margin: 0;
}

.help-modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
}

.license-modal {
  width: min(520px, 100%);
}

.hero-modal {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: auto;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #d1d6dc;
  border-radius: 7px;
  background: #f8f9fa;
}

.hero-choice {
  display: grid;
  gap: 7px;
  padding: 7px;
  min-height: auto;
  text-align: left;
  background: #fff;
}

.hero-choice.selected {
  border-color: #0f6f78;
  box-shadow: 0 0 0 2px rgba(15, 111, 120, 0.2);
}

.hero-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  background: #dfe3e8;
}

.hero-choice span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #3e4650;
}

.license-actions {
  margin: 18px 0 10px;
}

.license-details {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #d1d6dc;
  border-radius: 7px;
  background: #f8f9fa;
  color: #48525f;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.help-modal h3 {
  margin: 18px 0 7px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #4d5661;
}

.help-modal ol,
.help-modal ul {
  margin: 0;
  padding-left: 22px;
}

.help-modal li + li {
  margin-top: 5px;
}

.export-modal {
  width: min(620px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: auto;
}

.export-page-picker {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid #d1d6dc;
  border-radius: 7px;
  background: #f8f9fa;
}

.export-page-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.export-page-row input {
  width: auto;
  min-height: auto;
}

#exportSummary {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal .danger {
  background: #7f1d1d;
  border-color: #7f1d1d;
  color: #fff;
}

.modal .primary {
  background: #0f6f78;
  border-color: #0f6f78;
  color: #fff;
}

.busy-box {
  min-width: 220px;
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #c6ccd3;
  box-shadow: 0 18px 50px rgba(15, 20, 28, 0.28);
  color: #20242a;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #cfd6dd;
  border-top-color: #0f6f78;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow: auto;
  }

  .sidebar {
    height: auto;
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid #c8cdd3;
  }

  .workspace {
    height: 52vh;
  }
}
