/* DasuMae PDF — styles. Light + dark via prefers-color-scheme.
   Ad regions are reserved in the layout but collapse to nothing while
   ADS_ENABLED is false (body[data-ads-enabled="false"]). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16202c;
  --text-muted: #5a6b7b;
  --border: #d8dee6;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0ff;
  --danger: #b4232a;
  --ok: #1f7a46;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 44, .06), 0 6px 20px rgba(16, 32, 44, .06);
  --maxw: 980px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #161c24;
    --surface-2: #1d252f;
    --text: #e8edf3;
    --text-muted: #9fb0c0;
    --border: #2a333f;
    --accent: #4b8bff;
    --accent-ink: #0b1016;
    --accent-soft: #16233a;
    --danger: #ff6b72;
    --ok: #4cc585;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 20px 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 750; font-size: 20px; }
.brand-descriptor { color: var(--text-muted); font-size: 13px; }
.tagline { margin: 0; color: var(--text-muted); font-size: 15px; }
.lang-toggle {
  margin-left: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- layout ---------- */
.layout { max-width: var(--maxw); margin: 0 auto; padding: 12px 20px 40px; }

.hero { padding: 20px 0 8px; }
.hero h1 { font-size: clamp(24px, 4vw, 34px); margin: 8px 0 10px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--text-muted); max-width: 62ch; }

.work { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 8px; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-hint { margin: 0; color: var(--text-muted); display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; }
.file-btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 650;
  cursor: pointer;
}
.file-btn:hover { filter: brightness(1.05); }

/* ---------- file bar ---------- */
.file-bar { margin-top: 14px; }
.file-status { margin: 0 0 6px; color: var(--text-muted); font-size: 14px; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 14px;
}
.file-list .fname { font-weight: 600; }
.file-list .fmeta { color: var(--text-muted); }
.file-list .fremove { margin-left: auto; }
.ghost-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 999px; padding: 4px 12px;
  font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 0; border-bottom: 1px solid var(--border); }
.tab {
  appearance: none; background: transparent; border: none;
  padding: 10px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 19px; }
.panel-intro { margin: 0 0 16px; color: var(--text-muted); font-size: 14px; }
.need-file { color: var(--text-muted); font-style: italic; }
.hint { color: var(--text-muted); font-size: 13px; margin: 10px 0 0; }

.primary-btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: var(--radius-sm); padding: 11px 20px;
  font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 12px;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; max-width: 340px; }
.field-label { font-weight: 600; font-size: 14px; }
.text-input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 15px; font-family: inherit;
}
.text-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- metadata table ---------- */
.meta-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.meta-table th, .meta-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.meta-table th { width: 170px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.meta-table td { word-break: break-word; }
.meta-table .is-empty { color: var(--text-muted); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--present { background: var(--accent-soft); color: var(--accent); }
.badge--absent { background: var(--surface-2); color: var(--text-muted); }
.all-clear { color: var(--ok); font-weight: 600; }

/* ---------- merge list ---------- */
.merge-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.merge-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; cursor: grab; font-size: 14px;
}
.merge-list li.drag-over { border-color: var(--accent); }
.merge-list .handle { color: var(--text-muted); cursor: grab; }
.merge-list .idx { font-variant-numeric: tabular-nums; color: var(--text-muted); width: 1.4em; }

/* ---------- organize grid ---------- */
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 4px; }
.org-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px; display: flex; flex-direction: column; gap: 8px; cursor: grab;
}
.org-card.drag-over { border-color: var(--accent); }
.org-card.deleted { opacity: .45; }
.org-thumb { position: relative; background: var(--surface); border-radius: 6px; overflow: hidden; display: grid; place-items: center; min-height: 150px; }
.org-thumb canvas, .org-thumb img { max-width: 100%; height: auto; display: block; transition: transform .15s; }
.org-pagenum { position: absolute; top: 4px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px; }
.org-del-flag { position: absolute; inset: 0; display: grid; place-items: center; color: var(--danger); font-weight: 700; font-size: 13px; background: rgba(180,35,42,.1); }
.org-actions { display: flex; gap: 6px; justify-content: center; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 5px 8px; font-size: 13px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- results / toast ---------- */
.result {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-size: 14px;
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}
.result .delta { color: var(--text-muted); }
.result.error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; z-index: 20;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- limits + footer ---------- */
.limits { margin-top: 24px; padding: 16px 18px; background: var(--surface-2); border-radius: var(--radius); }
.limits h2 { margin: 0 0 6px; font-size: 16px; }
.limits p { margin: 0; color: var(--text-muted); font-size: 14px; }
.site-footer { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 40px; color: var(--text-muted); font-size: 13px; }
.site-footer p { margin: 2px 0; }
.site-footer .muted { opacity: .8; }

/* ---------- ad slots (reserved; collapsed while disabled) ---------- */
.ad-slot { display: none; }
.ad-slot--below { width: 100%; }
body[data-ads-enabled="true"] .ad-slot--below {
  display: block; min-height: 90px; margin: 20px 0 0;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius);
}
body[data-ads-enabled="true"] .ad-slot--side { display: block; }

/* When ads are enabled, widen the layout and add a sidebar column. */
@media (min-width: 1100px) {
  body[data-ads-enabled="true"] { --maxw: 1180px; }
  body[data-ads-enabled="true"] .work { grid-template-columns: 1fr 300px; align-items: start; }
  body[data-ads-enabled="true"] .ad-slot--side {
    min-height: 600px; position: sticky; top: 16px;
    background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius);
  }
}

@media (max-width: 560px) {
  .site-header { gap: 10px; }
  .tagline { flex-basis: 100%; order: 3; }
  .lang-toggle { margin-left: auto; }
  .meta-table th { width: 120px; }
}
