:root {
  --bg: #0e1117; --panel: #161b22; --border: #2d333b; --fg: #e6edf3;
  --muted: #8b949e; --accent: #7c5cff; --accent2: #2dd4bf; --warn: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
header { padding: 24px 20px 8px; max-width: 1100px; margin: 0 auto; }
h1 { margin: 0; font-size: 1.7rem; }
h1 .sub { font-size: .9rem; color: var(--muted); font-weight: 400; margin-left: 8px; }
.tagline { color: var(--muted); max-width: 760px; }
code { background: #21262d; padding: 1px 5px; border-radius: 4px; font-size: .85em; color: var(--accent2); }
main { max-width: 1100px; margin: 0 auto; padding: 8px 20px 60px;
       display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.controls { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 14px; align-items: end; }
.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl label { font-size: .8rem; color: var(--muted); }
.ctl small { color: var(--muted); font-size: .72rem; min-height: 1em; }
select, input[type=range] { width: 100%; }
select { background: #0d1117; color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 7px; }
button#train-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 18px; font-size: 1rem; cursor: pointer; font-weight: 600; white-space: nowrap;
}
button#train-btn:disabled { opacity: .5; cursor: not-allowed; }
.status { grid-column: 1 / -1; font-size: .85rem; color: var(--accent2); min-height: 1.2em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
canvas#curve { width: 100%; height: auto; background: #0d1117; border-radius: 8px; }
.legend { margin-top: 8px; font-size: .76rem; display: flex; gap: 16px; }
.lg::before { content: "■ "; }
.lg-raw { color: #6e7681; } .lg-avg { color: var(--accent2); } .lg-eps { color: var(--warn); }
.viz-panel { grid-column: 1 / -1; }
.hint { color: var(--muted); }
/* GridWorld 可視化 */
.gw { display: inline-grid; gap: 3px; margin-top: 6px; }
.gw-cell { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
           border-radius: 6px; font-size: 1.4rem; position: relative; }
.gw-wall { background: #30363d; } .gw-goal { background: var(--accent2); color: #04201b; font-weight: 700; }
.gw-cell .v { position: absolute; bottom: 2px; right: 4px; font-size: .58rem; color: rgba(255,255,255,.6); }
.viz-meta { color: var(--muted); font-size: .82rem; margin: 4px 0 10px; }
/* CartPole action map */
.amap { display: inline-grid; gap: 1px; margin-top: 6px; }
.amap-cell { width: 16px; height: 16px; border-radius: 2px; }
.axis-note { color: var(--muted); font-size: .76rem; margin-top: 6px; }
.learn { grid-column: 1 / -1; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; font-size: .86rem; }
.learn-grid div { background: #0d1117; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
footer { max-width: 1100px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: .8rem; }
footer a { color: var(--accent2); }
/* chat */
#chat-fab { position: fixed; bottom: 24px; right: 24px; width: 54px; height: 54px; border-radius: 50%;
            background: var(--accent); color: #fff; border: 0; font-size: 1.5rem; cursor: pointer; z-index: 50; }
#chat-panel { position: fixed; bottom: 88px; right: 24px; width: 340px; max-height: 460px; background: var(--panel);
              border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; z-index: 50; }
#chat-panel.hidden { display: none; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; }
.chat-head button { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
#chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; font-size: .86rem; }
#chat-log .u { color: var(--accent2); } #chat-log .a { color: var(--fg); margin-bottom: 10px; }
.chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; background: #0d1117; color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 7px; }
.chat-input button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 0 12px; cursor: pointer; }
@media (max-width: 760px) { main { grid-template-columns: 1fr; } .controls { grid-template-columns: 1fr; } }
