:root {
  --ink: #17201d;
  --muted: #66716d;
  --paper: #f5f2e9;
  --panel: #fffdf7;
  --line: #d8d4c8;
  --accent: #e4603b;
  --accent-dark: #bf4627;
  --green: #2a6853;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f4ec, #e8eee9);
  font-family: "Noto Sans JP", "Yu Gothic", sans-serif;
  min-height: 100vh;
}

.shell { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 72px; }
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.site-nav a {
  padding: 8px 12px;
  color: #3f4a45;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
}
.site-nav a:hover { border-color: var(--accent); color: var(--accent-dark); }
header { margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.05; }
h2 { margin-bottom: 0; font-size: 1.35rem; }
.eyebrow { margin-bottom: 8px; color: var(--accent-dark); font: 700 .72rem/1.2 monospace; letter-spacing: .16em; }
.lead { max-width: 680px; color: var(--muted); }

.panel {
  margin-top: 18px;
  padding: clamp(18px, 4vw, 34px);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid rgba(23, 32, 29, .12);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(36, 43, 39, .08);
}

form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: .84rem; font-weight: 700; color: #45504c; }
input, button, .download-link, textarea { font: inherit; }
input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%;
  padding: 10px 13px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
input[type="text"], input[type="email"], input[type="number"] { min-height: 46px; }
textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.7;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #e4603b20; }
input[type="color"] { width: 100%; height: 46px; padding: 4px; background: white; border: 1px solid var(--line); border-radius: 8px; }

.drop-zone {
  position: relative;
  min-height: 156px;
  display: grid;
  place-items: center;
  padding: 26px;
  text-align: center;
  background: #ffffff;
  border: 2px dashed #c8c2b5;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.drop-zone.dragging, .drop-zone:focus {
  background: #fff8f3;
  border-color: var(--accent);
  outline: none;
}
.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.drop-zone strong { display: block; margin-bottom: 8px; font-size: 1.25rem; }
.drop-zone span { color: var(--muted); }

.limits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.limits span {
  padding: 7px 10px;
  color: #3f4a45;
  background: #f4f1e9;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 700;
}

.file-summary, .actions, .unit-input { display: flex; align-items: center; gap: 14px; }
.file-summary {
  min-height: 48px;
  padding: 12px;
  background: #f7f4ec;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.file-summary strong { font-size: 1rem; }
.file-summary span { color: var(--muted); font-weight: 700; }
.file-summary button { margin-left: auto; }

.file-list {
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  color: var(--muted);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .86rem;
}
.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #eee9df;
}
.file-row:last-child { border-bottom: 0; }
.file-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-input { position: relative; gap: 0; }
.unit-input span { margin-left: -36px; color: var(--muted); pointer-events: none; }
.actions { margin-top: 5px; flex-wrap: wrap; }
button, .download-link {
  min-height: 46px;
  padding: 10px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}
button.primary { color: white; border-color: var(--accent); background: var(--accent); }
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
.download-link { color: white; border-color: var(--green); background: var(--green); }
#message { color: var(--accent-dark); font-size: .84rem; font-weight: 700; }

.upload-status {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: #f4f1e9;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.upload-status[hidden] { display: none; }
.upload-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #d7d3c8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: upload-spin .8s linear infinite;
}
.upload-status-body { min-width: 0; }
.upload-status-heading { display: flex; justify-content: space-between; gap: 16px; }
.upload-status-heading span { color: var(--accent-dark); font: 700 1rem/1 monospace; }
.upload-track { height: 6px; margin: 9px 0 7px; overflow: hidden; background: #ddd9ce; border-radius: 100px; }
#upload-bar { width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .15s ease; }
.upload-status small { color: var(--muted); }
@keyframes upload-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upload-spinner { animation-duration: 1.8s; } }

.progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#progress-percent { color: var(--green); font: 700 2rem/1 monospace; }
.progress-track { height: 10px; margin: 20px 0 24px; overflow: hidden; background: #e3e1d9; border-radius: 100px; }
#progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), #eda55a); border-radius: inherit; transition: width .25s ease; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 22px; }
.stats div { padding: 12px; background: #f4f1e9; border-radius: 8px; }
.stats dt { color: var(--muted); font-size: .7rem; }
.stats dd { margin: 4px 0 0; font: 700 1.2rem/1 monospace; }
.logs { height: 240px; padding: 15px; overflow: auto; color: #d6e2dc; background: #202925; border-radius: 8px; font: .78rem/1.7 monospace; white-space: pre-wrap; }

.mobile-help {
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: .9rem;
}
.image-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.image-result-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.image-preview-link {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f4f1e9;
  border-radius: 6px;
}
.image-preview-link img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.image-result-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
}
.image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.image-actions a {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 8px 10px;
  color: var(--ink);
  background: #f7f4ec;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.image-actions a:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.article {
  font-size: 1rem;
  line-height: 1.9;
}
.article h2 { margin-bottom: 12px; }
.article p { max-width: 760px; }
.article figure {
  margin: 22px 0 0;
}
.article img {
  display: block;
  width: min(100%, 760px);
  max-height: 720px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.article figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.empty-page {
  min-height: 240px;
}
.request-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.required {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent-dark);
  font-size: .76rem;
}
.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}
.notice.success {
  color: #1d5b46;
  background: #e7f3ed;
  border-color: #bddccc;
}
.notice.error {
  color: #8a2f1b;
  background: #fff1ea;
  border-color: #efc4b5;
}

@media (max-width: 760px) {
  .shell { padding-top: 30px; }
  form { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .actions, .file-summary { align-items: stretch; flex-direction: column; }
  .file-summary button { margin-left: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .result-heading { align-items: stretch; flex-direction: column; }
  .image-results { grid-template-columns: 1fr; }
  .image-preview-link { aspect-ratio: 1 / 1; }
}
