:root {
  color-scheme: light;
  font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  color: #14213d;
  background: #f1f5f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

.app-shell {
  display: block;
  min-height: calc(100vh - 104px);
}

.app-header {
  padding: 18px clamp(24px, 6vw, 84px);
  border-bottom: 1px solid #d9e2ec;
  background: #fff;
}

.app-header h1 {
  margin: 0;
}

.editor {
  padding: 20px clamp(24px, 6vw, 84px);
  background: #ffffff;
}

.eyebrow {
  margin: 0 0 10px;
  color: #0d83ad;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.25;
}

.catalog-selector {
  margin-bottom: 0;
  border: 1px solid #b9dbe8;
  border-radius: 10px;
  padding: 18px;
  background: #f3fbff;
}

.field-label {
  margin: 0;
  color: #344256;
  font-size: 0.84rem;
  font-weight: 700;
}

.catalog-fields,
.label-form {
  display: grid;
  gap: 17px;
}

.catalog-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 86px;
  align-items: start;
  gap: 12px;
}

.catalog-pair {
  display: grid;
  gap: 7px;
  color: #344256;
  font-size: 0.84rem;
  font-weight: 700;
}

.catalog-fields label,
.label-form label {
  display: grid;
  gap: 7px;
  color: #344256;
  font-size: 0.84rem;
  font-weight: 700;
}

input[type="text"],
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 12px;
  color: #14213d;
  background: #fff;
  font: inherit;
  font-weight: 500;
}

input[type="text"]:focus,
select:focus,
input[type="color"]:focus-visible,
.label-action-button:focus-visible,
.print-button:focus-visible {
  outline: 3px solid #8ed8f5;
  outline-offset: 2px;
}

select {
  cursor: pointer;
}

.catalog-pair select {
  border-color: #78bcd8;
  background: #dff4fc;
}

select:disabled {
  cursor: not-allowed;
  color: #718096;
  background: #e9eff5;
}

.color-menu {
  position: relative;
}

.color-menu-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 12px;
  color: #14213d;
  background: #dff4fc;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
}

.color-menu-button::after {
  content: "⌄";
  margin-left: 12px;
  color: #526071;
  font-size: 1.25rem;
  line-height: 1;
}

.color-menu-button:focus-visible,
.color-option:focus-visible {
  outline: 3px solid #8ed8f5;
  outline-offset: 2px;
}

.color-menu-button:disabled {
  cursor: not-allowed;
  color: #718096;
  background: #e9eff5;
}

.color-menu-options {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: grid;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #9abac8;
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.color-menu-options[hidden] {
  display: none;
}

.color-option {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 5px;
  padding: 5px;
  color: #000;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
}

.color-option:hover {
  background: #e8f7fd;
}

.color-option-placeholder {
  padding: 7px 5px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
}

.color-option-swatch {
  display: block;
  height: 32px;
  border: 1px solid #64748b;
  background: var(--swatch-color);
}

.color-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
}

.color-modal[hidden] {
  display: none;
}

.color-modal-dialog {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 14px;
  padding: 20px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
}

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

.color-modal-header h2,
.color-modal-section h3 {
  margin: 0;
}

.color-modal-header h2 {
  font-size: 1.2rem;
}

.color-modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  padding: 0;
  color: #334155;
  background: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.color-modal-content {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.4fr);
  gap: 20px;
}

.color-modal-section {
  display: grid;
  align-content: start;
  gap: 10px;
}

.color-modal-section h3 {
  color: #334155;
  font-size: 0.9rem;
}

.color-modal .color-menu-options,
.color-modal .palette-options {
  position: static;
  max-height: 440px;
  border: 1px solid #cbd5e1;
  box-shadow: none;
}

.color-modal .color-menu-options {
  gap: 4px;
  padding: 6px;
}

.color-modal .palette-options {
  align-content: start;
}

.catalog-status {
  min-height: 1.3em;
  margin: 0;
  color: #526071;
  font-size: 0.75rem;
  line-height: 1.5;
}

.catalog-status.is-error {
  color: #b42318;
}

.color-name-field {
  margin-top: 4px;
}

.catalog-fields .inline-input-field {
  position: relative;
  display: block;
  margin-top: 4px;
}

.inline-input-field input {
  padding-right: 7.4em;
}

.hex-color-preview {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 45px;
  width: 20px;
  height: 20px;
  border: 1px solid #64748b;
  border-radius: 3px;
  pointer-events: none;
  transform: translateY(-50%);
}

.inline-input-label {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 12px;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  transform: translateY(-50%);
}

.palette-menu {
  position: relative;
}

.palette-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 44px;
  border: 1px solid #78bcd8;
  border-radius: 8px;
  padding: 9px 12px;
  color: #14213d;
  background: #dff4fc;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
}

.palette-button::after {
  content: "⌄";
  margin-left: 12px;
  color: #526071;
  font-size: 1.25rem;
  line-height: 1;
}

.palette-button:focus-visible,
.palette-color:focus-visible {
  outline: 3px solid #8ed8f5;
  outline-offset: 2px;
}

.palette-options {
  position: absolute;
  z-index: 11;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 2px;
  max-height: 290px;
  overflow-y: auto;
  border: 1px solid #9abac8;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.palette-options[hidden] {
  display: none;
}

.palette-color {
  aspect-ratio: 1;
  min-height: 16px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  background: var(--palette-color);
  cursor: pointer;
}

.palette-color:hover {
  position: relative;
  z-index: 1;
  outline: 2px solid #0f172a;
  outline-offset: 1px;
}

.label-action-button,
.print-button {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border: 0;
  border-radius: 8px;
  padding: 8px;
  color: #fff;
  background: #087ca6;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-line;
  text-align: center;
  transition: background 150ms ease, transform 150ms ease;
}

.label-action-button {
  background: #145c78;
}

.print-button {
  background: #a84916;
}

.label-action-button:hover:not(:disabled) {
  background: #056786;
}

.print-button:hover {
  background: #89390f;
}

.label-action-button:disabled {
  cursor: not-allowed;
  background: #94a3b8;
}

.label-action-button:active,
.print-button:active {
  transform: translateY(1px);
}

.label-actions {
  display: grid;
  gap: 8px;
  padding-top: 27px;
}

.label-action-note,
.print-note {
  display: none;
}

.preview-section {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 20px;
  padding: 28px clamp(24px, 6vw, 84px);
  background:
    radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.14), transparent 30%),
    #e8eef5;
}

.preview-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.preview-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.preview-heading span {
  color: #64748b;
  font-size: 0.8rem;
}

.preview-stage {
  display: grid;
  justify-items: center;
  width: min(100%, 1000px);
  min-width: 0;
  padding: 30px;
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 20px 50px rgba(51, 65, 85, 0.13);
}

.label-list {
  display: grid;
  grid-template-columns: repeat(4, 45mm);
  column-gap: 0.5mm;
  row-gap: 0.5mm;
  width: max-content;
}

.label-card {
  position: relative;
  width: 45mm;
  cursor: grab;
  transition: opacity 150ms ease, transform 150ms ease;
}

.label-card:active {
  cursor: grabbing;
}

.label-card.is-active .filament-label {
  outline: 0.7mm solid #0d83ad;
  outline-offset: 1.5mm;
}

.label-card.is-dragging {
  opacity: 0.45;
}

.label-card.is-drop-target {
  transform: translateX(6px);
}

.remove-label-button {
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid #991b1b;
  border-radius: 50%;
  padding: 0;
  color: #fff;
  background: #b91c1c;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
}

.remove-label-button:hover {
  background: #991b1b;
}

.empty-label-message {
  margin: 0;
  color: #526071;
  font-size: 0.9rem;
}

.clear-labels-button {
  border: 1px solid #b91c1c;
  border-radius: 7px;
  padding: 8px 16px;
  color: #991b1b;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.clear-labels-button:hover:not(:disabled) {
  color: #fff;
  background: #b91c1c;
}

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

.filament-label {
  display: flex;
  flex-direction: column;
  width: 45mm;
  height: 67mm;
  border: 0.25mm solid #000;
  padding: 2.5mm 4.5mm 3mm;
  color: #080b12;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  overflow: hidden;
}

.filament-label p {
  overflow: hidden;
  margin: 0;
  text-overflow: clip;
  white-space: nowrap;
}

.maker {
  min-height: 5mm;
  font-size: 4.56mm;
  line-height: 5mm;
}

.material {
  min-height: 10mm;
  font-size: 8mm;
  font-weight: 800;
  line-height: 10mm;
}

.series {
  min-height: 5.5mm;
  font-size: 4.94mm;
  line-height: 5.5mm;
}

.color-swatch {
  flex: 1 1 auto;
  min-height: 15mm;
  margin: 2.6mm 0 2.2mm;
  border: 0.25mm solid #000;
  display: block;
}

.color-name {
  min-height: 5mm;
  font-size: 3.8mm;
  line-height: 5mm;
}

@media (max-width: 1000px) {
  .catalog-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .editor {
    padding: 32px 24px;
  }

  .preview-section {
    padding: 36px 16px;
  }

  .preview-stage {
    width: 100%;
    min-width: 0;
    padding: 34px 16px;
  }

  .catalog-fields {
    grid-template-columns: 1fr;
  }

  .color-modal {
    padding: 12px;
  }

  .color-modal-dialog {
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  .color-modal-content {
    grid-template-columns: 1fr;
  }
}

.catalog-import-section {
  margin: 0;
  padding: 28px clamp(24px, 6vw, 84px) 40px;
  border-top: 1px solid #d9e2ec;
  background: #fff;
}

.catalog-import-section h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.catalog-import-section p {
  margin: 0 0 16px;
  max-width: 56rem;
  color: #52606d;
  font-size: 0.92rem;
  line-height: 1.6;
}

.catalog-import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.catalog-download-link,
.catalog-guide-link,
.catalog-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.catalog-guide-link {
  border: 1px solid #52606d;
  color: #52606d;
  background: #fff;
}

.catalog-guide-link:hover {
  background: #f1f5f9;
}

.catalog-download-link {
  border: 1px solid #0d83ad;
  color: #0d83ad;
  background: #f3fbff;
}

.catalog-download-link:hover {
  background: #e6f6fc;
}

.catalog-upload-button {
  border: 1px solid #344256;
  color: #fff;
  background: #344256;
}

.catalog-upload-button:hover {
  background: #243041;
}

.doc-page .app-header h1 {
  margin-bottom: 12px;
}

.doc-lead {
  margin: 0 0 12px;
  max-width: 48rem;
  color: #52606d;
  line-height: 1.7;
}

.doc-nav {
  margin: 0;
  font-size: 0.92rem;
}

.doc-nav a {
  color: #0d83ad;
  font-weight: 700;
  text-decoration: none;
}

.doc-nav a:hover {
  text-decoration: underline;
}

.doc-main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 28px clamp(24px, 6vw, 84px) 48px;
}

.doc-section + .doc-section {
  margin-top: 36px;
}

.doc-section h2 {
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.doc-section p,
.doc-section li {
  color: #344256;
  line-height: 1.7;
}

.doc-section code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #eef2f6;
  font-size: 0.9em;
}

.doc-table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.doc-table th,
.doc-table td {
  padding: 10px 12px;
  border: 1px solid #d9e2ec;
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  background: #f8fafc;
}

.doc-example {
  margin: 16px 0;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #f8fafc;
}

.doc-example code {
  padding: 0;
  background: transparent;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre;
}

.doc-list {
  margin: 12px 0 0;
  padding-left: 1.4rem;
}

.doc-list-ordered {
  list-style-type: decimal;
}

.doc-footer {
  padding-top: 20px;
  padding-bottom: 28px;
}

@page {
  size: A4;
  margin: 10mm;
}

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    box-shadow: none !important;
  }

  html,
  body {
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell,
  .preview-section,
  .preview-stage {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .app-header,
  .editor,
  .preview-heading,
  .clear-labels-button,
  .catalog-import-section,
  .color-modal {
    display: none;
  }

  .label-list {
    display: grid;
    grid-template-columns: repeat(4, 45mm);
    justify-content: start;
    column-gap: 1mm;
    row-gap: 1mm;
  }

  .label-card.is-active .filament-label {
    outline: 0;
  }

  .remove-label-button,
  .empty-label-message {
    display: none;
  }

  .filament-label {
    margin: 0;
    page-break-inside: avoid;
  }
}
