/* ==========================================================================
   Mind Map Studio — full-screen canvas app (shares panel/toolbar chrome with
   the Mind Palace stylesheet, which loads alongside this file)

   All colours read the site theme variables so every site theme restyles
   the studio; branch colours on the canvas stay per-branch.
   ========================================================================== */

/* The hidden attribute must always win, even over display rules */
[hidden] { display: none !important; }


#mindmap-canvas {
    position: fixed;
    inset: 0;
    display: block;
    cursor: grab;
}
#mindmap-canvas.panning { cursor: grabbing; }
#mindmap-canvas.over-room { cursor: pointer; }

/* Status message is adopted into the shared status bar by tool-chrome.js */

.mm-editor {
    position: fixed;
    z-index: 40;
    width: 260px;
}
.mm-editor input {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    color: var(--text);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
}
.mm-editor input:focus { outline: none; }

#mp-toolbar button {
    font-size: 1rem;
    /* Render icons through the emoji font first so every glyph gets its
       colour form on Windows instead of a thin serif fallback. */
    font-family: 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', Georgia, serif;
    line-height: 1.35;
}
#mp-toolbar .mm-ai-btn {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 0.02em;
    font-family: Georgia, serif;
}

/* Floating ✨ grow button on the selected node */
.mm-node-ai {
    position: fixed;
    z-index: 25;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: var(--bg-card);
    color: var(--accent);
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.12s ease, background 0.15s ease;
    padding: 0;
}
.mm-node-ai:hover { transform: scale(1.12); background: var(--accent-soft); }

/* ------------------------------ AI panel ------------------------------ */

#mm-ai-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    bottom: 48px;
    z-index: 30;
    width: min(340px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.8rem;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    animation: mm-ai-in 0.22s ease;
    overflow-y: auto;
}
@keyframes mm-ai-in {
    from { opacity: 0; transform: translateX(14px); }
    to   { opacity: 1; transform: none; }
}
.mm-ai-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-family: Georgia, serif;
}
.mm-ai-head strong { flex: 1; font-size: 1rem; }
.mm-ai-head button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.mm-ai-head button:hover { color: var(--accent); border-color: var(--accent); }

.mm-ai-section { display: flex; flex-direction: column; gap: 0.45rem; }
.mm-ai-section > label { color: var(--text-dim); font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; }
#mm-ai-input {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-family: Georgia, serif;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 70px;
}
#mm-ai-input:focus { outline: none; border-color: var(--accent); }
.mm-ai-primary {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    font-family: Georgia, serif;
    font-size: 0.92rem;
    font-weight: bold;
    cursor: pointer;
    transition: filter 0.2s ease;
}
.mm-ai-primary:hover { filter: brightness(1.25); }
.mm-ai-primary:disabled { opacity: 0.5; cursor: wait; }

.mm-ai-chat-section { flex: 1; min-height: 130px; }
#mm-ai-log {
    flex: 1;
    min-height: 70px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-right: 0.2rem;
}
.mm-ai-msg {
    max-width: 92%;
    padding: 0.45rem 0.65rem;
    border-radius: 10px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text);
}
.mm-ai-msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent); }
.mm-ai-msg.ai { align-self: flex-start; background: var(--bg-raised); border: 1px solid var(--border); }
.mm-ai-msg.busy { color: var(--text-dim); font-style: italic; letter-spacing: 2px; }
.mm-ai-msg.error { border-color: #ffb454; color: #ffb454; }
#mm-ai-form { display: flex; gap: 0.4rem; }
#mm-ai-form input {
    flex: 1;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 18px;
    padding: 0.45rem 0.8rem;
    font-family: Georgia, serif;
    font-size: 0.88rem;
    min-width: 0;
}
#mm-ai-form input:focus { outline: none; border-color: var(--accent); }
#mm-ai-form button {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 0.9rem;
}
#mm-ai-form button:disabled { opacity: 0.5; cursor: wait; }

/* Inline Gemini key bar */
#mm-ai-key .gemini-key-bar { display: flex; flex-direction: column; gap: 0.4rem; }
#mm-ai-key .key-bar-status { font-size: 0.82rem; }
#mm-ai-key .key-bar-status.ok { color: #7ddf8a; }
#mm-ai-key .key-bar-status.warn { color: #ffb454; }
#mm-ai-key .key-bar-form { display: flex; gap: 0.35rem; }
#mm-ai-key .key-bar-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}
#mm-ai-key .key-bar-input:focus { outline: none; border-color: var(--accent); }
#mm-ai-key .key-bar-reveal {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-dim);
}
#mm-ai-key .key-bar-model {
    max-width: 110px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 6px;
    font-size: 0.78rem;
}
#mm-ai-key .key-bar-hint { font-size: 0.72rem; color: var(--text-dim); line-height: 1.45; margin: 0; }
#mm-ai-key .key-bar-hint a { color: var(--accent); }
#mm-ai-key .key-bar-attention { animation: mm-key-flash 0.4s ease 2; }
@keyframes mm-key-flash { 50% { transform: translateX(4px); } }

/* Corkboard pairs a bright gold accent with a mid-brown page — accent-filled
   controls need dark ink there (same convention as site.css). */
:root[data-theme="corkboard"] #mm-ai-form button { color: #1a1206; }

@media (prefers-reduced-motion: reduce) {
    #mm-ai-panel, #mm-ai-key .key-bar-attention { animation: none; }
}
