:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #d1d5db;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #107c41;
  --accent-hover: #0d592f;
  --accent-soft: #e7f4ec;
  --progress: #2e72d2;
  --error: #b91c1c;
  --error-soft: #fef2f2;
  --warn: #b45309;
  --ok-soft: #ecfdf5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #1b1f24;
    --border: #343a42;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #2ea866;
    --accent-hover: #3cc47a;
    --accent-soft: #16301f;
    --progress: #5b9bf0;
    --error: #f87171;
    --error-soft: #2a1515;
    --warn: #f59e0b;
    --ok-soft: #12291e;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.tenant { color: var(--muted); font-size: .9rem; }
.topbar nav { margin-left: auto; display: flex; gap: 1rem; align-items: center; }

.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 16px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.25rem; margin-bottom: 1.25rem; min-width: 0;
}
.card.login { width: 100%; max-width: 380px; text-align: left; }
.card.narrow { max-width: 480px; }

label { display: block; margin-bottom: .9rem; font-size: .9rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .65rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--text); font: inherit;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.check { display: inline-flex; align-items: center; gap: .4rem; margin-right: 1.2rem; }
label.check input { width: auto; margin: 0; }
fieldset { border: none; padding: 0; margin: 0 0 .9rem; }
legend { font-size: .9rem; margin-bottom: .3rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

button, .btn {
  display: inline-block; padding: .5rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font: inherit; font-size: .9rem; text-decoration: none;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.wide { width: 100%; padding: .7rem; }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.small, .btn { font-size: .82rem; padding: .3rem .7rem; }
.btn { border-color: var(--accent); color: var(--accent); }
.btn:hover { background: var(--accent-soft); }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.small-input { width: 9rem; margin: 0; padding: .3rem .5rem; font-size: .82rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.alert { padding: .6rem .8rem; border-radius: 6px; font-size: .9rem; }
.alert.error { background: var(--error-soft); color: var(--error); }
.alert.ok { background: var(--ok-soft); color: var(--accent); }
.err { color: var(--error); }
.warn { color: var(--warn); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  padding: 2rem 1rem; border: 2px dashed var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dz-title { font-weight: 600; }
.selected { list-style: none; padding: 0; margin: .5rem 0 1rem; font-size: .85rem; }
.selected li { padding: .2rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

.jobs { list-style: none; padding: 0; margin: 0; }
.jobs .empty { padding: 1rem 0; }
.job { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.job-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.job .name { font-weight: 600; overflow-wrap: anywhere; }
.badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; background: var(--bg); }
.badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.error { background: var(--error-soft); color: var(--error); }
.badge.running { color: var(--progress); }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: .4rem 0 .2rem; }
.fill { height: 100%; background: var(--progress); transition: width .3s; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }

table.users { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.users th, table.users td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--border); }
td.ops { display: flex; gap: .6rem; flex-wrap: wrap; }
@media (max-width: 620px) {
  table.users thead { display: none; }
  table.users tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  table.users td { display: block; border: none; padding: .15rem 0; }
}

.selected li { cursor: pointer; padding-left: .4rem; border-left: 3px solid transparent; }
.selected li:hover { background: var(--accent-soft); }
.selected li.active { border-left-color: var(--accent); font-weight: 600; }

.preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1rem; }
.preview-head {
  display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .35rem .6rem; background: var(--bg); border-bottom: 1px solid var(--border);
}
.preview-head span:first-child { overflow-wrap: anywhere; }
.preview-body { height: 460px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.pdf-pages { align-self: stretch; width: 100%; overflow-y: auto; padding: 8px; }
.pdf-pages canvas { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.page-no { text-align: center; margin: .2rem 0 .6rem; }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-body .placeholder { padding: 1rem; text-align: center; }
@media (max-width: 520px) { .preview-body { height: 320px; } }

.result-text { margin-top: .6rem; position: relative; }
.result-text button { position: absolute; top: .4rem; right: .4rem; }
.result-text pre {
  margin: 0; padding: .7rem; padding-top: 2.4rem; max-height: 360px; overflow: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-family: "BIZ UDGothic", "Yu Gothic UI", ui-monospace, monospace; font-size: .85rem;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---- プラン表示（色は料金プラン資料に合わせる） ---- */
.plan-badge {
  display: inline-block; padding: .1rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; color: #fff; white-space: nowrap;
}
.plan-simple { background: #6f8f9a; }
.plan-standard { background: #4e8296; }
.plan-plus { background: #009fbe; }
.plan-pro { background: #006b45; }

.features { list-style: none; padding: 0; margin: .5rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem 1rem; }
.features li { font-size: .9rem; }
.features li.on span[aria-hidden] { color: var(--accent); }
.features li.off { color: var(--muted); }
.features li.off span[aria-hidden] { color: var(--error); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.folder-pick { margin-top: .5rem; text-align: center; }
.folder-pick .btn { cursor: pointer; }

/* ---- AI補正 ON/OFF スイッチ ---- */
.ai-box { border: 1px solid var(--border); border-radius: 8px; padding: .8rem .9rem .2rem; margin-bottom: 1rem; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; margin-bottom: .6rem; font-size: .95rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 44px; height: 24px; border-radius: 999px;
  background: var(--border); transition: background .15s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-style { margin-bottom: .6rem; }
