/* Kitty Dev shell — calm walnut/chess palette, same family as kittyempiregames.com. */
:root {
  --bg: #1f1a17;
  --panel: #2a231f;
  --panel-2: #342b25;
  --line: #4a3d33;
  --text: #f3e9dc;
  --muted: #b9a894;
  --accent: #e0b65a;
  --accent-ink: #2a1d0b;
  --mine: #3b4f3a;
  --mentor: #3a3247;
  --danger: #e07a5f;
  --font: "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* id rules below set display; hidden must still win */
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 6px 12px; cursor: pointer; font-weight: bold;
}
button:hover { filter: brightness(1.08); }
button.quiet { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: normal; }
button.icon { background: transparent; color: var(--text); font-size: 1.3em; padding: 4px 8px; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

#bar {
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#bar .brand { font-weight: bold; font-size: 1.15em; margin-right: 6px; }
#bar .spacer { flex: 1; }
#bar select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-width: 220px; }
#who { color: var(--muted); }
.pill { font-size: .85em; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: var(--panel-2); }
.pill.live { color: #9be29b; }

#layout { display: grid; grid-template-columns: 360px 1fr 400px; height: calc(100% - 52px); }
body.no-chat #layout { grid-template-columns: 0 1fr 400px; }
body.no-dock #layout { grid-template-columns: 360px 1fr 0; }
body.no-chat.no-dock #layout { grid-template-columns: 0 1fr 0; }
body.no-chat #chat, body.no-dock #dock { display: none; }

/* Chat */
#chat { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: 12px; line-height: 1.4; max-width: 95%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--mine); white-space: pre-wrap; }
.msg.mentor { align-self: flex-start; background: var(--mentor); }
.msg.mentor p { margin: .3em 0; }
.msg.mentor pre { background: #00000040; padding: 8px; border-radius: 8px; overflow-x: auto; }
.msg.mentor code { font-family: var(--mono); font-size: .9em; }
details.steps { align-self: flex-start; color: var(--muted); font-size: .85em; }
details.steps summary { cursor: pointer; }
details.steps div { margin: 4px 0 0 12px; }
#chat-thinking { padding: 6px 14px; color: var(--muted); }
.dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
#chat-form { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
#chat-input { resize: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; max-height: 40vh; }
.chat-actions { display: flex; justify-content: space-between; }

/* Stage */
#stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#frame-wrap { flex: 1; position: relative; background: #000; min-height: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
#empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 1.2em; }
#console { background: var(--panel); border-top: 1px solid var(--line); max-height: 30vh; display: flex; flex-direction: column; }
#console summary { padding: 6px 12px; cursor: pointer; color: var(--muted); }
#console-count.has-errors { color: var(--danger); font-weight: bold; }
#console-out { margin: 0; padding: 6px 12px 10px; overflow: auto; font-family: var(--mono); font-size: .82em; white-space: pre-wrap; }
#console-out .error { color: var(--danger); }
#console-out .warn { color: var(--accent); }

/* Dock */
#dock { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
#dock-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
#dock-tabs button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: normal; padding: 5px 9px; }
#dock-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: bold; }
#dock-tabs button.mine { border-style: dashed; }
#dock-frames { flex: 1; position: relative; min-height: 0; }
#dock-frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--panel); }

/* Login + dialogs */
#login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 10; }
#login form, #new-form { display: flex; flex-direction: column; gap: 10px; width: min(340px, 90vw); }
#login input, #new-form input[type=text], #new-title { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
#login-error { color: var(--danger); min-height: 1.2em; margin: 0; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
dialog::backdrop { background: #0008; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; grid-template-rows: 1fr 40vh; }
  #chat, #dock { display: none; }
}
details.steps.live summary { color: var(--accent); }
