/* ========== TEACHER MESSAGES PAGE ========== */
/* Prefixed .tm-*  — matches the home/editorial design system
   (Instrument Serif headlines, #2f6844 green, #faf8f3 warm off-white,
   #ece7dd warm tan borders, 14–16px radii, subtle warm shadows). */

/* Messages uses the full main-content area with its own 3-column layout
   (conversations | thread | shared-content side panel). */
.main-content.tm-mode {
    align-items: stretch;
    padding: 0;
    background: #faf8f3;
}
.main-content.tm-mode .cal-container {
    width: 100%;
    max-width: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    padding: 0;
}

.tm-shell {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: #faf8f3;
    color: #111;
    font-family: inherit;
}

/* Shared serif treatment — same pattern as teacher-home */
.tm-shell em,
.tm-shell .tm-italic {
    font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* ============================================================
   LEFT COLUMN  —  conversation list
   ============================================================ */
.tm-side {
    width: 340px;
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ece7dd;
    background: #faf8f3;
    min-height: 0;
}

.tm-side-head {
    padding: 24px 24px 16px;
}
.tm-side-over {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
    color: #8a7f6a;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.tm-side-title {
    font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    font-weight: 400;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: #111;
    margin: 0 0 16px;
}
.tm-side-title em { color: #2f6844; }

.tm-search {
    position: relative;
    margin-bottom: 12px;
}
.tm-search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    font-family: inherit;
    font-size: 13px;
    color: #111;
    background: #fff;
    border: 1px solid #ece7dd;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.tm-search input:focus {
    border-color: #2f6844;
    box-shadow: 0 0 0 3px rgba(47, 104, 68, 0.1);
}
.tm-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #8a7f6a;
    pointer-events: none;
    width: 14px;
    height: 14px;
}

.tm-newbtn {
    width: 100%;
    padding: 10px 14px;
    background: #2f6844;
    color: #fff;
    border: 1px solid #2f6844;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s;
}
.tm-newbtn:hover { background: #264f35; }
.tm-newbtn svg { width: 14px; height: 14px; }

.tm-side-filters {
    display: flex;
    gap: 6px;
    padding: 0 20px 10px;
    flex-wrap: wrap;
}
.tm-filter {
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 600;
    color: #6b7280;
    background: #fff;
    border: 1px solid #ece7dd;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
    letter-spacing: 0.2px;
}
.tm-filter:hover { border-color: #c1b9a6; color: #2f6844; }
.tm-filter.active {
    background: #2f6844;
    color: #fff;
    border-color: #2f6844;
}

.tm-convo-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 12px 20px;
}
.tm-convo-list-empty {
    padding: 30px 20px;
    text-align: center;
    font-size: 13px;
    color: #8a7f6a;
}

.tm-convo {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
    position: relative;
}
.tm-convo:hover { background: rgba(47, 104, 68, 0.05); }
.tm-convo.active {
    background: #e8f2ec;
}
.tm-convo.unread .tm-convo-name {
    font-weight: 700;
    color: #111;
}
.tm-convo.unread .tm-convo-preview { color: #111; }

.tm-avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2f6844;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    overflow: hidden;
    position: relative;
}
.tm-avatar.student { background: #2f6844; }
.tm-avatar.teacher { background: #6366f1; }
.tm-avatar.class { background: #b45309; }
.tm-avatar.group { background: #0f766e; }

.tm-avatar.stack {
    background: transparent;
    position: relative;
}
.tm-avatar.stack .tm-avatar-sub {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border: 2px solid #faf8f3;
}
.tm-avatar.stack .tm-avatar-sub:nth-child(1) { top: 0; left: 0; }
.tm-avatar.stack .tm-avatar-sub:nth-child(2) { bottom: 0; right: 0; }

.tm-convo-main {
    flex: 1;
    min-width: 0;
}
.tm-convo-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}
.tm-convo-name {
    font-size: 13.5px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.tm-convo-time {
    flex: 0 0 auto;
    font-size: 11px;
    color: #9ca3af;
}
.tm-convo-preview {
    font-size: 12.5px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.tm-convo-sender {
    color: #4b5563;
    font-weight: 500;
}
.tm-convo-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #2f6844;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tm-convo-kind-tag {
    font-size: 10px;
    letter-spacing: 0.4px;
    color: #8a7f6a;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: 6px;
}

/* ============================================================
   CENTER COLUMN  —  active thread
   ============================================================ */
.tm-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #fff;
}

.tm-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #8a7f6a;
    text-align: center;
}
.tm-empty-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    color: #c1b9a6;
}
.tm-empty-title {
    font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    font-weight: 400;
    font-size: 26px;
    color: #111;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.tm-empty-title em { color: #2f6844; }
.tm-empty-sub {
    font-size: 13px;
    color: #6b7280;
    max-width: 340px;
    line-height: 1.5;
}

.tm-thread-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid #ece7dd;
    background: #fff;
    flex: 0 0 auto;
}
.tm-thread-head-main {
    flex: 1;
    min-width: 0;
}
.tm-thread-title {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-thread-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tm-thread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}
.tm-thread-actions {
    display: flex;
    gap: 4px;
}
.tm-iconbtn {
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.12s;
}
.tm-iconbtn:hover {
    color: #2f6844;
    background: #f4f1e8;
}
.tm-iconbtn.active {
    color: #2f6844;
    background: #e8f2ec;
    border-color: #b7d6c2;
}
.tm-iconbtn svg { width: 16px; height: 16px; }

.tm-thread-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tm-daylabel {
    align-self: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: #f4f1e8;
    font-size: 11px;
    font-weight: 600;
    color: #8a7f6a;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin: 8px 0;
}

.tm-msg {
    display: flex;
    gap: 10px;
    max-width: 78%;
}
.tm-msg.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.tm-msg-avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2f6844;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}
.tm-msg.me .tm-msg-avatar { display: none; }
.tm-msg-body { min-width: 0; }
.tm-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 11.5px;
    color: #6b7280;
}
.tm-msg.me .tm-msg-meta { justify-content: flex-end; }
.tm-msg-sender {
    font-size: 12.5px;
    font-weight: 600;
    color: #2f6844;
}
.tm-msg.me .tm-msg-sender { display: none; }
.tm-msg-time { font-size: 11px; color: #9ca3af; }

.tm-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #111;
    background: #f4f1e8;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.tm-msg.me .tm-bubble {
    background: #2f6844;
    color: #fff;
}
.tm-msg.me .tm-bubble a { color: #d4e6dd; text-decoration: underline; }

.tm-bubble a {
    color: #2f6844;
    text-decoration: underline;
}

.tm-msg-receipts {
    font-size: 10.5px;
    color: #9ca3af;
    margin-top: 3px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.tm-msg.me .tm-msg-receipts { justify-content: flex-end; }
.tm-msg-receipts.read { color: #2f6844; }
.tm-msg-receipts svg { width: 12px; height: 12px; }

/* System messages (share receipts, joined, left) — centered pill */
.tm-msg-system {
    align-self: center;
    max-width: 80%;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #ece7dd;
    border-radius: 999px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}
.tm-msg-system strong { color: #2f6844; font-weight: 600; }

/* Announcement — full-width banner bubble */
.tm-msg-announcement {
    align-self: stretch;
    max-width: 100%;
    background: #fff8e6;
    border: 1px solid #f0d58c;
    border-left: 4px solid #b45309;
    border-radius: 12px;
    padding: 14px 18px;
    color: #92400e;
}
.tm-msg-announcement .tm-ann-over {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #b45309;
    margin-bottom: 6px;
}
.tm-msg-announcement .tm-ann-title {
    font-weight: 700;
    color: #78350f;
    font-size: 14.5px;
    margin-bottom: 4px;
}
.tm-msg-announcement .tm-ann-body {
    font-size: 13.5px;
    line-height: 1.5;
    color: #78350f;
    white-space: pre-wrap;
}

/* Typing indicator */
.tm-typing {
    display: flex;
    gap: 10px;
    align-self: flex-start;
    max-width: 78%;
    align-items: center;
}
.tm-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #f4f1e8;
    border-radius: 14px;
}
.tm-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8a7f6a;
    animation: tmTyping 1.2s infinite ease-in-out;
}
.tm-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.tm-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tmTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}
.tm-typing-label {
    font-size: 11.5px;
    color: #8a7f6a;
}

/* ============================================================
   ATTACHMENT BADGES INSIDE MESSAGES
   ============================================================ */
.tm-msg-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.tm-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border: 1.5px solid #c1b9a6;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all 0.15s;
    max-width: 380px;
}
.tm-attachment:hover {
    border-color: #2f6844;
    background: #f7faf6;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 30, 10, 0.06);
}
.tm-attachment.lesson { border-left: 4px solid #2f6844; }
.tm-attachment.assignment { border-left: 4px solid #6366f1; }
.tm-attachment.data { border-left: 4px solid #b45309; }
.tm-attachment.drive { border-left: 4px solid #2563eb; }
.tm-attachment.file { border-left: 4px solid #4b5563; }

.tm-att-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #f4f1e8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2f6844;
}
.tm-attachment.assignment .tm-att-icon { color: #6366f1; }
.tm-attachment.data .tm-att-icon { color: #b45309; }
.tm-attachment.drive .tm-att-icon { color: #2563eb; }
.tm-attachment.file .tm-att-icon { color: #4b5563; }
.tm-att-icon svg { width: 20px; height: 20px; }

.tm-att-body { flex: 1; min-width: 0; }
.tm-att-kind {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #8a7f6a;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.tm-att-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-att-sub {
    font-size: 11.5px;
    color: #6b7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-att-open {
    flex: 0 0 auto;
    font-size: 11.5px;
    font-weight: 600;
    color: #2f6844;
}

/* In "me" bubbles, invert attachment look */
.tm-msg.me .tm-attachment {
    background: #ffffff;
    color: #111;
}

/* ============================================================
   COMPOSER
   ============================================================ */
.tm-composer {
    flex: 0 0 auto;
    padding: 12px 24px 18px;
    border-top: 1px solid #ece7dd;
    background: #fff;
}
.tm-composer-pending {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.tm-composer-pending:empty { display: none; }
.tm-pending-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: #e8f2ec;
    border: 1px solid #b7d6c2;
    border-radius: 999px;
    font-size: 12px;
    color: #2f6844;
    font-weight: 500;
    max-width: 260px;
}
.tm-pending-chip .tm-pending-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-pending-chip button {
    background: transparent;
    border: none;
    padding: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    color: #2f6844;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.tm-pending-chip button:hover { background: rgba(47, 104, 68, 0.15); }

.tm-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px;
    background: #faf8f3;
    border: 1px solid #ece7dd;
    border-radius: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tm-composer-row:focus-within {
    border-color: #2f6844;
    box-shadow: 0 0 0 3px rgba(47, 104, 68, 0.1);
}
.tm-composer-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #111;
    max-height: 160px;
    min-height: 20px;
    padding: 4px 0;
}
.tm-composer-input::placeholder { color: #8a7f6a; }

.tm-composer-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}
.tm-tool {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    position: relative;
}
.tm-tool:hover { color: #2f6844; background: #f4f1e8; }
.tm-tool svg { width: 16px; height: 16px; }

.tm-send {
    width: 36px;
    height: 36px;
    background: #2f6844;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex: 0 0 auto;
}
.tm-send:hover:not(:disabled) { background: #264f35; }
.tm-send:disabled { opacity: 0.5; cursor: not-allowed; }
.tm-send svg { width: 16px; height: 16px; }

.tm-announce-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
    user-select: none;
}
.tm-announce-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.tm-announce-toggle input { accent-color: #b45309; }
.tm-announce-toggle.active { color: #b45309; font-weight: 600; }

/* ============================================================
   TOOL MENUS (attach / link-lesson / link-assignment / drive)
   ============================================================ */
.tm-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 260px;
    max-width: 320px;
    max-height: 360px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ece7dd;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(40, 30, 10, 0.12);
    padding: 6px;
    z-index: 40;
}
.tm-menu-head {
    padding: 8px 10px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #8a7f6a;
    text-transform: uppercase;
}
.tm-menu-search {
    padding: 6px 10px 10px;
}
.tm-menu-search input {
    width: 100%;
    padding: 7px 10px;
    font-size: 12.5px;
    font-family: inherit;
    border: 1px solid #ece7dd;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
}
.tm-menu-search input:focus { border-color: #2f6844; }
.tm-menu-item {
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #111;
    display: flex;
    align-items: center;
    gap: 10px;
}
.tm-menu-item:hover { background: #f4f1e8; }
.tm-menu-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f4f1e8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2f6844;
    flex: 0 0 auto;
}
.tm-menu-item-main {
    flex: 1;
    min-width: 0;
}
.tm-menu-item-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-menu-item-sub {
    font-size: 11.5px;
    color: #6b7280;
    margin-top: 2px;
}
.tm-menu-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 12px;
    color: #8a7f6a;
}

/* ============================================================
   RIGHT COLUMN  —  shared-content / attachments panel
   ============================================================ */
.tm-side-right {
    width: 300px;
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ece7dd;
    background: #faf8f3;
    min-height: 0;
}
.tm-side-right.hidden { display: none; }

.tm-right-head {
    padding: 18px 20px 12px;
    border-bottom: 1px solid #ece7dd;
}
.tm-right-title {
    font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    font-weight: 400;
    font-size: 20px;
    color: #111;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.tm-right-title em { color: #2f6844; }
.tm-right-sub {
    font-size: 11.5px;
    color: #8a7f6a;
}
.tm-right-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    border-bottom: 1px solid #ece7dd;
    overflow-x: auto;
}
.tm-right-tab {
    padding: 6px 10px;
    font-size: 11.5px;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.12s;
}
.tm-right-tab:hover { color: #2f6844; background: #f4f1e8; }
.tm-right-tab.active { color: #2f6844; background: #e8f2ec; }

.tm-right-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tm-right-empty {
    padding: 24px 12px;
    text-align: center;
    font-size: 12.5px;
    color: #8a7f6a;
}

.tm-right-card {
    background: #fff;
    border: 1px solid #ece7dd;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.12s;
    display: flex;
    gap: 10px;
    align-items: center;
}
.tm-right-card:hover {
    border-color: #c1b9a6;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(40, 30, 10, 0.04);
}
.tm-right-card .tm-att-icon {
    width: 32px; height: 32px; border-radius: 8px;
}
.tm-right-card-body { flex: 1; min-width: 0; }
.tm-right-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-right-card-sub {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

/* ============================================================
   NEW CHAT MODAL (directory picker)
   ============================================================ */
.tm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 20, 10, 0.35);
    z-index: 3200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: tmFadeIn 0.15s;
}
@keyframes tmFadeIn { from { opacity: 0; } to { opacity: 1; } }

.tm-modal {
    width: min(92vw, 560px);
    max-height: 84vh;
    background: #faf8f3;
    border: 1px solid #ece7dd;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(40, 30, 10, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.tm-modal-head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid #ece7dd;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tm-modal-title {
    font-family: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    font-weight: 400;
    font-size: 22px;
    color: #111;
    letter-spacing: -0.01em;
}
.tm-modal-title em { color: #2f6844; }
.tm-modal-close {
    width: 32px; height: 32px;
    border: none; background: transparent;
    border-radius: 8px; cursor: pointer;
    color: #6b7280;
    display: inline-flex; align-items: center; justify-content: center;
}
.tm-modal-close:hover { background: #f4f1e8; color: #111; }

.tm-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 22px 10px;
}
.tm-modal-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #ece7dd;
    margin-bottom: 10px;
}
.tm-modal-tab {
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
}
.tm-modal-tab.active { color: #2f6844; border-bottom-color: #2f6844; }

.tm-modal-search {
    margin-bottom: 10px;
}
.tm-modal-search input {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 13px;
    border: 1px solid #ece7dd;
    border-radius: 10px;
    outline: none;
    box-sizing: border-box;
    background: #fff;
}
.tm-modal-search input:focus { border-color: #2f6844; }

.tm-picker-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tm-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
}
.tm-picker-item:hover { background: #fff; }
.tm-picker-item.selected { background: #e8f2ec; }
.tm-picker-item .tm-avatar {
    width: 32px; height: 32px; font-size: 12px;
}
.tm-picker-item-body {
    flex: 1;
    min-width: 0;
}
.tm-picker-item-title {
    font-size: 13.5px;
    font-weight: 500;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-picker-item-sub {
    font-size: 11.5px;
    color: #6b7280;
}
.tm-picker-check {
    width: 18px;
    height: 18px;
    border: 1.5px solid #c1b9a6;
    border-radius: 50%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
}
.tm-picker-item.selected .tm-picker-check {
    background: #2f6844;
    border-color: #2f6844;
    color: #fff;
}
.tm-picker-check svg { width: 12px; height: 12px; }

.tm-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 10px;
}
.tm-selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    background: #e8f2ec;
    border: 1px solid #b7d6c2;
    border-radius: 999px;
    font-size: 12px;
    color: #2f6844;
    font-weight: 500;
}
.tm-selected-chip button {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #2f6844;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tm-selected-chip button:hover { background: rgba(47, 104, 68, 0.15); }

.tm-modal-foot {
    padding: 14px 22px;
    border-top: 1px solid #ece7dd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
}
.tm-modal-foot-input {
    flex: 1;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    border: 1px solid #ece7dd;
    border-radius: 8px;
    outline: none;
    background: #fff;
    min-width: 0;
}
.tm-modal-foot-input:focus { border-color: #2f6844; }
.tm-modal-foot-input[hidden] { display: none; }
.tm-modal-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.tm-modal-btn.primary {
    background: #2f6844; color: #fff; border-color: #2f6844;
}
.tm-modal-btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.tm-modal-btn.primary:hover:not(:disabled) { background: #264f35; }
.tm-modal-btn.ghost {
    background: #fff; color: #4b5563; border-color: #d6d0c2;
}
.tm-modal-btn.ghost:hover { background: #f4f1e8; }

/* ============================================================
   HIDDEN FILE INPUT
   ============================================================ */
.tm-file-input {
    position: absolute;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   PHASE C2b — LIBRARY SHARE MESSAGE CARD
   ============================================================ */
.tm-bubble-share {
    padding: 10px 12px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.tm-msg.me .tm-bubble-share {
    background: #d1fae5;
    border-color: #6ee7b7;
}
.tm-share-text {
    margin-bottom: 8px;
    font-size: 13.5px;
    color: #064e3b;
    line-height: 1.45;
}
.tm-share-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 9px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.tm-share-icon {
    font-size: 26px;
    line-height: 1;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}
.tm-share-body {
    flex: 1;
    min-width: 0;
}
.tm-share-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-share-sub {
    font-size: 11.5px;
    color: #475569;
    margin-top: 2px;
}
.tm-share-view {
    background: #059669;
    border: 1px solid #059669;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 6px 14px;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s;
}
.tm-share-view:hover:not(:disabled) {
    background: #047857;
    border-color: #047857;
}
.tm-share-view:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.tm-share-view.is-gone {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ============================================================
   PHASE C: LEAVE-CLASS REQUEST BUBBLE
   ============================================================ */
.tm-bubble-leave {
    background: #fff;
    border: 1px solid #f3d3d3;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.06);
    padding: 0;
    overflow: hidden;
}
.tm-msg.me .tm-bubble-leave {
    border-color: #d3d3d3;
}
.tm-lr-card {
    display: flex;
    flex-direction: column;
}
.tm-lr-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fef2f2;
    border-bottom: 1px solid #f3d3d3;
    font-size: 12px;
    font-weight: 700;
    color: #991b1b;
    letter-spacing: 0.2px;
}
.tm-lr-card-icon { font-size: 14px; opacity: 0.8; }
.tm-lr-card-title { flex: 1 1 auto; }
.tm-lr-pill {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.tm-lr-pill-pending { background: #fde68a; color: #78350f; }
.tm-lr-pill-approved { background: #d1fae5; color: #065f46; }
.tm-lr-pill-declined { background: #e5e7eb; color: #374151; }
.tm-lr-card-body {
    padding: 12px 14px;
    color: #1a1a1a;
    font-size: 13px;
    line-height: 1.55;
}
.tm-lr-actions {
    display: flex;
    gap: 8px;
    padding: 0 14px 12px;
}
.tm-lr-btn {
    flex: 1 1 auto;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tm-lr-btn:disabled { opacity: 0.6; cursor: default; }
.tm-lr-decline {
    background: #fff;
    color: #4b5563;
    border-color: #d1d5db;
}
.tm-lr-decline:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; color: #111; }
.tm-lr-approve {
    background: #dc2626;
    color: #fff;
}
.tm-lr-approve:hover:not(:disabled) { background: #b91c1c; }

.tm-lr-resolved-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}
.tm-lr-resolved-dot.is-approved { background: #059669; }
.tm-lr-resolved-dot.is-declined { background: #9ca3af; }

/* ============================================================
   TEACHER-LINK REQUEST BADGE (inline OK/Decline)
   ============================================================ */
.tm-bubble-tl {
    background: #fff;
    border: 1px solid #c8e0d2;
    box-shadow: 0 2px 8px rgba(47, 104, 68, 0.06);
    padding: 0;
    overflow: hidden;
}
.tm-msg.me .tm-bubble-tl { border-color: #d3d3d3; }
.tm-tl-card { display: flex; flex-direction: column; }
.tm-tl-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #ecf5ef;
    border-bottom: 1px solid #c8e0d2;
    font-size: 12px;
    font-weight: 700;
    color: #1f4a30;
    letter-spacing: 0.2px;
}
.tm-tl-icon { font-size: 14px; }
.tm-tl-title { flex: 1 1 auto; }
.tm-tl-chip {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.tm-tl-chip-pending  { background: #fde68a; color: #78350f; }
.tm-tl-chip-approved { background: #d1fae5; color: #065f46; }
.tm-tl-chip-declined { background: #e5e7eb; color: #374151; }
.tm-tl-body {
    padding: 12px 14px;
    color: #1a1a1a;
    font-size: 13px;
    line-height: 1.55;
}
.tm-tl-actions {
    display: flex;
    gap: 8px;
    padding: 0 14px 12px;
}
.tm-tl-btn {
    flex: 1 1 auto;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    font-family: inherit;
}
.tm-tl-btn:disabled { opacity: 0.6; cursor: default; }
.tm-tl-btn-no {
    background: #fff;
    color: #4b5563;
    border-color: #d1d5db;
}
.tm-tl-btn-no:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; color: #111; }
.tm-tl-btn-yes {
    background: #2f6844;
    color: #fff;
    border-color: #2f6844;
}
.tm-tl-btn-yes:hover:not(:disabled) { background: #264f35; border-color: #264f35; }

/* ============================================================
   Student-copy request card (Phase 5c) — extends .tm-tl-card with
   a tickable field list shown to the source teacher while pending.
   ============================================================ */
.tm-scr-card .tm-tl-icon { color: #92400e; }
.tm-scr-fields {
    margin: 8px 0 4px;
    padding: 8px 10px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tm-scr-fields-h {
    font-size: 10.5px;
    font-weight: 800;
    color: #6b7280;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.tm-scr-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12.5px;
    color: #1f2937;
}
.tm-scr-field:hover { background: #fff; }
.tm-scr-field.is-locked { cursor: default; opacity: 0.85; }
.tm-scr-field.is-locked:hover { background: transparent; }
.tm-scr-field input {
    width: 14px;
    height: 14px;
    accent-color: #2f6844;
    cursor: pointer;
}
.tm-scr-field input:disabled { cursor: default; }
.tm-scr-fields-static {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
}
.tm-scr-fields-static .tm-scr-fields-h { width: 100%; margin: 0 0 2px; }
.tm-scr-pill {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    color: #374151;
    background: #e5e7eb;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.3px;
}

/* ============================================================
   PHASE H4: event invite + cancellation bubbles
   ============================================================ */
.tm-bubble-event {
    background: #fff;
    border: 1px solid #ddd6fe;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.06);
    padding: 0;
    overflow: hidden;
}
.tm-msg.me .tm-bubble-event {
    border-color: #d8d8d8;
}
.tm-ev-card {
    display: flex;
    flex-direction: column;
}
.tm-ev-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f5f3ff;
    border-bottom: 1px solid #ddd6fe;
    font-size: 12px;
    font-weight: 700;
    color: #5b21b6;
}
.tm-ev-card-icon { font-size: 14px; }
.tm-ev-card-title { flex: 1 1 auto; }
.tm-ev-card-meta {
    padding: 8px 14px 4px;
    font-size: 12.5px;
    color: #4b5563;
}
.tm-ev-card-body {
    padding: 6px 14px 10px;
    color: #1a1a1a;
    font-size: 13px;
    line-height: 1.5;
}
.tm-ev-actions {
    display: flex;
    gap: 6px;
    padding: 0 14px 12px;
}
.tm-ev-btn {
    flex: 1 1 auto;
    padding: 7px 10px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.tm-ev-btn:disabled { opacity: 0.6; cursor: default; }
.tm-ev-btn-yes:hover:not(:disabled) { background: #059669; color: #fff; border-color: #059669; }
.tm-ev-btn-maybe:hover:not(:disabled) { background: #d97706; color: #fff; border-color: #d97706; }
.tm-ev-btn-no:hover:not(:disabled) { background: #6b7280; color: #fff; border-color: #6b7280; }

.tm-ev-status-pill {
    margin: 0 14px 12px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    text-align: center;
}
.tm-ev-status-pill.tm-ev-status-accepted { background: #d1fae5; color: #065f46; }
.tm-ev-status-pill.tm-ev-status-maybe { background: #fde68a; color: #78350f; }
.tm-ev-status-pill.tm-ev-status-declined { background: #e5e7eb; color: #374151; }

.tm-ev-cancel-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    background: #b91c1c;
    vertical-align: middle;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1180px) {
    .tm-side-right { display: none; }
}
@media (max-width: 860px) {
    .tm-side { width: 260px; flex-basis: 260px; }
}
