:root {
  --bg: #f7f4ef;
  --paper: #ffffff;
  --ink: #252925;
  --muted: #69706a;
  --soft: #eef3ef;
  --sage: #78917f;
  --sage-dark: #52695a;
  --coral: #db7f6f;
  --line: #d9ded8;
  --shadow: 0 24px 70px rgba(36, 43, 37, 0.1);
  --radius: 8px;
  --sans: "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0)),
    var(--bg);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.tool-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(217, 222, 216, 0.82);
  background: rgba(247, 244, 239, 0.9);
  backdrop-filter: blur(18px);
}

.tool-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #cfd7d0;
  border-radius: 50%;
  color: var(--sage-dark);
  background: #fff;
  font-family: Georgia, serif;
  font-size: 17px;
}

.tool-brand strong,
.tool-brand small {
  display: block;
}

.tool-brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.tool-brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-button,
.primary-action,
.secondary-action,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
}

.upload-button {
  color: var(--sage-dark);
  background: #fff;
  border-color: #cbd6ce;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.primary-action {
  color: #fff;
  background: var(--sage-dark);
}

.secondary-action,
.download-button {
  width: 100%;
  color: var(--sage-dark);
  background: var(--soft);
  border-color: #d8e0da;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 22px;
}

.workspace,
.inspector {
  border: 1px solid rgba(217, 222, 216, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.workspace {
  min-width: 0;
  padding: 20px;
}

.workspace-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.5vw, 38px);
  line-height: 1.35;
}

.workspace-top p {
  max-width: 720px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 82px);
  align-self: start;
  padding: 4px;
  border: 1px solid #d5ddd6;
  border-radius: var(--radius);
  background: #f5f8f5;
}

.mode-switch button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.mode-switch button.is-active {
  color: #fff;
  background: var(--sage);
}

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 548px;
  overflow: hidden;
  border: 1px solid #dfe4df;
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #eef1ed 25%, transparent 25%),
    linear-gradient(-45deg, #eef1ed 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1ed 75%),
    linear-gradient(-45deg, transparent 75%, #eef1ed 75%),
    #f9faf8;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

canvas {
  display: block;
  width: min(100%, 1242px);
  height: auto;
}

.empty-state {
  position: absolute;
  inset: auto;
  display: grid;
  gap: 8px;
  place-items: center;
  width: min(360px, calc(100% - 48px));
  padding: 28px;
  border: 1px dashed #bac8bd;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
  pointer-events: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 19px;
}

.empty-state span {
  font-size: 13px;
  line-height: 1.7;
}

.empty-state.is-hidden {
  display: none;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.preview-tile {
  overflow: hidden;
  border: 1px solid #dce2dd;
  border-radius: var(--radius);
  background: #fff;
}

.preview-tile canvas {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #f8f8f6;
}

.preview-tile span {
  display: block;
  padding: 9px 12px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inspector {
  align-self: start;
  padding: 18px;
}

.control-section + .control-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.control-section h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

.spec-table {
  display: grid;
  gap: 8px;
}

.spec-table div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: #f7f9f7;
}

.spec-table span,
.range-row span,
.check-row {
  color: var(--muted);
  font-size: 13px;
}

.spec-table strong {
  font-size: 13px;
}

.range-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.range-row input {
  accent-color: var(--sage);
}

.range-row b {
  color: var(--sage-dark);
  font-size: 12px;
  text-align: right;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 10px;
  margin-bottom: 14px;
}

.swatch {
  width: 42px;
  height: 42px;
  border: 1px solid #cfd8d1;
  border-radius: var(--radius);
  background: var(--swatch);
}

.swatch.is-active {
  outline: 3px solid rgba(120, 145, 127, 0.28);
  border-color: var(--sage-dark);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
}

.check-row input {
  accent-color: var(--sage);
}

.download-grid {
  display: grid;
  gap: 9px;
}

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

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

  .control-section + .control-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 720px) {
  .tool-header,
  .workspace-top,
  .header-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-header {
    position: static;
  }

  .app-shell {
    padding: 12px;
  }

  .workspace,
  .inspector {
    padding: 14px;
  }

  .canvas-stage {
    min-height: 320px;
  }

  .preview-strip,
  .inspector {
    grid-template-columns: 1fr;
  }

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