:root {
  color: #1c1917;
  background: #f4efe6;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px 16px 48px;
}

body.ads-on {
  padding: 16px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1100px) 160px;
  grid-template-areas:
    "top top top"
    "left page right";
  justify-content: center;
  column-gap: 16px;
  row-gap: 16px;
  align-items: start;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
}

button:hover {
  border-color: #0f766e;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.is-selected,
button.primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  min-width: 0;
}

body.ads-on .page {
  grid-area: page;
  max-width: none;
  margin: 0;
}

.top,
main,
.bottom {
  max-width: 1100px;
  margin: 0 auto;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: baseline;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.nav-links a {
  color: #0f766e;
  text-decoration: none;
}

.nav-links a:hover {
  text-decoration: underline;
}

.nav-links a[aria-current="page"] {
  font-weight: 700;
}

.brand {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}

.brand-en {
  margin-left: 6px;
  color: #0f766e;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero {
  margin-top: 20px;
}

.kicker {
  margin: 0 0 8px;
  color: #0f766e;
  font-weight: 700;
}

.hero h1,
.top > h1 {
  margin: 20px 0 12px;
  font-size: 30px;
  line-height: 1.3;
}

.hero h1 {
  margin-top: 0;
}

.lead,
.hero-next {
  margin: 0 0 10px;
  max-width: 40em;
}

.steps .step-list {
  display: grid;
  gap: 12px;
  padding-left: 0;
  list-style: none;
}

.steps .step-list li {
  padding: 12px;
  border: 1px solid #e7e0d4;
  border-radius: 10px;
  background: #faf7f1;
}

.steps .step-list p {
  margin: 6px 0 0;
}

.demo {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

.demo-label {
  margin: 0 0 6px;
  font-size: 14px;
  color: #4b5563;
}

.demo-long {
  display: grid;
  place-content: center;
  width: 88px;
  min-height: 160px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.demo-arrow {
  margin: 0;
  font-size: 28px;
}

.demo-stack {
  display: grid;
  gap: 8px;
  width: 140px;
}

.demo-stack span {
  display: grid;
  place-content: center;
  min-height: 40px;
  border-radius: 8px;
  background: #115e59;
  color: #fff;
}

.drop-title {
  font-size: 20px;
  font-weight: 700;
}

.tag,
.help,
.bottom {
  color: #4b5563;
}

.status {
  min-height: 1.5em;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #e7f3f1;
}

.status.is-error {
  background: #fee2e2;
  color: #991b1b;
}

.toolbar,
.button-row,
.size-row,
.result-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar {
  margin-top: 16px;
}

#meta {
  margin: 0;
  color: #4b5563;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.drop {
  min-height: 360px;
  padding: 12px;
  border: 1px dashed #9ca3af;
  border-radius: 12px;
  background: #fff;
}

.drop.is-over {
  border-color: #0f766e;
  background: #e7f3f1;
}

.drop-hint {
  display: grid;
  min-height: 320px;
  place-content: center;
  text-align: center;
}

.drop-hint p {
  margin: 4px 0;
}

canvas {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  touch-action: none;
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.tools,
.result,
.guide {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.tools section + section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

h2,
h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.label {
  margin: 12px 0 6px;
  font-weight: 700;
}

.size-row label,
.slider {
  display: grid;
  gap: 4px;
}

.slider {
  grid-template-columns: 1fr 96px auto;
  align-items: center;
}

.slider span {
  grid-column: 1 / -1;
}

.size-row input[type="number"],
.field input[type="number"],
.field input[type="text"] {
  width: 120px;
  min-height: 40px;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.field input[type="text"] {
  width: 100%;
}

.field {
  display: grid;
  gap: 4px;
  margin: 10px 0;
}

.quality-line {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quality-line input {
  flex: 1;
}

.cut-px {
  width: 96px;
}

.guide ul {
  margin: 0;
  padding-left: 20px;
}

.check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 40px;
}

.help {
  margin: 8px 0 0;
  font-size: 14px;
}

.result {
  margin-top: 16px;
}

.result-head {
  justify-content: space-between;
}

.sliders {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.slider input[type="range"] {
  width: 100%;
}

.pieces {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.piece {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.piece img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: #f3f4f6;
}

.piece p {
  margin: 0;
  font-size: 14px;
}

.guide {
  margin-top: 16px;
}

.guide ol {
  margin: 0;
  padding-left: 20px;
}

details {
  padding: 8px 0;
  border-top: 1px solid #e5e7eb;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.bottom {
  margin-top: 24px;
}

.footer-brand {
  margin: 0 0 8px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.footer-links a {
  color: #0f766e;
}

.article p {
  margin: 0 0 12px;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  border: 1px dashed #8d8d8d;
  border-radius: 12px;
  background: #cfcfcf;
  color: #4b4b4b;
  text-align: center;
}

.ad-top {
  grid-area: top;
  min-height: 90px;
}

.ad-side {
  position: sticky;
  top: 16px;
  min-height: 600px;
}

.ad-side[data-ad="side-left"] {
  grid-area: left;
}

.ad-side[data-ad="side-right"] {
  grid-area: right;
}

.ad-slot p {
  margin: 0;
  font-size: 14px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  body.ads-on {
    grid-template-columns: minmax(0, 1100px);
    grid-template-areas:
      "top"
      "page";
  }

  body.ads-on .ad-side {
    display: none;
  }
}

@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}
