/* データベース。style.css と flow.css の上に重ねる */
.subh { margin: 20px 0 10px; font-size: 15px; }
.dbchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chipbtn:focus-visible, .dbt tbody tr[tabindex]:focus-visible, .dctrl button:focus-visible, .seg button:focus-visible, .ckreset:focus-visible, .mlist input:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.chipbtn.dangerchip { color: #b91c1c; border-color: #fecaca; }
.chipbtn.dangerchip.on { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* 表 */
.dbtwo { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.dbt { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; transition: box-shadow .2s; }
.dbt.tbl { box-shadow: 0 0 0 3px #f59e0b; }
.dbtcap { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.dbtcap b { font-family: var(--latin); color: var(--ink); font-size: 13.5px; }
.dbtscroll { overflow-x: auto; }
.dbt table, .qres table, table.flat { border-collapse: collapse; width: 100%; font-size: 13px; }
.dbt th, .dbt td, .qres th, .qres td, table.flat th, table.flat td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.dbt th, .qres th, table.flat th { font-family: var(--latin); font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--line2); }
.dbt td, .qres td, table.flat td { transition: background .2s; }
.kb { font-style: normal; font-family: var(--latin); font-size: 9.5px; font-weight: 600; border-radius: 4px; padding: 0 4px; margin-left: 4px; vertical-align: 1px; }
.kb.pk { background: #fde68a; color: #92400e; }
.kb.fk { background: #bfdbfe; color: #1e40af; }
#cptTables tbody tr { cursor: pointer; }
#cptTables tbody tr:hover td { background: var(--line2); }
.dbt tr.use td { background: #fef9c3; font-weight: 700; }
.dbt tr.lk td { background: #dbeafe; }
.dbt td.pkc { background: #fde68a !important; color: #92400e; font-weight: 700; }
.dbt td.fkc { background: #bfdbfe !important; color: #1e40af; font-weight: 700; }
.dbt td.colc, .dbt th.colc { background: #dcfce7; color: #166534; font-weight: 700; }
.dbt tr.gone td { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.dbt td.chg { background: #dcfce7; color: #166534; font-weight: 700; }
.dbt td.chg s { color: var(--muted); font-weight: 400; }
.dbt tr.added td { background: #dcfce7; color: #166534; font-weight: 700; }
.dbnote { margin-top: 10px; padding: 12px 16px; display: flex; flex-direction: column; gap: 3px; }
.dbnote b { font-size: 14.5px; }
.dbnote span { font-size: 13px; color: var(--ink2); }

/* SQL のデモ */
.qlayout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.dbtwo-v { grid-template-columns: 1fr; }
.qside { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dbcode { margin: 0; font-family: var(--latin); font-size: 12.5px; line-height: 1.6; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qsay { margin: 0; font-size: 13px; color: var(--ink2); }
.qresh { font-size: 12px; font-weight: 700; color: var(--k-test); margin-bottom: 4px; }
.qres { border: 1px solid #a7f3d0; border-radius: 10px; padding: 8px 10px; background: #f0fdf4; }
.qres th { background: #dcfce7; color: #166534; }
.qeff { border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 14px; background: #f0fdf4; color: #166534; }
.qeff.danger { background: #fee2e2; color: #991b1b; }
.qleg { margin: 0; font-size: 11.5px; color: var(--muted); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg.use { background: #fde047; }
.lg.gone { background: #fca5a5; }
.lg.chg, .lg.add { background: #86efac; }

/* 正規化 */
.normgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.normcard { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.normcard h3 { margin: 0; font-size: 15px; }
table.flat td.dup { background: #fef9c3; }
table.flat td.chg { background: #dcfce7; color: #166534; font-weight: 700; }
table.flat td.miss { background: #fee2e2; color: #991b1b; font-weight: 700; }
table.flat td.miss em { font-style: normal; font-size: 10.5px; margin-left: 6px; background: #b91c1c; color: #fff; border-radius: 4px; padding: 1px 5px; }
.normsay { margin: 0; font-size: 13px; color: var(--ink2); border-radius: 8px; padding: 8px 10px; background: var(--line2); }
.normsay.bad { background: #fee2e2; color: #7f1d1d; }
.normsay.good { background: #dcfce7; color: #14532d; }
.normpts, .dbgrid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.dbgrid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dbcard { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dbcard b { font-size: 14px; }
.dbcard span { font-size: 12.5px; color: var(--ink2); }
.dbcard .csrc { margin-top: auto; padding-top: 4px; font-size: 12px; color: var(--muted); }
.dbcard a { color: #1d4ed8; }

/* インデックスのデモ */
.dctrl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.dctrl > button { font: inherit; font-size: 13px; font-weight: 700; border-radius: 999px; padding: 6px 16px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; }
.dctrl > button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.dctrl > button:disabled { opacity: .5; cursor: default; }
.ixdemo, .txdemo, .n1demo { padding: 14px 16px; }
.ixt { font-size: 13px; margin-bottom: 10px; }
.ixt b { font-family: var(--latin); font-size: 16px; }
.ixrow { display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.ixh { font-size: 13.5px; font-weight: 700; }
.ixh small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.ixbar { height: 18px; background: var(--line2); border-radius: 6px; overflow: hidden; }
.ixbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f59e0b, #ef4444); border-radius: 6px; }
.ixn { font-size: 12.5px; }
.ixn b { font-family: var(--latin); font-size: 18px; margin-right: 4px; }
.ixn small { display: block; color: var(--muted); font-size: 11px; }
.ixpath { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ixpath li { font-size: 12.5px; background: #dcfce7; color: #14532d; border-radius: 6px; padding: 3px 8px; font-family: var(--latin); }
.ixpath li span { font-family: var(--sans); font-weight: 700; font-size: 11.5px; margin-right: 8px; }
.ixnote { margin: 8px 0 0; font-size: 12.5px; color: var(--ink2); }
.ixmulti { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.ixmulti p { margin: 0; font-size: 13px; color: var(--ink2); }
.oklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.oklist li { border-radius: 6px; padding: 4px 8px; }
.oklist li.ok { background: #dcfce7; color: #14532d; }
.oklist li.ng { background: #fee2e2; color: #7f1d1d; }
.oklist code, .plan code { font-family: var(--latin); font-size: 12px; }
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.plan { border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.plan small { font-size: 11px; font-weight: 700; }
.plan.ng { background: #fee2e2; color: #7f1d1d; }
.plan.ok { background: #dcfce7; color: #14532d; }

/* トランザクションのデモ */
.seg { display: inline-flex; background: var(--line2); border-radius: 999px; padding: 3px; }
.seg button { appearance: none; border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--ink2); }
.seg button.on { background: var(--ink); color: #fff; }
.txbody { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.dbcode .ln { display: block; border-radius: 4px; padding: 0 4px; transition: background .2s; }
.dbcode .ln.cur { background: rgba(250, 204, 21, .3); }
.dbcode .ln.done { color: #86efac; }
.dbcode .ln.boom { color: #fca5a5; font-weight: 700; }
.dbcode .ln.rb { color: #fde68a; font-weight: 700; }
.txbal { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.acc { background: var(--line2); border-radius: 10px; padding: 8px 10px; transition: background .3s; min-width: 0; }
.acc small { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.acc b { font-family: var(--latin); font-size: 17px; }
.acc.bump { background: #fef9c3; }
.acc.total { background: #e0f2fe; }
.acc.total.lost { background: #fee2e2; color: #991b1b; }
.txmsg { margin: 8px 0 0; font-size: 13px; color: var(--ink2); border-radius: 8px; padding: 8px 10px; background: var(--line2); }
.txmsg.good { background: #dcfce7; color: #14532d; }
.txmsg.bad { background: #fee2e2; color: #7f1d1d; font-weight: 700; }
.acid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.acidc { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: start; }
.acidc .al { width: 34px; height: 34px; border-radius: 9px; background: var(--k-test); color: #fff; font-family: var(--latin); font-weight: 600; font-size: 18px; display: grid; place-items: center; }
.acidc b { display: block; font-size: 14px; }
.acidc b small { font-family: var(--latin); font-weight: 500; font-size: 11px; color: var(--muted); margin-left: 6px; }
.acidc span { font-size: 12.5px; color: var(--ink2); }
.dbnote2 { margin-top: 10px; padding: 11px 14px; display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--ink2); }
.dbnote2 b { flex: none; color: var(--ink); }

/* N+1 のデモ */
.n1cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.n1col { border-radius: 12px; padding: 10px 12px; min-width: 0; }
.n1col.bad { background: #fef2f2; border: 1px solid #fecaca; }
.n1col.good { background: #f0fdf4; border: 1px solid #bbf7d0; }
.n1h { font-size: 13px; font-weight: 700; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.n1h b { font-family: var(--latin); font-size: 22px; margin-left: auto; }
.n1col.bad .n1h b { color: #b91c1c; }
.n1col.good .n1h b { color: #15803d; }
.n1h small { font-size: 12px; }
.n1log { margin: 0; padding-left: 1.4em; display: grid; gap: 2px; font-family: var(--latin); font-size: 11.5px; color: var(--ink2); overflow-wrap: anywhere; }
.n1log li.more { list-style: none; margin-left: -1.4em; font-family: var(--sans); color: #b91c1c; font-weight: 700; }
.n1log li.sum { list-style: none; margin: 6px 0 0 -1.4em; font-family: var(--sans); font-weight: 700; border-radius: 6px; padding: 4px 8px; }
.n1log li.sum.bad { background: #fee2e2; color: #7f1d1d; }
.n1log li.sum.good { background: #dcfce7; color: #14532d; }
.n1code { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.n1c { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.n1c h3 { margin: 0; font-size: 15px; }
.n1c p { margin: 0; font-size: 12.5px; color: var(--ink2); }
.n1cc { display: grid; gap: 6px; }
.n1cc small { display: block; font-size: 11px; font-weight: 700; margin-bottom: 3px; }
.ngl { color: #b91c1c; }
.okl { color: #15803d; }

/* 使い分け・AI */
.dbcard.kind .kh { display: flex; flex-direction: column; gap: 1px; margin-bottom: 2px; }
.dbcard.kind .kh small { font-size: 11.5px; color: var(--muted); }
.dbcard em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--k-test); margin-right: 6px; }
.dbcard.ai { background: #faf5ff; border-color: #ddd6fe; }
.aitag { font-style: normal; font-family: var(--latin); font-size: 10.5px; font-weight: 600; background: #ede9fe; color: #5b21b6; border-radius: 5px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; }

/* チェックリスト */
.mlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mlist label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 4px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.mlist label:hover { background: var(--line2); }
.mlist input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--k-test); flex: none; }
.mlist input:checked + span { color: var(--muted); text-decoration: line-through; }
.ckfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.mcount { font-size: 12.5px; font-weight: 700; color: var(--k-test); }
.ckreset { appearance: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink2); cursor: pointer; }
.ckreset:hover { border-color: #94a3b8; }

/* 同時に書き込むとき・データベースで守る決まり */
.dgguard { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.dgcard { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dgcard h3 { margin: 0; font-size: 15px; }
.dgcard p { margin: 0; font-size: 13px; color: var(--ink2); }
.dgcard p a { color: #1d4ed8; }
.dgcode { margin: 0; font-family: var(--latin); font-size: 11.5px; line-height: 1.6; background: #0f172a; color: #e2e8f0; border-radius: 9px; padding: 8px 11px; overflow-x: auto; white-space: pre; }
.dgsrc { margin-top: auto !important; font-size: 12px !important; }
@media (max-width: 1100px) { .dgguard { grid-template-columns: 1fr; } }
@media (max-width: 1100px) {
  .acid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dbgrid3, .normpts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .dbtwo, .qlayout, .normgrid, .txbody, .n1code { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .dbgrid3, .normpts, .dbgrid2, .acid, .n1cols, .plans { grid-template-columns: 1fr; }
  .ixrow { grid-template-columns: 1fr; gap: 6px; }
  .txbal { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .acc b { font-size: 15px; }
  .dbnote2 { flex-direction: column; gap: 2px; }
}
