:root {
  color-scheme: light;
  --page: #f8f7f3;
  --surface: #ffffff;
  --surface-soft: #fbfcfa;
  --border: #dddcd5;
  --border-soft: #e8e6df;
  --text: #222724;
  --muted: #6f756f;
  --green: #0c5b45;
  --green-dark: #074c3a;
  --green-soft: #eef7f2;
  --green-border: #b9d6c9;
  --error-bg: #fff2f2;
  --error-border: #e3aaaa;
  --error-text: #8a2c2c;
  --success-bg: #eef8f3;
  --success-border: #9ac9b4;
  --success-text: #185d46;
  --shadow: 0 10px 30px rgba(45, 51, 46, 0.05);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  line-height: 1.65;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

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

.tool-shell {
  width: min(1410px, calc(100% - 28px));
  margin: 14px auto;
  padding: 30px 32px 12px;
  border: 1px solid #e2ded5;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 4px 24px rgba(66, 57, 44, 0.04);
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 0 14px 26px;
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: #285e50;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow img {
  width: 23px;
  height: 23px;
  object-fit: contain;
}

h1 {
  margin-bottom: 8px;
  color: #064f3d;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2.1rem, 4vw, 3.25rem);
  line-height: 1.22;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(365px, 100%);
  padding: 16px 18px;
  border: 1px solid var(--green-border);
  border-radius: 12px;
  background: #f5faf7;
  color: #244d41;
}

.privacy-note strong,
.privacy-note small {
  display: block;
}

.privacy-note strong {
  font-size: 0.87rem;
}

.privacy-note small {
  margin-top: 2px;
  color: #59665f;
  font-size: 0.78rem;
}

.privacy-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
}

.privacy-icon img {
  width: 25px;
  filter: brightness(0) invert(1);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-message {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 700;
}

.status-message[data-type="success"] {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.status-message[data-type="error"] {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.upload-panel {
  padding: 26px;
}

.drop-zone {
  position: relative;
  display: flex;
  min-height: 470px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border: 1px dashed #cbd4ca;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfcfa 0%, #f9fbf8 100%);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging {
  border-color: #6ea48f;
  background: var(--green-soft);
  outline: none;
}

.upload-visual {
  width: 150px;
  height: 120px;
  margin-bottom: 12px;
  object-fit: contain;
  opacity: 0.68;
}

.drop-zone h2 {
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 1.5rem;
}

.drop-zone p {
  margin-bottom: 20px;
  color: var(--muted);
}

.drop-zone small {
  margin-top: 13px;
  color: #7e827e;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.button:disabled {
  background: #e9eae8;
  color: #999d99;
  cursor: wait;
}

.button-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 5px 12px rgba(12, 91, 69, 0.18);
}

.button-primary img {
  filter: brightness(0) invert(1);
}

.button-primary:hover:not(:disabled),
.button-primary:focus-visible:not(:disabled) {
  background: var(--green-dark);
}

.button-ghost {
  border-color: var(--border);
  background: #fff;
  color: #4d544f;
}

.button-ghost:hover,
.button-ghost:focus-visible {
  border-color: #7cad9a;
  color: var(--green-dark);
}

.select-button {
  min-width: 245px;
  min-height: 48px;
}

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, 0.65fr);
  gap: 20px;
  align-items: start;
}

.editor-panel,
.settings-panel,
.result-panel {
  padding: 24px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 2px;
  font-size: 1.22rem;
  line-height: 1.4;
}

.panel-heading > p:last-child,
.panel-heading > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.step-label {
  margin-bottom: 3px;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.compact-button {
  min-height: 36px;
  padding: 6px 12px;
  flex: 0 0 auto;
  font-size: 0.75rem;
}

.crop-stage {
  height: min(62vh, 660px);
  min-height: 430px;
  overflow: hidden;
  border-radius: 10px;
  background-color: #e7e9e6;
  background-image:
    linear-gradient(45deg, #dfe2df 25%, transparent 25%),
    linear-gradient(-45deg, #dfe2df 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe2df 75%),
    linear-gradient(-45deg, transparent 75%, #dfe2df 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.crop-stage > img {
  display: block;
  max-width: 100%;
}

.crop-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tool-button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.tool-button span {
  color: var(--green);
  font-size: 1.25rem;
  line-height: 1;
}

.tool-button:hover,
.tool-button:focus-visible {
  border-color: #75a994;
  background: #f5faf7;
}

.crop-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.74rem;
}

.crop-metrics strong {
  margin-left: 4px;
  color: #37413b;
}

.setting-group {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.setting-group legend,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.preset-button {
  min-height: 47px;
  padding: 7px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.preset-button.is-active {
  border-color: #75a994;
  background: var(--green-soft);
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px rgba(12, 91, 69, 0.05);
}

.preset-button small {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
}

.setting-group select {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid #d8d9d5;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.setting-group select:focus {
  border-color: #67a18b;
  outline: 3px solid rgba(12, 91, 69, 0.1);
}

.quality-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quality-heading output {
  display: grid;
  min-width: 44px;
  min-height: 31px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

.quality-group input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.65rem;
}

.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.quality-group.is-disabled {
  opacity: 0.62;
}

.source-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.source-summary div {
  padding: 11px;
  border-radius: 8px;
  background: #f7f8f6;
}

.source-summary span,
.source-summary strong {
  display: block;
}

.source-summary span {
  color: var(--muted);
  font-size: 0.65rem;
}

.source-summary strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.preview-button {
  width: 100%;
  min-height: 56px;
}

.result-panel {
  grid-column: 1 / -1;
}

.result-content {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 24px;
  align-items: center;
}

.preview-frame {
  display: grid;
  min-height: 260px;
  max-height: 560px;
  place-items: center;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #f2f4f2;
}

.preview-frame img {
  max-height: 520px;
  object-fit: contain;
}

.result-details dl {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.result-details dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: #f7f8f6;
}

.result-details dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.result-details dd {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: right;
}

.download-button {
  width: 100%;
  min-height: 52px;
}

.result-details > p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding-top: 14px;
  color: #90958f;
  font-size: 0.7rem;
}

.tool-footer img {
  width: 14px;
  opacity: 0.55;
}

.cropper-view-box,
.cropper-face {
  border-radius: 2px;
}

.cropper-line,
.cropper-point {
  background-color: var(--green);
}

.cropper-view-box {
  outline-color: rgba(12, 91, 69, 0.85);
}

@media (max-width: 1000px) {
  .editor-workspace {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .crop-stage {
    min-height: 390px;
  }
}

@media (max-width: 820px) {
  .tool-shell {
    width: min(100% - 20px, 720px);
    padding: 24px 20px 10px;
  }

  .tool-header {
    display: grid;
    padding-inline: 0;
  }

  .privacy-note {
    width: 100%;
  }

  .editor-workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    grid-column: auto;
  }

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

@media (max-width: 600px) {
  .tool-shell {
    width: 100%;
    margin: 0;
    padding: 20px 14px 10px;
    border: 0;
    border-radius: 0;
  }

  h1 {
    font-size: 2rem;
  }

  .lead {
    font-size: 0.88rem;
  }

  .upload-panel,
  .editor-panel,
  .settings-panel,
  .result-panel {
    padding: 16px;
  }

  .drop-zone {
    min-height: 370px;
    padding: 22px 16px;
  }

  .upload-visual {
    width: 125px;
  }

  .editor-heading {
    display: grid;
  }

  .compact-button {
    justify-self: start;
  }

  .crop-stage {
    height: 54vh;
    min-height: 340px;
  }

  .crop-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-button {
    min-height: 50px;
  }

  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-frame {
    min-height: 200px;
  }

  .tool-footer {
    align-items: flex-start;
    text-align: left;
  }
}
