:root {
  color-scheme: light;
  --ink: #1c232b;
  --muted: #66717f;
  --line: #d8dee6;
  --panel: #f6f8fa;
  --accent: #007a78;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: #eef2f5;
  font-size: 14px;
  font-family: Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  padding: 16px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

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

.brand p,
.status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.editor,
.sheet-controls {
  display: grid;
  gap: 8px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f9;
}

.sub-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 7px;
  background: #eef3f6;
}

.sub-tabs label {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
}

.sub-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sub-tabs label:has(input:checked) {
  color: #ffffff;
  background: #26323f;
}

.mode-tabs label {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 30px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.mode-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-tabs label:has(input:checked) {
  color: #ffffff;
  background: var(--accent);
}

[hidden] {
  display: none !important;
}

fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px var(--line);
}

legend {
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #3b4652;
}

select,
input {
  min-height: 32px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
}

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

.compact-check {
  min-height: 24px;
}

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

button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.94);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

#print-sheet {
  background: #26323f;
}

#clear-all {
  color: var(--danger);
  background: #fff7f6;
  border-color: #ffd7d2;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 32px;
}

.sheet-frame {
  width: var(--sheet-frame-width, auto);
  height: var(--sheet-frame-height, var(--paper-height, 297mm));
}

.pages {
  display: flex;
  gap: 18px;
  height: var(--paper-height, 297mm);
  transform: scale(var(--sheet-scale, 1));
  transform-origin: top left;
}

.sheet {
  position: relative;
  flex: 0 0 auto;
  width: var(--paper-width, 210mm);
  height: var(--paper-height, 297mm);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(24, 35, 48, 0.18);
}

.marker-card {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 2mm;
  width: var(--box-width);
  break-inside: avoid;
}

.marker-box {
  display: grid;
  place-items: center;
  width: var(--box-width);
  height: var(--box-height);
  padding: var(--quiet-zone);
  background: #ffffff;
}

.marker-card.show-border .marker-box {
  border: 0.2mm solid #111111;
}

.marker-art {
  width: 100%;
  height: 100%;
}

.marker-art svg {
  display: block;
  width: 100%;
  height: 100%;
}

.marker-label {
  width: var(--box-width);
  min-height: 10mm;
  color: #111111;
  font-size: 8px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.remove {
  position: absolute;
  top: -11px;
  right: -11px;
  display: grid;
  place-items: center;
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  background: #26323f;
}

@media (max-width: 860px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .controls {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 16px;
  }
}

@media (max-height: 760px) and (min-width: 861px) {
  .controls {
    gap: 6px;
    padding: 10px;
  }

  .brand h1 {
    margin: 0;
    font-size: 15px;
  }

  .brand p {
    display: none;
  }

  fieldset {
    gap: 5px;
    padding: 7px;
  }

  legend,
  label,
  .status {
    font-size: 11px;
  }

  select,
  input,
  button {
    min-height: 28px;
    padding: 4px 7px;
  }

  .mode-tabs label {
    min-height: 26px;
  }
}

@media print {
  @page {
    size: var(--print-page-size, A4);
    margin: 0;
  }

  body {
    background: #ffffff;
  }

  .controls {
    display: none;
  }

  .app {
    display: block;
  }

  .workspace {
    display: block;
    overflow: visible;
    padding: 0;
  }

  .sheet-frame {
    width: auto;
    height: auto;
  }

  .pages {
    display: block;
    height: auto;
    transform: none;
  }

  .sheet {
    break-after: page;
    page-break-after: always;
    margin: 0;
    box-shadow: none;
  }

  .sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .remove {
    display: none;
  }

  .marker-card.hide-label .marker-label {
    display: none;
  }
}
