:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --surface-muted: #f2f6f3;
  --ink: #18211d;
  --ink-strong: #111915;
  --muted: #546159;
  --border: #cbd5cf;
  --border-light: #dce3df;
  --green: #178447;
  --green-dark: #0e6535;
  --green-soft: #e9f6ee;
  --coral: #dc665f;
  --coral-soft: #fff2f1;
  --amber: #a86d14;
  --blue-soft: #edf4fb;
  --blue-border: #c8d9eb;
  --blue-text: #34536e;
  --danger: #b84038;
  --shadow: 0 12px 32px rgba(31, 48, 39, 0.06);
  --shadow-strong: 0 18px 48px rgba(31, 48, 39, 0.11);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-width: 320px; color-scheme: light; scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(112deg, rgba(220, 102, 95, 0.035) 0%, transparent 32%),
    linear-gradient(248deg, rgba(23, 132, 71, 0.04) 0%, transparent 36%),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 48%, #f5f8f6 100%);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, input[type="checkbox"] { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(23, 132, 71, 0.22);
  outline-offset: 2px;
}
a { color: inherit; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-inner, .footer-inner {
  width: calc(100% - 40px);
  max-width: 1200px;
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; width: 116px; height: auto; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.header-tool-name { color: #37443d; font-size: 0.9rem; font-weight: 700; }
.lang-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--surface-muted);
}
.lang-btn {
  min-width: 42px;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.lang-btn.active { background: var(--surface); color: var(--ink-strong); box-shadow: 0 1px 4px rgba(24, 33, 29, 0.1); }

main {
  width: calc(100% - 40px);
  max-width: 1200px;
  margin: 0 auto;
  padding: 34px 0 64px;
}
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  align-items: end;
  gap: 24px;
  margin-bottom: 22px;
}
h1 {
  max-width: 860px;
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -0.045em;
}
.intro-copy p { max-width: 760px; margin: 12px 0 0; color: var(--muted); font-size: 1.04rem; }
.privacy-note {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid #c7e1d1;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: #245f3c;
  font-size: 0.88rem;
  font-weight: 700;
}
.privacy-note svg { flex: 0 0 auto; color: var(--green); }

.tool-panel {
  position: relative;
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}
.domain-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid #e8bbb8;
  border-radius: var(--radius);
  background: var(--coral-soft);
  color: #8c332e;
  font-size: 0.86rem;
  font-weight: 700;
}
.domain-banner svg { flex: 0 0 auto; margin-top: 2px; }
.tool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.tool-head h2 { margin: 0; color: var(--ink-strong); font-size: 1.32rem; line-height: 1.18; }
.tool-head p { max-width: 700px; margin: 7px 0 0; color: var(--muted); font-size: 0.9rem; }
.runtime-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid #c7e1d1;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}
.runtime-badge svg { width: 15px; height: 15px; }

.workflow-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr); gap: 18px; }
.panel { min-width: 0; padding: 18px; border: 1px solid var(--border-light); border-radius: var(--radius); background: #fcfdfc; }
.step-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.step-number {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}
.step-heading h3 { margin: 0; color: var(--ink-strong); font-size: 0.96rem; line-height: 1.2; }
.step-heading p { margin: 3px 0 0; color: var(--muted); font-size: 0.78rem; }

.dropzone {
  width: 100%;
  min-height: 252px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed #9eada4;
  border-radius: var(--radius);
  background: #fbfcfb;
  color: var(--ink);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--green); background: #f2faf5; }
.dropzone.dragover { transform: translateY(-1px); }
.dropzone:disabled { cursor: not-allowed; }
.upload-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
}
.upload-icon svg { width: 25px; height: 25px; }
.drop-title { font-size: 1.05rem; font-weight: 800; }
.drop-or { margin: 4px 0 0; color: var(--muted); font-size: 0.84rem; }
.browse-text { color: var(--green-dark); font-size: 0.94rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.drop-hint { margin-top: 10px; color: var(--muted); font-size: 0.8rem; }
#imageInput { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.source-meta {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid #c7e1d1;
  border-radius: 6px;
  background: var(--green-soft);
}
.file-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 5px; background: #fff; color: var(--green); }
.file-icon svg { width: 17px; height: 17px; }
.source-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.source-copy strong, .source-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-copy strong { color: var(--ink-strong); font-size: 0.79rem; }
.source-copy span { color: #437253; font-size: 0.72rem; }
.source-meta .icon-button { margin-left: auto; }

.field-group + .field-group { margin-top: 18px; }
.field-label { display: block; margin-bottom: 8px; color: #46534b; font-size: 0.72rem; font-weight: 800; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-label-row .field-label { margin-bottom: 8px; }
.scale-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.scale-option {
  min-height: 42px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #46534b;
  font-size: 0.86rem;
  font-weight: 800;
}
.scale-option:hover { border-color: var(--green); color: var(--green-dark); }
.scale-option.active { border-color: var(--green); background: var(--green); color: #fff; box-shadow: 0 5px 12px rgba(23, 132, 71, 0.18); }
.local-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--green-dark); font-size: 0.7rem; font-weight: 800; }
.local-chip svg { width: 13px; height: 13px; }
.model-list { display: grid; gap: 7px; }
.model-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.model-row:hover { border-color: #9bc8ac; background: #f8fcf9; }
.model-row[data-selected="true"] { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.model-row[data-state="trying"] { border-color: #9bc8ac; background: #f3fbf5; }
.model-row[data-state="success"] { border-color: #9bc8ac; background: #f3fbf5; }
.model-row[data-state="failed"] { border-color: #e6c4c1; background: #fffafa; }
.model-radio { width: 17px; height: 17px; margin: 0; accent-color: var(--green); }
.model-radio:disabled { cursor: not-allowed; }
.model-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.model-name { color: var(--ink-strong); font-size: 0.78rem; font-weight: 800; }
.model-description { overflow: hidden; color: var(--muted); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.model-status { color: var(--muted); font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
.model-row[data-state="trying"] .model-status { color: var(--green-dark); }
.model-row[data-state="success"] .model-status { color: var(--green-dark); }
.model-row[data-state="failed"] .model-status { color: var(--danger); }
.model-row[data-state="trying"] .model-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 4px; border: 1.5px solid currentColor; border-top-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.rotation-note { min-height: 48px; display: flex; align-items: center; gap: 9px; margin-top: 16px; padding: 10px 11px; border: 1px solid #c7e1d1; border-radius: 6px; background: var(--green-soft); color: var(--green-dark); }
.rotation-note > svg { width: 17px; height: 17px; flex: 0 0 auto; }
.rotation-note > span { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rotation-note strong { font-size: 0.75rem; }
.rotation-note small { color: #437253; font-size: 0.66rem; }
.primary-button, .secondary-button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.primary-button { width: 100%; margin-top: 16px; padding: 10px 16px; border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--green-dark); border-color: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: 0.45; }
.primary-button svg, .secondary-button svg { width: 16px; height: 16px; }
.secondary-button { padding: 9px 13px; border: 1px solid var(--border); background: #fff; color: var(--ink-strong); }
.secondary-button:hover:not(:disabled) { border-color: var(--green); color: var(--green-dark); }
.status-line { min-height: 29px; display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 0.72rem; }
.status-line[data-tone="working"] { color: var(--green-dark); }
.status-line[data-tone="success"] { color: var(--green-dark); }
.status-line[data-tone="error"] { color: var(--danger); }
.status-line svg { width: 14px; height: 14px; flex: 0 0 auto; }

.preview-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-light); }
.preview-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.preview-head h3 { margin: 0; color: var(--ink-strong); font-size: 1rem; }
.preview-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.76rem; }
.preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.zoom-controls { min-height: 43px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.zoom-label { color: var(--muted); font-size: 0.7rem; font-weight: 700; white-space: nowrap; }
.zoom-value { width: 29px; color: var(--ink-strong); font-size: 0.72rem; font-weight: 800; text-align: center; }
.zoom-controls .icon-button:hover:not(:disabled) { border-color: var(--green); color: var(--green-dark); }
.zoom-controls .icon-button:disabled { cursor: not-allowed; opacity: 0.38; }
.compare-frame { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--border-light); border-radius: 6px; background: #fff; }
.compare-frame figcaption { min-height: 37px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; border-bottom: 1px solid var(--border-light); color: var(--ink-strong); font-size: 0.75rem; font-weight: 800; }
.compare-caption-label { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.compare-caption-label small { color: var(--muted); font-size: 0.68rem; font-weight: 600; }
.compare-caption-enhanced { text-align: right; }
.compare-stage { --compare-position: 50%; --preview-zoom: 1; position: relative; width: 100%; height: clamp(280px, 52vw, 610px); overflow: hidden; background-color: #f8faf9; isolation: isolate; }
.compare-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; transform: scale(var(--preview-zoom)); transform-origin: center; transition: transform 180ms ease; user-select: none; -webkit-user-drag: none; }
.compare-after { position: absolute; inset: 0; z-index: 1; clip-path: inset(0 0 0 var(--compare-position)); pointer-events: none; }
.compare-divider { position: absolute; top: 0; bottom: 0; left: var(--compare-position); z-index: 2; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(17, 25, 21, 0.34), 0 0 12px rgba(17, 25, 21, 0.2); transform: translateX(-1px); pointer-events: none; }
.compare-handle { position: absolute; top: 50%; left: 50%; width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 4px 16px rgba(17, 25, 21, 0.28); transform: translate(-50%, -50%); }
.compare-handle svg { width: 19px; height: 19px; }
.compare-range { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare-stage:focus-within { outline: 3px solid rgba(23, 132, 71, 0.24); outline-offset: -3px; }
.compare-stage:focus-within .compare-handle { box-shadow: 0 0 0 4px rgba(23, 132, 71, 0.24), 0 4px 16px rgba(17, 25, 21, 0.28); }
.checkerboard { background-image: linear-gradient(45deg, #edf1ee 25%, transparent 25%), linear-gradient(-45deg, #edf1ee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #edf1ee 75%), linear-gradient(-45deg, transparent 75%, #edf1ee 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; background-color: #f8faf9; }
.result-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 12px; border: 1px solid #c7e1d1; border-radius: 6px; background: var(--green-soft); color: #245f3c; font-size: 0.74rem; }
.result-note svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }

.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 32px; }
.info-item { display: flex; align-items: flex-start; gap: 11px; padding-top: 16px; border-top: 1px solid var(--border); }
.info-item > svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--green); }
.info-item h3 { margin: 0; color: var(--ink-strong); font-size: 0.82rem; }
.info-item p { margin: 4px 0 0; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }

.icon-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 1px solid var(--border-light); border-radius: 5px; background: #fff; color: var(--muted); }
.icon-button:hover { border-color: var(--coral); color: var(--danger); }
.icon-button svg { width: 15px; height: 15px; }
.site-footer { border-top: 1px solid var(--border-light); background: #fff; color: var(--muted); font-size: 0.74rem; }
.footer-inner { min-height: 58px; }
.site-footer a { color: var(--green-dark); font-weight: 800; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: min(360px, calc(100vw - 40px)); padding: 11px 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; box-shadow: var(--shadow-strong); color: var(--ink-strong); font-size: 0.78rem; font-weight: 700; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast[data-tone="error"] { border-color: #e8bbb8; color: var(--danger); background: var(--coral-soft); }
.toast[data-tone="success"] { border-color: #c7e1d1; color: var(--green-dark); background: var(--green-soft); }

body[data-domain-blocked="true"] .dropzone, body[data-domain-blocked="true"] .scale-option, body[data-domain-blocked="true"] .model-row { filter: grayscale(0.8); }
body[data-processing="true"] .dropzone { cursor: progress; }

@media (max-width: 860px) {
  .intro { grid-template-columns: 1fr; align-items: start; }
  .privacy-note { max-width: 420px; }
  .workflow-grid { grid-template-columns: 1fr; }
  .upload-panel .dropzone { min-height: 220px; }
}

@media (max-width: 620px) {
  .header-inner, .footer-inner, main { width: calc(100% - 28px); }
  .header-inner { min-height: 58px; }
  .brand img { width: 102px; }
  .header-actions { gap: 10px; }
  .header-tool-name { display: none; }
  main { padding-top: 25px; padding-bottom: 44px; }
  h1 { font-size: 2.15rem; letter-spacing: -0.035em; }
  .intro-copy p { font-size: 0.92rem; }
  .tool-panel { padding: 15px; }
  .tool-head { display: block; }
  .tool-head h2 { font-size: 1.12rem; }
  .runtime-badge { margin-top: 12px; }
  .panel { padding: 14px; }
  .dropzone { min-height: 196px; }
  .info-grid { grid-template-columns: 1fr; }
  .compare-stage { height: clamp(240px, 72vw, 390px); }
  .preview-head { align-items: flex-start; flex-direction: column; }
  .preview-actions { width: 100%; justify-content: space-between; }
  .preview-actions .secondary-button { flex: 1 1 auto; }
  .zoom-label { display: none; }
  .footer-inner { min-height: 70px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; }
  .toast { right: 14px; bottom: 14px; max-width: calc(100vw - 28px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
