/* ================= BẢNG PHẤN LỚP HỌC (CHALKBOARD STUDIO) ================= */
#cb-modal {
    position: fixed; inset: 0; z-index: 62; display: none;
    align-items: center; justify-content: center; padding: 10px;
    background: rgba(14, 22, 36, 0.72); backdrop-filter: blur(2px);
}
#cb-modal.open { display: flex; }

.cb-frame {
    position: relative; width: min(1040px, 98vw); max-height: 94dvh;
    display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 10px;
    border-radius: 12px;
    background: repeating-linear-gradient(90deg, #7c512a 0 18px, #6e4522 18px 20px, #855830 20px 36px);
    border: 3px solid #4d2e14;
    box-shadow: 0 14px 36px rgba(0,0,0,0.62), inset 0 0 14px rgba(0,0,0,0.4);
    font-family: Tahoma, 'Segoe UI', sans-serif;
}

.cb-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cb-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#cb-title {
    margin: 0; font: 700 18px Tahoma, sans-serif; color: #fff8e1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.cb-sync-pill {
    padding: 3px 9px; border-radius: 12px; font: 700 11.5px Tahoma, sans-serif;
    background: rgba(255, 248, 225, 0.9); color: #4e342e; border: 1px solid #a1784a;
}
.cb-sync-pill.cloud { background: #e8f5e9; color: #1b5e20; border-color: #2e7d32; }
.cb-close {
    width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff;
    background: #c62828; color: #fff; font: 700 16px Tahoma, sans-serif; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.cb-close:hover { background: #e53935; }

.cb-tools {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    padding: 7px 10px; border-radius: 8px;
    background: rgba(44, 27, 13, 0.62); border: 1px solid rgba(255, 224, 178, 0.25);
}
.cb-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.cb-btn {
    padding: 5px 9px; border-radius: 7px; border: 1.5px solid rgba(255, 236, 179, 0.35);
    background: rgba(255, 248, 225, 0.14); color: #fff8e7;
    font: 700 12px Tahoma, sans-serif; cursor: pointer; transition: background .12s, transform .08s;
}
.cb-btn:hover { background: rgba(255, 248, 225, 0.26); }
.cb-btn.active {
    background: #ffe082; border-color: #fff8e1; color: #2b1d0e;
    box-shadow: 0 0 0 2px rgba(255, 224, 130, 0.38);
}
.cb-btn.cb-danger { background: rgba(198, 40, 40, 0.72); border-color: #ef9a9a; }
.cb-btn.cb-danger:hover { background: #d32f2f; }
.cb-actions { margin-left: auto; }

.cb-colors { gap: 6px; padding: 0 4px; }
.cb-swatch {
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.55);
    cursor: pointer; transition: transform .1s, box-shadow .12s;
}
.cb-swatch:hover { transform: scale(1.12); }
.cb-swatch.active {
    border-color: #fff; transform: scale(1.16);
    box-shadow: 0 0 0 2.5px #1a237e, 0 0 0 4px #ffe082;
}

.cb-symbols {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 5px 9px; border-radius: 7px;
    background: rgba(24, 52, 46, 0.85); border: 1px solid rgba(186, 201, 175, 0.4);
    color: #e0efe6; font: 700 12px Tahoma, sans-serif;
}
.cb-symbols[hidden] { display: none; }
.cb-symbols button {
    min-width: 28px; height: 26px; padding: 0 6px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.12);
    color: #fff8e1; font: 700 14px Tahoma, sans-serif; cursor: pointer;
}
.cb-symbols button:hover { background: #ffe082; color: #1b2e28; }

.cb-board-wrap {
    position: relative; width: 100%; aspect-ratio: 960 / 360; max-height: 58dvh;
    border-radius: 5px; overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 42%, rgba(255,255,255,0.08), transparent 68%),
        radial-gradient(circle at 18% 72%, rgba(255,255,255,0.03), transparent 40%),
        #224a42;
    border: 4px solid #3f2713;
    box-shadow: inset 0 0 24px rgba(0,0,0,0.55);
    touch-action: none; user-select: none;
}
.cb-board-wrap.tool-chalk { cursor: crosshair; }
.cb-board-wrap.tool-text { cursor: text; }
.cb-board-wrap.tool-eraser { cursor: cell; }
.cb-board-wrap canvas {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
#cb-preview { pointer-events: none; }

/* Ô gõ chữ nổi ngay tại vị trí click trên bảng */
#cb-text-placer {
    position: absolute; z-index: 6; display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 5px; border-radius: 6px;
    background: rgba(18, 42, 37, 0.88); border: 1.5px dashed #ffe082;
    box-shadow: 0 4px 12px rgba(0,0,0,0.45);
    transform: translate(0, -50%);
}
#cb-text-placer[hidden] { display: none; }
#cb-text-input {
    width: clamp(140px, 28vw, 320px); border: 0; outline: 0; background: transparent;
    color: #f7f6eb; font: 700 18px 'Patrick Hand', 'Comic Sans MS', Tahoma, sans-serif;
    -webkit-user-select: text; user-select: text;
}
#cb-text-input::placeholder { color: rgba(255,248,225,0.52); font-size: 13px; }
#cb-text-ok, #cb-text-cancel {
    width: 25px; height: 25px; border-radius: 5px; border: 0; cursor: pointer;
    font: 700 13px Tahoma, sans-serif;
}
#cb-text-ok { background: #2e7d32; color: #fff; }
#cb-text-cancel { background: #757575; color: #fff; }

/* Khay phấn gỗ đáy bảng */
.cb-ledge {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 5px 10px; border-radius: 6px;
    background: linear-gradient(180deg, #9c6b3d, #704721);
    border-top: 2px solid #bd8b56; color: #fff5d9; font: 600 12px/1.35 Tahoma, sans-serif;
}
.cb-chalk-sticks { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }
.cb-chalk-sticks i { display: inline-block; width: 24px; height: 6px; border-radius: 2px; background: #f5f3e6; box-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.cb-chalk-sticks i:nth-child(2) { background: #ffe082; width: 18px; }
.cb-chalk-sticks i:nth-child(3) { background: #f8bbd0; width: 15px; }

@media (max-width: 680px) {
    .cb-frame { padding: 9px; gap: 6px; }
    .cb-btn { padding: 4px 7px; font-size: 11.5px; }
    .cb-actions { margin-left: 0; }
    #cb-title { font-size: 15.5px; }
}
