/* layout.css — top bar, tab rail, panels, console drawer. */
/* SPDX-License-Identifier: GPL-2.0-only */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent); }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px; border-bottom: 1px solid var(--edge); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.1rem; margin: 0 6px 0 0; font-weight: 700; letter-spacing: -.01em; }
.topbar h1 small { font-weight: 400; color: var(--ink-3); font-size: .8rem; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar nav a { margin-left: 14px; font-size: .9rem; color: var(--ink-2); }
.notice { margin: 0; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--edge); color: var(--ink-2); font-size: .9rem; }
.notice.warn { border-left: 4px solid var(--warn); }

.app { display: grid; grid-template-columns: 196px 1fr; flex: 1 0 auto; align-items: stretch; }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } }

/* ---- tab rail ---- */
.rail { background: var(--panel); border-right: 1px solid var(--edge); padding: 8px 0; position: sticky; top: 53px; align-self: start; max-height: calc(100vh - 53px); overflow-y: auto; }
.rail button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; border-left: 3px solid transparent; padding: 9px 14px 9px 13px; color: var(--ink-2); font: inherit; cursor: pointer; }
.rail button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.rail button[aria-selected="true"] { color: var(--ink); border-left-color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.rail button .n { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); width: 1.4em; }
.rail button .flag { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.rail button .flag.err { background: var(--err); } .rail button .flag.warn { background: var(--warn); } .rail button .flag.ok { background: var(--ok); }
.rail hr { border: none; border-top: 1px solid var(--edge); margin: 8px 0; }
.rail button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 860px) { .rail { position: static; max-height: none; display: flex; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--edge); } .rail button { width: auto; border-left: none; border-bottom: 3px solid transparent; } .rail button[aria-selected="true"] { border-bottom-color: var(--accent); } .rail hr { display: none; } }

/* ---- panels ---- */
.main { min-width: 0; display: flex; flex-direction: column; }
.panel { display: none; padding: 18px 22px 28px; max-width: 1100px; width: 100%; }
.panel.active { display: block; }
.panel > h2 { margin: 0 0 4px; font-size: 1.25rem; }
.panel > .lede { margin: 0 0 18px; color: var(--ink-2); max-width: 70ch; }
.card { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.card h3 .badge { margin-left: 8px; vertical-align: middle; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.screen { background: var(--screen); border: 1px solid var(--edge); border-radius: var(--radius); }
canvas.preview { width: 100%; display: block; }

/* ---- console drawer ---- */
.console { border-top: 1px solid var(--edge); background: var(--panel); display: flex; flex-direction: column; margin-top: auto; }
.console .bar { display: flex; align-items: center; gap: 8px; padding: 6px 16px; flex-wrap: wrap; }
.console .bar h2 { font-size: .9rem; margin: 0; font-weight: 700; flex: 1; }
.console .bar label { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-2); }
.console .bar select { padding: 3px 6px; font-size: .85rem; }
.console .handle { height: 8px; cursor: ns-resize; background: linear-gradient(var(--edge), var(--edge)) center / 48px 2px no-repeat; }
.log { font-family: var(--mono); font-size: .84rem; line-height: 1.5; background: var(--screen); margin: 0 16px; padding: 10px 12px; height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; color: var(--ink-2); border: 1px solid var(--edge); border-radius: var(--radius); }
.log .tx { color: var(--accent); } .log .err { color: var(--err); } .log .dim { color: var(--ink-3); } .log .reply { color: var(--ink); } .log .ok { color: var(--ok); }
.log .toggle { display: block; background: none; border: none; color: var(--accent); font: inherit; padding: 2px 0; cursor: pointer; }
.log-send { display: flex; gap: 8px; padding: 8px 16px 12px; }
.log-send input { flex: 1; }
.console.collapsed .log, .console.collapsed .log-send, .console.collapsed .handle { display: none; }

footer { padding: 10px 16px; border-top: 1px solid var(--edge); color: var(--ink-3); font-size: .85rem; }
footer a { color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
