:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1a1d23;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f54eb;
  --accent-d: #1d3bbf;
  --ok: #1f9d55;
  --warn: #b7791f;
  --err: #d64545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,25,40,.08), 0 1px 2px rgba(20,25,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.7;
}
button { font-family: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; transition: .12s; }
button:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); }
.btn-secondary { background: #eef1fe; color: var(--accent-d); }
.btn-secondary:hover { background: #e0e6fd; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f0f1f3; }
select, input, textarea {
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,84,235,.12); }
.muted { color: var(--muted); }

/* ───── ログイン ───── */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 36px 32px; border-radius: 14px; box-shadow: var(--shadow); width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 18px; margin: 0; }
.login-card .brand { font-weight: 800; letter-spacing: .14em; color: var(--accent); font-size: 13px; }
.login-card input { padding: 11px 12px; }
.login-card button { padding: 11px; background: var(--accent); color: #fff; }
.login-card .err { color: var(--err); font-size: 12px; min-height: 16px; margin: 0; }

/* ───── トップバー ───── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand-row { display: flex; align-items: baseline; gap: 12px; }
.brand { font-weight: 800; letter-spacing: .14em; color: var(--accent); }
.app-name { font-weight: 700; font-size: 15px; }
.top-actions { display: flex; gap: 8px; }

/* ───── レイアウト ───── */
.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 53px); }
.sidebar { border-right: 1px solid var(--line); padding: 12px; background: #fafbfc; display: flex; flex-direction: column; gap: 10px; }
.sidebar #search { width: 100%; }
.case-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.case-list .empty { color: var(--muted); font-size: 12px; padding: 12px 6px; }
.case-item { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 28px 9px 10px; cursor: pointer; }
.case-item:hover { border-color: #cdd3da; }
.case-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,84,235,.1); }
.ci-title { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-meta { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.ci-snip { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-status { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.ci-status.s-done, .ci-status.s-generated { background: #e6f5ec; color: var(--ok); }
.ci-status.s-queued, .ci-status.s-generating { background: #fdf3e2; color: var(--warn); }
.ci-status.s-error { background: #fbe9e9; color: var(--err); }
.ci-del { position: absolute; top: 6px; right: 6px; background: transparent; color: #c2c7cf; padding: 2px 6px; font-size: 14px; line-height: 1; }
.ci-del:hover { color: var(--err); }

/* ───── メイン ───── */
.main { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.editor, .output { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.title-input { width: 100%; font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.brief { width: 100%; min-height: 240px; resize: vertical; line-height: 1.7; }
.settings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0; }
.setting { display: flex; flex-direction: column; gap: 3px; }
.setting label { font-size: 11px; color: var(--muted); font-weight: 600; }
.setting select { width: 100%; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-pill { font-size: 12px; color: var(--muted); margin-left: auto; }
.status-pill.s-queued, .status-pill.s-generating { color: var(--warn); }
.status-pill.s-done, .status-pill.s-generated { color: var(--ok); }
.status-pill.s-error { color: var(--err); }

/* ───── 出力 ───── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; padding: 8px 12px; font-weight: 700; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.output textarea { width: 100%; min-height: 320px; resize: vertical; }
.output textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6; background: #fbfbfc; }
.output textarea.jp { line-height: 1.85; }
.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn-copy { background: #eef1f4; color: var(--ink); }
.btn-copy:hover { background: #e3e7eb; }

/* ───── NGチェック ───── */
.ng-results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ng-item { display: flex; gap: 9px; padding: 8px 10px; border-radius: 8px; background: #f7f8fa; align-items: flex-start; }
.ng-item.ok { background: #f1f9f4; }
.ng-item.ng-error { background: #fdf0f0; }
.ng-item.ng-warn { background: #fdf7ec; }
.ng-mark { font-weight: 800; width: 18px; text-align: center; flex: none; }
.ng-item.ok .ng-mark { color: var(--ok); }
.ng-item.ng-error .ng-mark { color: var(--err); }
.ng-item.ng-warn .ng-mark { color: var(--warn); }
.ng-item.ng-info .ng-mark { color: var(--accent); }
.ng-label { font-weight: 700; font-size: 12.5px; }
.ng-detail { font-size: 12px; color: var(--muted); }

/* ───── トースト ───── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a1d23; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───── レスポンシブ（スマホ） ───── */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); max-height: 38vh; }
}
@media (max-width: 560px) {
  .settings { grid-template-columns: 1fr 1fr; }
  .app-name { display: none; }
  .topbar { padding: 10px 12px; }
  .main { padding: 12px; }
}
