
:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --bg: #eef3f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #cfd8e3;
  --ok: #0f766e;
  --error: #b91c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
  padding: 20px 14px 68px;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

h1 { margin: 0 0 8px; font-size: clamp(1.45rem, 3vw, 2rem); color: #0f3d79; }
p { line-height: 1.7; }
.lead { margin: 0; color: var(--muted); }
.notice {
  margin-top: 14px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  color: #334155;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
  margin-top: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.card h2 { margin: 0 0 12px; font-size: 1.05rem; color: #0f3d79; }
.drop-zone {
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 2px dashed #93b4db;
  border-radius: 16px;
  background: #f8fbff;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.08s;
  padding: 18px;
}
.drop-zone.dragover { background: #e8f2ff; border-color: var(--primary); transform: scale(1.01); }
.drop-title { display:block; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.drop-small { display:block; color: var(--muted); font-size: 0.88rem; }
input[type="file"] { display: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label { display: grid; gap: 6px; font-size: 0.88rem; color: #334155; }
select, input[type="number"], input[type="color"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 9px;
  background: #fff;
  font: inherit;
}
input[type="color"] { padding: 3px; }
.check-label { display:flex; align-items:center; gap:8px; padding-top:24px; }
.check-label input { width: 18px; height: 18px; }

.actions { display:flex; flex-wrap:wrap; gap:10px; margin-top: 14px; }
button {
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.48; cursor: not-allowed; }
.secondary { background: #64748b; }
.secondary:hover { background: #475569; }

.file-list { display:flex; flex-wrap:wrap; gap:8px; margin-top: 12px; }
.file-pill {
  color: #0f3d79;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 7px 10px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-pill:hover { background:#dbeafe; color:#0f3d79; }

.preview-wrap { display:grid; gap:10px; }
canvas {
  display:block;
  width:100%;
  max-height: 520px;
  object-fit: contain;
  background: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border:1px solid var(--border);
  border-radius: 14px;
}
.preview-info { color: var(--muted); font-size: 0.9rem; }

.log-box {
  height: 190px;
  overflow:auto;
  background:#0f172a;
  color:#e2e8f0;
  border-radius:14px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height:1.6;
}
.log-line.ok { color:#99f6e4; }
.log-line.error { color:#fecaca; }

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 32px;
  border-top: 1px solid #cfd8e3;
  background: #eef3f8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.app-footer p { margin: 0; padding: 5px 10px; font-size: 0.82rem; line-height: 1.2; color: #1d4ed8; text-align:center; }
.app-footer a { color: #1d4ed8; text-decoration: none; font-weight:700; }
.app-footer a:hover { text-decoration: underline; }

.ad-panel {
  width: min(1120px, calc(100% - 28px));
  margin: 14px auto 0;
  border: 1px solid #d7e6f8;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.ad-panel[hidden] { display:none !important; margin:0 !important; padding:0 !important; border:0 !important; height:0 !important; overflow:hidden !important; }
.ad-panel-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:5px 8px;
  background:#f4f8ff;
  border-bottom:1px solid #d7e6f8;
}
.ad-label, .ad-wait-message { font-size:0.72rem; color:#4f6f91; line-height:1.2; }
.ad-close-btn {
  margin:0 !important;
  padding:3px 8px !important;
  border:0;
  border-radius:999px;
  background:#1565c0;
  color:#fff;
  font-size:0.72rem !important;
  line-height:1.2;
  font-weight:700;
  cursor:pointer;
}
.ad-close-btn:hover { background:#0d47a1; }
.ad-close-btn[hidden] { display:none !important; }
.ad-body { padding: 8px; background:#fff; }

@media (max-width: 760px) {
  body { padding: 12px 10px 72px; }
  .grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .check-label { padding-top:0; }
}
