: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;
  --warning-bg: #fffaf0;
  --warning-border: #e7c98b;
  --warning-text: #654c20;
  --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,
h3,
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);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: 0;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(350px, 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);
}

.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="warning"] {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(600px, 1.18fr);
  gap: 20px;
  align-items: stretch;
}

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

.panel-upload,
.controls {
  padding: 26px;
}

.drop-zone {
  position: relative;
  display: flex;
  min-height: 440px;
  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);
  font-size: 0.91rem;
}

.drop-help {
  margin-top: 12px;
  color: #7e827e;
  font-size: 0.82rem;
}

.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 {
  border-color: #d7d8d5;
  background: #e9eae8;
  color: #999d99;
  cursor: not-allowed;
  opacity: 1;
}

.button:disabled img {
  opacity: 0.55;
}

.button-primary {
  background: var(--green);
  color: #ffffff;
  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-secondary,
.button-ghost {
  border-color: var(--border);
  background: #ffffff;
  color: #4d544f;
}

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

.select-button {
  min-width: 245px;
  min-height: 48px;
  font-size: 1rem;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--warning-border);
  border-radius: 9px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.83rem;
  font-weight: 600;
}

.notice img {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  object-fit: contain;
}

.batch-note {
  margin: 20px 0 0;
}

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

.section-heading h2,
.section-heading h3 {
  margin-bottom: 2px;
  line-height: 1.4;
}

.section-heading h2 {
  font-size: 1.25rem;
}

.section-heading h3 {
  font-size: 0.96rem;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.settings-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-heading > img {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  object-fit: contain;
}

.section-heading.compact {
  margin-bottom: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.radio-group legend {
  font-size: 0.82rem;
  font-weight: 800;
}

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

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

.size-grid {
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  gap: 10px;
}

.size-lock {
  display: grid;
  width: 28px;
  height: 28px;
  align-self: end;
  margin-bottom: 8px;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
}

.size-lock img {
  width: 16px;
  opacity: 0.62;
}

.option-row {
  margin: 0 0 16px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.check-field input,
.radio-group input,
.fit-card input {
  accent-color: var(--green);
}

.check-field input {
  width: 16px;
  height: 16px;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.radio-group legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.radio-group label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.81rem;
  font-weight: 700;
}

.radio-group label:has(input:checked),
.fit-card:has(input:checked) {
  border-color: #75a994;
  background: #f5faf7;
}

.fit-options {
  margin-bottom: 16px;
}

.fit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.fit-card {
  position: relative;
  display: grid;
  min-height: 142px;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 18px 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: #ffffff;
  cursor: pointer;
}

.fit-card input {
  position: absolute;
  top: 9px;
  right: 9px;
}

.fit-card > img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.fit-card strong,
.fit-card small {
  display: block;
}

.fit-card strong {
  margin-bottom: 3px;
  color: #32443d;
  font-size: 0.82rem;
}

.fit-card small {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.65;
}

.upscale-notice {
  margin-top: -4px;
}

.quality-field {
  margin-bottom: 14px;
}

.quality-title strong {
  display: inline-grid;
  min-width: 42px;
  min-height: 30px;
  margin-left: 8px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.range-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.range-row small {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.quality-field input[type="range"] {
  min-height: auto;
  padding: 0;
  accent-color: var(--green);
}

.filename-option {
  margin-bottom: 0;
}

.batch-panel {
  grid-column: 1 / -1;
  padding: 20px 24px;
}

.batch-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.batch-header .section-heading {
  margin-bottom: 10px;
}

.batch-header h2 {
  font-size: 1rem;
}

.batch-header h2 span {
  color: var(--green);
}

.clear-button {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 0.76rem;
}

.batch-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 325px;
  gap: 24px;
  align-items: center;
}

.empty-state {
  display: grid;
  min-height: 104px;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 2px;
}

.batch-item {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #ffffff;
}

.batch-thumb {
  display: grid;
  width: 96px;
  aspect-ratio: 1.2 / 1;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: #f2f4f2;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.batch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-info {
  min-width: 0;
  padding-right: 22px;
}

.batch-info h3 {
  margin: 0 0 5px;
  overflow: hidden;
  font-size: 0.78rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-info p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.68rem;
}

.batch-metrics {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
}

.batch-metrics div {
  min-width: 0;
  padding: 5px 7px;
  border-radius: 5px;
  background: #f7f8f6;
}

.batch-metrics dt {
  color: var(--muted);
  font-size: 0.59rem;
  font-weight: 700;
}

.batch-metrics dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.68rem;
  font-weight: 800;
}

.batch-action {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 7px;
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f6f7f5;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 800;
}

.status-loading,
.status-converting {
  border-color: #aebfd1;
  background: #f0f5fa;
  color: #355b7d;
}

.status-done {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.status-failed {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.batch-download {
  min-height: 27px;
  margin-left: auto;
  padding: 3px 8px;
  font-size: 0.62rem;
}

.remove-item {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #606762;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.remove-item:hover,
.remove-item:focus-visible {
  background: #f0f2ef;
  color: var(--green-dark);
}

.batch-actions {
  display: grid;
  gap: 8px;
  align-content: center;
}

.batch-actions > small {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.convert-button {
  min-height: 58px;
  font-size: 1rem;
}

.zip-button {
  min-height: 40px;
  font-size: 0.78rem;
}

.progress-wrap {
  display: grid;
  gap: 5px;
}

.progress-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #eceeeb;
}

progress::-webkit-progress-bar {
  background: #eceeeb;
}

progress::-webkit-progress-value {
  background: var(--green);
}

progress::-moz-progress-bar {
  background: var(--green);
}

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

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

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(300px, 0.8fr) minmax(500px, 1.2fr);
  }

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

  .fit-card {
    min-height: 115px;
  }

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

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

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

  .privacy-note {
    width: 100%;
  }

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

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

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

  .batch-actions {
    grid-row: 1;
  }

  .image-list {
    max-height: none;
  }
}

@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;
  }

  .panel-upload,
  .controls,
  .batch-panel {
    padding: 16px;
  }

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

  .upload-visual {
    width: 125px;
  }

  .field-grid,
  .size-grid,
  .radio-group,
  .fit-grid,
  .image-list {
    grid-template-columns: 1fr;
  }

  .size-lock {
    display: none;
  }

  .field-grid {
    gap: 12px;
  }

  .radio-group label {
    min-height: 46px;
  }

  .fit-card {
    min-height: 98px;
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .range-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .range-row small:last-child {
    text-align: right;
  }

  .batch-header {
    align-items: center;
  }

  .batch-header .section-heading p {
    display: none;
  }

  .batch-item {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .batch-thumb {
    width: 82px;
  }

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