/* Doplňky nástěnky a učitelského prostředí. */
#studio-bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
#studio-bg-canvas[hidden], #studio-tools-widget[hidden], #studio-alarm-global[hidden],
.wall-alarm-off[hidden], #wall-compose-student-uploads-wrap[hidden] { display: none !important; }
#studio-tools-widget, #studio-alarm-global { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 490; }
#studio-tools-widget {
    width: 35px; height: 35px; border-radius: 50%; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.16) 0%, rgba(56, 189, 248, 0.04) 100%);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(56, 189, 248, 0.35); color: var(--st-blue);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
#studio-tools-widget .mi { width: 18px; height: 18px; }
#studio-tools-widget:hover {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.28) 0%, rgba(56, 189, 248, 0.08) 100%);
    border-color: rgba(56, 189, 248, 0.7); transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.35);
}
#studio-tools-widget.has-run::after {
    content: ''; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px;
    border-radius: 50%; background: var(--st-gold); box-shadow: 0 0 8px rgba(251, 191, 36, 0.85);
    animation: toolsRunPulse 1.6s ease-in-out infinite;
}
#studio-alarm-global { bottom: max(68px, calc(env(safe-area-inset-bottom) + 52px)); color: var(--st-gold); z-index: 100001; }
#wall-title { min-width: 90px; width: clamp(100px, 21vw, 340px); max-width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 4px 7px; background: transparent; color: inherit; font: inherit; text-overflow: ellipsis; }
#wall-title:not([readonly]):hover { border-color: var(--glass-border); }
#wall-title:focus { outline: 2px solid var(--st-blue); background: var(--bg-color); text-overflow: clip; }
#wall-title-detail { font-size: .75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
#modal-wall .wall-msg { container-type: size; }
.wall-msg .wall-quiz { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 4px; padding: 4px; box-sizing: border-box; }
.wall-msg .wall-quiz-share { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; flex: 1 1 auto; gap: 4px; width: 100%; }
.wall-msg .wall-quiz-qr { aspect-ratio: 1 / 1; flex: 1 1 auto; min-height: 0; width: auto; height: auto; max-height: min(220px, 62cqh); max-width: 94%; margin: 2px auto; display: flex; align-items: center; justify-content: center; }
.wall-msg .wall-quiz-qr svg { width: auto; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1; display: block; padding: 4px; box-sizing: border-box; background: #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.wall-card-code { flex-shrink: 0; width: auto; display: inline-flex; justify-content: center; align-items: center; color: var(--st-gold); margin-top: 2px; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(251, 191, 36, 0.35); }
.wall-card-code .sess-icons { display: flex; justify-content: center; align-items: center; gap: clamp(4px, 2cqw, 10px); }
.wall-card-code .mi { width: clamp(18px, 6cqw, 28px); height: clamp(18px, 6cqw, 28px); color: var(--st-gold); }
.wall-msg .wall-media-img { width: 100%; height: auto; max-height: 65%; object-fit: contain; border-radius: 6px; background: rgba(0, 0, 0, 0.25); flex: 1 1 auto; min-height: 0; display: block; margin: 0 auto; }
.wall-msg.has-text .wall-media-img { max-height: 42%; flex: 0 1 auto; }
.wall-msg:not(.has-text) .wall-media-img { flex: 1 1 auto; max-height: 75%; }
.wall-canvas-wrap.is-stacked .wall-msg .wall-quiz-qr { width: clamp(200px, 68vw, 320px); height: clamp(200px, 68vw, 320px); max-height: none; }
.wall-canvas-wrap.is-stacked .wall-msg .wall-media-img { max-height: 50vh; width: auto; max-width: 100%; }
.wall-msg .wall-embed { flex: 1 1 auto; min-height: 0; }
.wall-msg .wall-embed-time { font-size: clamp(25px, min(18cqw, 23cqh), 160px); line-height: 1.05; font-variant-numeric: tabular-nums; }
.wall-embed.is-done .wall-embed-time { color: var(--st-gold); }
#modal-tool-timer > .txt-picker-content { width: 96vw !important; max-width: 1140px !important; min-height: min(72dvh, 650px); container-type: inline-size; }
#modal-tool-timer .tools-big { font-size: clamp(48px, 16cqw, 180px); line-height: 1.15; font-variant-numeric: tabular-nums; }
@media (max-height: 560px) {
    #modal-tool-timer > .txt-picker-content { min-height: 0; }
    #modal-tool-timer .tools-body { padding: 2px 14px 6px; }
    #modal-tool-timer .tools-big { font-size: clamp(1.8rem, min(10vw, 15vh), 3.8rem); padding: 0; }
    #modal-tool-timer .tools-row { margin: 2px 0; }
    #modal-tool-timer #studio-timer-settings { margin: 2px 0; }
    #modal-tool-timer .icon-btn.icon-lg { width: 52px; height: 52px; }
    #modal-tool-timer .icon-btn.icon-lg .mi { width: 24px; height: 24px; }
}
#studio-timer-settings input, .studio-time-inputs input { width: 5em; padding: 7px; font: inherit; border: 1px solid var(--glass-border); border-radius: 6px; color: var(--text-main); background: var(--bg-color); }
.studio-time-inputs { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
#modal-tools.teacher-tools-drawer {
    justify-content: flex-end; align-items: flex-end;
    padding: max(16px, env(safe-area-inset-right));
    padding-bottom: max(68px, calc(env(safe-area-inset-bottom) + 68px));
    background: rgba(0,0,0,.28); backdrop-filter: none; -webkit-backdrop-filter: none;
}
#modal-tools.teacher-tools-drawer > .txt-picker-content {
    width: min(300px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
    height: auto !important;
    max-height: min(85dvh, calc(100dvh - 90px)) !important;
    margin: 0; border-radius: 16px; padding: 0;
    display: flex; flex-direction: column;
    box-shadow: 0 16px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(56, 189, 248, 0.35);
}
#modal-tools.teacher-tools-drawer .txt-picker-header {
    padding: 10px 14px; border-bottom: 1px solid var(--glass-border); flex-shrink: 0;
}
#modal-tools.teacher-tools-drawer .tools-grid {
    grid-template-columns: 1fr; gap: 6px; padding: 10px 12px 14px; overflow-y: auto;
}
#modal-tools.teacher-tools-drawer .tools-tile {
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
    gap: 12px; padding: 9px 12px; min-height: 44px; text-align: left;
    border-radius: 10px; width: 100%;
}
#modal-tools.teacher-tools-drawer .tools-tile .mi {
    width: 22px; height: 22px; flex-shrink: 0;
}
#modal-tools.teacher-tools-drawer .tools-tile span {
    font-size: 0.88rem; font-weight: 600; flex: 1;
}
#modal-tools.teacher-tools-drawer .tools-tile-status {
    position: static; margin-left: auto; font-size: 0.74rem;
}
.wall-draw-stage { position: relative; flex-shrink: 0; }
#wall-draw-textbox { position: absolute; z-index: 2; justify-content: flex-start; padding: 0; align-items: flex-start; flex-wrap: wrap; background: rgba(255,255,255,.96); border: 1px solid #2563eb; border-radius: 5px; box-sizing: border-box; }
#wall-draw-textbox[hidden] { display: none; }
#wall-draw-textbox input { min-width: 0; width: 100%; flex: 1 1 100%; padding: 1px 4px; border: 0; border-radius: 0; color: #0b1220; background: transparent; font-family: Rajdhani, "Segoe UI", sans-serif; font-weight: 700; line-height: 1.15; }
#wall-draw-textbox .icon-btn { width: 32px; height: 32px; flex-basis: 32px; color: #0b1220; }
#wall-draw-colors { max-width: 350px; gap: 5px; flex-wrap: wrap; }
#wall-draw-colors .wall-color { width: 26px; height: 26px; flex: 0 0 26px; }
#modal-wall-color > .txt-picker-content { width: min(94vw, 420px); }
.wall-color-mixer { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.wall-color-mixer label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wall-color-mixer input[type="range"] { width: 65%; }
#wall-color-hex { width: 9em; font: inherit; padding: 6px; }
#wall-color-preview { min-height: 56px; border: 1px solid var(--glass-border); border-radius: 8px; }
@media (max-width: 640px) { #wall-title { width: 120px; } #wall-title-detail { display: none; } }
@media (prefers-reduced-motion: reduce) { #modal-tools.teacher-tools-drawer > .txt-picker-content { animation: none; } }

/* Mobilní skládání karet má automatickou výšku, proto zde nepoužívat size containment. */
#modal-wall .wall-canvas-wrap.is-stacked .wall-msg { container-type: inline-size; }
#modal-wall .wall-canvas-wrap.is-stacked .wall-quiz-qr { width: min(80cqw, 320px); }
#modal-wall .wall-canvas-wrap.is-stacked .wall-embed-time { font-size: clamp(32px, 20cqw, 120px); }
.wall-thread-item .wall-cmt-del-btn,
.wall-chat-item .wall-cmt-del-btn {
    width: 17px !important; height: 17px !important; min-width: 17px !important;
    padding: 0 !important; border-radius: 4px; align-self: center; margin-left: auto;
    flex-shrink: 0; opacity: 0.7; transition: opacity 0.15s, background 0.15s;
}
.wall-thread-item .wall-cmt-del-btn:hover,
.wall-chat-item .wall-cmt-del-btn:hover {
    opacity: 1; background: rgba(248, 113, 113, 0.2);
}
.wall-thread-item .wall-cmt-del-btn .mi,
.wall-chat-item .wall-cmt-del-btn .mi {
    width: 11px !important; height: 11px !important;
}

#wall-title-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#modal-wall-compose > .txt-picker-content { resize: both; overflow: auto; max-width: min(94vw, 960px) !important; min-width: min(300px, 92vw); min-height: min(400px, 80dvh); }
#wall-quiz-prev { container-type: inline-size; flex-direction: column; position: relative; }
#wall-quiz-prev .wall-quiz-prev-main { order: 0; width: 100%; padding-right: 32px; }
#wall-quiz-prev-qr { order: 1; width: clamp(90px, 40cqw, 360px); max-width: 85%; }
#wall-quiz-prev-icons { order: 2; }
#wall-quiz-prev-icons .mi { width: clamp(22px, 7cqw, 64px); height: clamp(22px, 7cqw, 64px); }
#wall-quiz-prev-remove { position: absolute; top: 8px; right: 8px; }

@keyframes wallWidgetIn {
    from { transform: translateY(14px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes wallWidgetOut {
    from { transform: translateY(0) scale(1); opacity: 1; }
    to { transform: translateY(12px) scale(0.97); opacity: 0; }
}
#modal-tools.teacher-tools-drawer.active > .txt-picker-content { animation: wallWidgetIn .22s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
#modal-tools.teacher-tools-drawer.active > .txt-picker-content.modal-out { animation: wallWidgetOut .16s ease-in forwards; }
@media (prefers-reduced-motion: reduce) {
    #modal-tools.teacher-tools-drawer.active > .txt-picker-content,
    #modal-tools.teacher-tools-drawer.active > .txt-picker-content.modal-out { animation: none; }
}

/* Kvízová karta: obsah kvízu dostane volnou výšku, QR není jen pod textem. */
#modal-wall .wall-msg.has-quiz .wall-quiz,
#modal-wall .wall-msg.has-quiz .wall-quiz-share {
    flex: 1 1 0;
}
/* Automatická výška karty: size containment by jinak zabránil tomu,
   aby se výška počítala z obsahu (obrázek/text/chat). */
#modal-wall .wall-msg.is-auto-height {
    container-type: inline-size;
    height: auto !important;
    max-height: var(--wall-card-max-h, 600px);
}

#modal-wall .wall-msg.is-auto-height .wall-media-img {
    width: 100%;
    height: auto !important;
    max-height: none !important;
    flex: 0 0 auto !important;
}

#modal-wall .wall-msg.is-auto-height .wall-msg-main,
#modal-wall .wall-msg.is-auto-height .wall-chat,
#modal-wall .wall-msg.is-auto-height .wall-quiz,
#modal-wall .wall-msg.is-auto-height .wall-embed {
    flex: 0 0 auto !important;
}
