/* Floating input bar — shared by chat room pages.
   Loaded AFTER base.css / theme-room.css; page-local CSS loads last and wins. */

.float-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 90%; max-width: 720px; padding: 12px clamp(1.5rem, 5vw, 3rem) 20px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-top: 1px solid var(--glass-b); z-index: 100; display: flex; align-items: flex-end; gap: 10px; border-radius: 14px 14px 0 0; }
.float-remaining { font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-2); white-space: nowrap; padding-bottom: 10px; }
.float-input { flex: 1; padding: 12px 16px; background: var(--glass); border: 1px solid var(--glass-b); border-radius: 10px; color: var(--text); font-family: var(--font-body); font-size: 0.85rem; outline: none; transition: border-color 0.3s; resize: none; overflow-y: hidden; max-height: 150px; line-height: 1.5; min-height: 42px; }
.float-input:focus { border-color: var(--accent); }
.float-input::placeholder { color: var(--text-3); }
.float-send { width: 42px; height: 42px; border-radius: 10px; background: var(--accent); border: none; color: var(--bg); font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s; flex-shrink: 0; }
.float-send:hover { opacity: 0.85; }
.float-send:disabled { opacity: 0.45; cursor: wait; }
.float-clear { background: none; border: 1px solid var(--glass-b); border-radius: 8px; color: var(--text-3); font-family: var(--font-mono); font-size: 0.6rem; line-height: 1; padding: 6px 10px; cursor: pointer; white-space: nowrap; transition: all 0.3s; flex-shrink: 0; letter-spacing: 0.02rem; display: inline-flex; align-items: center; justify-content: center; }
.float-clear:hover { border-color: var(--accent); color: var(--accent); }
.float-clear-toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--glass-bh); color: var(--text-2); font-family: var(--font-mono); font-size: 0.72rem; padding: 10px 20px; border-radius: 8px; z-index: 200; opacity: 0; transition: opacity 0.3s; pointer-events: none; }

/* ===== New-topic control (icon + explainer panel) =====
   Hidden until the user has accumulated enough follow-ups to have memory worth
   resetting; the room scripts add .show. Replaces the old 清空记忆 text button. */
.newtopic { position: relative; display: none; flex-shrink: 0; }
.newtopic.show { display: block; }

.newtopic-btn {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--glass-b); border-radius: 9px;
    color: var(--text-3); cursor: pointer; padding: 0;
    transition: border-color 0.25s, color 0.25s;
}
.newtopic-btn:hover, .newtopic.open .newtopic-btn { border-color: var(--accent); color: var(--accent); }
.newtopic-btn svg { width: 17px; height: 17px; display: block; }

/* Panel sits above the bar (or below it in toolbars via .newtopic-down),
   so the input and send button are never covered. */
.newtopic-panel {
    position: absolute; bottom: calc(100% + 2rem); left: 0;
    width: min(19rem, calc(100vw - 2.5rem));
    padding: 0.95rem 1.05rem 0.85rem;
    background: var(--bg-3); border: 1px solid var(--glass-bh); border-radius: 10px;
    box-shadow: 0 14px 38px rgba(0,0,0,0.34);
    opacity: 0; visibility: hidden; transform: translateY(5px);
    transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), visibility 0.22s;
    z-index: 240;
}
.newtopic.open .newtopic-panel { opacity: 1; visibility: visible; transform: translateY(0); }

/* Toolbar variant is right-aligned, so anchor the panel to the right edge
   or it overflows the viewport. */
.newtopic-down .newtopic-panel { bottom: auto; top: calc(100% + 10px); left: auto; right: 0; transform: translateY(-5px); }
.newtopic-down.newtopic.open .newtopic-panel { transform: translateY(0); }

.newtopic-title { font-family: var(--font-head); font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 0.45rem; }
.newtopic-desc { font-size: 0.72rem; line-height: 1.75; color: var(--text-2); margin-bottom: 0.85rem; }
.newtopic-acts { display: flex; justify-content: flex-end; gap: 0.5rem; }
.newtopic-cancel, .newtopic-go {
    font-family: var(--font-mono); font-size: 0.65rem; line-height: 1;
    padding: 7px 13px; border-radius: 7px; cursor: pointer; white-space: nowrap;
    transition: all 0.25s;
}
.newtopic-cancel { background: none; border: 1px solid var(--glass-b); color: var(--text-3); }
.newtopic-cancel:hover { border-color: var(--glass-bh); color: var(--text-2); }
.newtopic-go { background: var(--accent); border: 1px solid var(--accent); color: var(--bg); font-weight: 700; }
.newtopic-go:hover { opacity: 0.88; }
.float-stop { background: none; border: 1px solid rgba(255,100,100,0.3); border-radius: 8px; color: rgba(255,100,100,0.7); font-family: var(--font-mono); font-size: 0.6rem; padding: 6px 10px; cursor: pointer; white-space: nowrap; transition: all 0.3s; flex-shrink: 0; }
.float-stop:hover { border-color: rgba(255,100,100,0.6); color: rgba(255,100,100,1); }

/* New-key button (prominent) */
.float-newkey { background: none; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); font-family: var(--font-mono); font-size: 0.65rem; line-height: 1; padding: 6px 14px; cursor: pointer; white-space: nowrap; transition: all 0.3s; flex-shrink: 0; letter-spacing: 0.03rem; display: inline-flex; align-items: center; justify-content: center; }
.float-newkey:hover { background: var(--accent); color: var(--bg); }
.float-newkey.float-newkey-primary { background: var(--success); border-color: var(--success); color: #0b0a0a !important; font-size: 0.6rem; font-weight: 700; padding: 6px 10px; letter-spacing: 0.02rem; }
.float-newkey.float-newkey-primary:hover { opacity: 0.85; color: #0b0a0a !important; }
html[data-theme="dark"] .float-newkey.float-newkey-primary,
html[data-theme="dark"] .float-newkey.float-newkey-primary:hover {
    color: #0b0a0a !important;
}
html[data-theme="light"] .float-newkey.float-newkey-primary,
html[data-theme="light"] .float-newkey.float-newkey-primary:hover {
    color: #fff !important;
}

/* Extend state (add-key input) */
.float-extend-msg { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-3); text-align: center; margin-bottom: 0.3rem; }
.float-extend-input { flex: 1; padding: 12px 16px; background: var(--glass); border: 1px solid var(--glass-b); border-radius: 10px; color: var(--text); font-family: var(--font-mono); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.15rem; text-align: center; outline: none; transition: border-color 0.3s; }
.float-extend-input:focus { border-color: var(--accent); }
.float-extend-input::placeholder { color: var(--text-3); text-transform: none; letter-spacing: 0; }
.float-extend-btn { padding: 12px 20px; border-radius: 10px; background: var(--success); border: none; color: var(--bg); font-family: var(--font-head); font-size: 0.75rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: opacity 0.3s; }
.float-extend-btn:hover { opacity: 0.85; }

@media (max-width: 768px) {
    .float-bar { width: 100%; padding: 10px 12px 16px; border-radius: 0; gap: 8px; }
    .float-remaining { position: absolute; top: -18px; right: 12px; font-size: 0.58rem; opacity: 0.6; padding-bottom: 0; }
    .float-input { padding: 10px 12px; font-size: 0.82rem; min-height: 38px; }
    .float-send { width: 38px; height: 38px; }
    .float-clear { font-size: 0.55rem; padding: 6px 8px; }
    .newtopic-btn { width: 32px; height: 32px; }
    .newtopic-panel { width: min(17.5rem, calc(100vw - 1.5rem)); }
    .float-newkey { font-size: 0.58rem; padding: 5px 10px; }
    .float-newkey.float-newkey-primary { font-size: 0.55rem; padding: 6px 8px; }
}

/* iOS keyboard fix */
@supports (-webkit-touch-callout: none) {
    .float-bar { position: fixed; }
}
