/* ============================================================
   TM01GPT — GLOBAL CSS
   Interface responsiva — PC / Tablet / Smartphone
   ============================================================ */

:root {
    --tm-bg: #080b10;
    --tm-bg-2: #0d1118;
    --tm-panel: #11161f;
    --tm-panel-2: #161c26;
    --tm-border: #252d39;

    --tm-text: #f1f3f6;
    --tm-muted: #8c96a5;
    --tm-soft: #b7bfca;

    --tm-accent: #e83e8c;
    --tm-accent-hover: #f0529b;
    --tm-accent-dark: #a92663;

    --tm-user: #18202b;
    --tm-assistant: #10151d;

    --tm-radius: 14px;
    --tm-radius-small: 9px;

    --tm-shadow: 0 18px 50px rgba(0, 0, 0, .35);

    --tm-header-height: 72px;
}


/* ============================================================
   RESET
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--tm-bg);
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;

    background:
        radial-gradient(
            circle at 50% -10%,
            rgba(232, 62, 140, .09),
            transparent 38%
        ),
        var(--tm-bg);

    color: var(--tm-text);

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
textarea,
select,
input {
    font: inherit;
}

img,
svg {
    max-width: 100%;
}


/* ============================================================
   APP
   ============================================================ */

.tm-app {
    min-height: 100vh;
}


/* ============================================================
   HEADER
   ============================================================ */

.tm-header {
    position: sticky;
    top: 0;
    z-index: 50;

    min-height: var(--tm-header-height);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    padding: 10px clamp(14px, 4vw, 32px);

    background: rgba(8, 11, 16, .90);

    border-bottom: 1px solid var(--tm-border);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.tm-brand {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 12px;
}

.tm-brand-mark {
    flex: 0 0 auto;

    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background:
        linear-gradient(
            135deg,
            var(--tm-accent),
            var(--tm-accent-dark)
        );

    color: white;

    font-size: 14px;
    font-weight: 800;

    box-shadow:
        0 8px 24px rgba(232, 62, 140, .22);
}

.tm-brand-name {
    overflow: hidden;

    font-size: 16px;
    font-weight: 700;
    letter-spacing: .02em;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.tm-brand-subtitle {
    margin-top: 1px;

    color: var(--tm-muted);

    font-size: 12px;
}


/* ============================================================
   BUTTONS
   ============================================================ */

.tm-button {
    flex: 0 0 auto;

    min-height: 42px;
    min-width: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 18px;

    border: 1px solid transparent;
    border-radius: 9px;

    background: var(--tm-accent);

    color: white;

    font-size: 14px;
    font-weight: 650;

    cursor: pointer;

    transition:
        background .18s ease,
        transform .18s ease,
        box-shadow .18s ease;
}

.tm-button:hover {
    background: var(--tm-accent-hover);

    box-shadow:
        0 8px 24px rgba(232, 62, 140, .22);

    transform: translateY(-1px);
}

.tm-button:active {
    transform: translateY(0);
}

.tm-button:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}


/* ============================================================
   MAIN
   ============================================================ */

.tm-main {
    min-height: calc(100vh - var(--tm-header-height));

    padding:
        clamp(20px, 4vw, 38px)
        clamp(10px, 4vw, 24px)
        60px;
}

.tm-container {
    width: min(1180px, 100%);
    margin: 0 auto;
}


/* ============================================================
   HOME
   ============================================================ */

.tm-eyebrow {
    color: var(--tm-accent);

    font-size: 12px;
    font-weight: 800;

    letter-spacing: .16em;
    text-transform: uppercase;
}

.tm-title {
    margin: 8px 0 10px;

    font-size: clamp(38px, 7vw, 68px);
    line-height: 1;

    letter-spacing: -.04em;
}

.tm-subtitle {
    color: var(--tm-muted);
    font-size: clamp(14px, 2vw, 16px);
}

.tm-card {
    margin-top: 38px;

    padding: clamp(18px, 4vw, 28px);

    background: var(--tm-panel);

    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius);

    box-shadow: var(--tm-shadow);
}

.tm-home-card h2 {
    margin-top: 0;
}


/* ============================================================
   CHAT
   ============================================================ */

.tm-chat {
    width: 100%;

    display: flex;
    flex-direction: column;

    min-height: calc(100vh - 150px);

    overflow: hidden;

    background: var(--tm-panel);

    border: 1px solid var(--tm-border);
    border-radius: 18px;

    box-shadow: var(--tm-shadow);
}


/* ============================================================
   CHAT HEADER
   ============================================================ */

.tm-chat-header {
    min-height: 78px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 16px 22px;

    background: var(--tm-panel-2);

    border-bottom: 1px solid var(--tm-border);
}

.tm-chat-title {
    font-size: 17px;
    font-weight: 750;
}

.tm-chat-status {
    display: flex;
    align-items: center;
    gap: 7px;

    margin-top: 3px;

    color: var(--tm-muted);
    font-size: 12px;
}

.tm-chat-status::before {
    content: "";

    width: 7px;
    height: 7px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #38d996;

    box-shadow:
        0 0 9px rgba(56, 217, 150, .5);
}


/* ============================================================
   MODEL
   ============================================================ */

.tm-model {
    min-width: 0;

    display: flex;
    align-items: center;

    gap: 10px;
}

.tm-model label {
    flex: 0 0 auto;

    color: var(--tm-muted);
    font-size: 12px;
}

.tm-model select {
    min-width: 190px;
    max-width: 100%;

    padding: 9px 34px 9px 11px;

    border: 1px solid var(--tm-border);
    border-radius: 8px;

    background: var(--tm-bg-2);
    color: var(--tm-text);

    outline: none;

    cursor: pointer;
}

.tm-model select:focus {
    border-color: var(--tm-accent);
}


/* ============================================================
   MESSAGES
   ============================================================ */

.tm-messages {
    flex: 1;

    min-height: 420px;

    overflow-y: auto;
    overflow-x: hidden;

    padding: clamp(16px, 4vw, 28px);

    background:
        radial-gradient(
            circle at 50% 0,
            rgba(232, 62, 140, .035),
            transparent 45%
        ),
        var(--tm-bg-2);

    overscroll-behavior: contain;

    scrollbar-gutter: stable;
}

.tm-message {
    width: min(820px, 100%);

    margin-bottom: 24px;

    animation: tm-message-in .2s ease;
}

@keyframes tm-message-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tm-message-role {
    margin-bottom: 7px;

    color: var(--tm-muted);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: .08em;
    text-transform: uppercase;
}

.tm-message-content {
    width: 100%;

    padding: 14px 17px;

    border: 1px solid var(--tm-border);
    border-radius: 12px;

    background: var(--tm-assistant);

    color: var(--tm-text);

    font-size: 14px;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.tm-message-user {
    margin-left: auto;
}

.tm-message-user .tm-message-role {
    text-align: right;
}

.tm-message-user .tm-message-content {
    background: var(--tm-user);
    border-color: #303a48;
}


/* ============================================================
   CHAT FORM
   ============================================================ */

.tm-chat-form {
    display: flex;
    align-items: flex-end;

    gap: 12px;

    padding: 16px 18px;

    background: var(--tm-panel);

    border-top: 1px solid var(--tm-border);
}

.tm-chat-input {
    flex: 1;

    width: 100%;
    min-width: 0;

    min-height: 52px;
    max-height: 180px;

    resize: vertical;

    padding: 14px 15px;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);
    color: var(--tm-text);

    outline: none;

    font-size: 14px;
    line-height: 1.5;

    transition:
        border-color .18s ease,
        box-shadow .18s ease;
}

.tm-chat-input::placeholder {
    color: #657080;
}

.tm-chat-input:focus {
    border-color: var(--tm-accent);

    box-shadow:
        0 0 0 3px rgba(232, 62, 140, .10);
}

.tm-chat-form .tm-button {
    min-width: 100px;
}


/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 1024px) {

    .tm-container {
        width: 100%;
    }

    .tm-chat {
        min-height: calc(100vh - 135px);
    }

    .tm-chat-header {
        padding: 15px 18px;
    }

    .tm-messages {
        min-height: 380px;
    }
}


/* ============================================================
   SMARTPHONE
   ============================================================ */

@media (max-width: 700px) {

    :root {
        --tm-header-height: 64px;
    }

    .tm-header {
        padding: 8px 12px;
    }

    .tm-brand {
        gap: 9px;
    }

    .tm-brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 9px;
    }

    .tm-brand-name {
        font-size: 15px;
    }

    .tm-brand-subtitle {
        display: none;
    }

    .tm-header .tm-button {
        min-height: 38px;
        padding: 0 13px;
        font-size: 13px;
    }

    .tm-main {
        padding: 10px 8px 20px;
    }

    .tm-card {
        margin-top: 24px;
    }

    .tm-chat {
        min-height: calc(100dvh - 84px);
        border-radius: 12px;
    }

    .tm-chat-header {
        align-items: stretch;
        flex-direction: column;

        gap: 12px;

        padding: 13px;
    }

    .tm-model {
        width: 100%;
    }

    .tm-model select {
        flex: 1;

        min-width: 0;
        width: 100%;
    }

    .tm-messages {
        min-height: 0;
        padding: 16px 11px;
    }

    .tm-message {
        margin-bottom: 18px;
    }

    .tm-message-content {
        padding: 12px 13px;
        font-size: 14px;
    }

    .tm-chat-form {
        align-items: stretch;
        flex-direction: column;

        gap: 8px;

        padding: 10px;
    }

    .tm-chat-input {
        min-height: 48px;
        max-height: 150px;
    }

    .tm-chat-form .tm-button {
        width: 100%;
        min-width: 0;
        min-height: 44px;
    }
}


/* ============================================================
   SMARTPHONE PEQUENO
   ============================================================ */

@media (max-width: 380px) {

    .tm-header .tm-button {
        padding: 0 10px;
    }

    .tm-brand-name {
        font-size: 14px;
    }

    .tm-chat-title {
        font-size: 16px;
    }

    .tm-model {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .tm-model select {
        width: 100%;
    }
}


/* ============================================================
   TOUCH
   ============================================================ */

@media (hover: none) {

    .tm-button:hover {
        transform: none;
        box-shadow: none;
        background: var(--tm-accent);
    }

    .tm-button:active {
        background: var(--tm-accent-hover);
    }
}


/* ============================================================
   ACESSIBILIDADE
   ============================================================ */

:focus-visible {
    outline: 2px solid var(--tm-accent);
    outline-offset: 2px;
}


/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: var(--tm-bg);
}

::-webkit-scrollbar-thumb {
    background: #303846;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #414c5d;
}


/* ============================================================
   REDUZIR ANIMAÇÕES
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ========================================================
   TM01GPT — DATA/HORA DAS MENSAGENS
   ======================================================== */

.tm-message-time {
    margin-top: 6px;
    font-size: 0.72rem;
    opacity: 0.55;
    text-align: right;
    user-select: none;
}

.tm-message-content {
    white-space: pre-wrap;
}



/* ============================================================
   TM01GPT — REVIEW / LEARNING
   ============================================================ */

.tm-review-panel {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--tm-border, #303846);
    border-radius: 12px;
    background: var(--tm-panel, #151a22);
}

.tm-review-panel[hidden] {
    display: none;
}


/* ------------------------------------------------------------
   CABEÇALHO
   ------------------------------------------------------------ */

.tm-review-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.tm-review-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.tm-review-subtitle {
    margin-top: 5px;
    font-size: 0.82rem;
    opacity: 0.65;
    line-height: 1.4;
}

.tm-review-status {
    flex-shrink: 0;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    background: var(--tm-bg, #10141b);
    opacity: 0.8;
}


/* ------------------------------------------------------------
   ITENS
   ------------------------------------------------------------ */

.tm-review-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tm-review-item {
    padding: 14px;
    border: 1px solid var(--tm-border, #303846);
    border-radius: 10px;
    background: var(--tm-bg, #10141b);
}

.tm-review-item-field {
    margin-bottom: 7px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}

.tm-review-item-original {
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.tm-review-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}


/* ------------------------------------------------------------
   BOTÕES DE ACÇÃO
   ------------------------------------------------------------ */

.tm-review-action {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--tm-border, #303846);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}

.tm-review-action:hover {
    background: var(--tm-bg, #10141b);
    border-color: var(--tm-accent, #888);
}

.tm-review-action:active {
    transform: translateY(1px);
}


/* ------------------------------------------------------------
   CAMPO DE CORRECÇÃO
   ------------------------------------------------------------ */

.tm-review-correction {
    width: 100%;
    min-height: 70px;
    margin-top: 12px;
    padding: 10px 12px;
    box-sizing: border-box;

    border: 1px solid var(--tm-border, #303846);
    border-radius: 8px;

    background: var(--tm-bg, #10141b);
    color: inherit;

    font: inherit;
    font-size: 0.88rem;
    line-height: 1.4;

    resize: vertical;
}

.tm-review-correction:focus {
    outline: none;
    border-color: var(--tm-accent, #888);
}


/* ------------------------------------------------------------
   NOTA
   ------------------------------------------------------------ */

.tm-review-note {
    width: 100%;
    min-height: 50px;
    margin-top: 8px;
    padding: 9px 12px;
    box-sizing: border-box;

    border: 1px solid var(--tm-border, #303846);
    border-radius: 8px;

    background: var(--tm-bg, #10141b);
    color: inherit;

    font: inherit;
    font-size: 0.82rem;
    line-height: 1.4;

    resize: vertical;
}


/* ------------------------------------------------------------
   RODAPÉ
   ------------------------------------------------------------ */

.tm-review-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--tm-border, #303846);
}

.tm-button-secondary {
    background: transparent;
    border: 1px solid var(--tm-border, #303846);
}

.tm-button-secondary:hover {
    background: var(--tm-bg, #10141b);
}


/* ------------------------------------------------------------
   ESTADOS
   ------------------------------------------------------------ */

.tm-review-item.is-correct {
    border-color: var(--tm-accent, #888);
}

.tm-review-item.is-incorrect,
.tm-review-item.is-partial {
    border-color: var(--tm-accent, #888);
}


/* ------------------------------------------------------------
   MOBILE
   ------------------------------------------------------------ */

@media (max-width: 600px) {

    .tm-review-panel {
        padding: 14px;
    }

    .tm-review-header {
        flex-direction: column;
        gap: 10px;
    }

    .tm-review-status {
        align-self: flex-start;
    }

    .tm-review-item-actions {
        flex-direction: column;
    }

    .tm-review-action {
        width: 100%;
    }

    .tm-review-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .tm-review-footer .tm-button {
        width: 100%;
    }

}


/* ============================================================
   TM01GPT — ANÁLISE DE VÍDEO
   ============================================================ */

.tm-video-page {
    padding-bottom: 40px;
}

.tm-video-intro {
    margin-bottom: 28px;
}

.tm-video-source-card {
    margin-top: 0;
}

.tm-video-section-title {
    font-size: 16px;
    font-weight: 750;
}

.tm-video-source-tabs {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    margin-bottom: 20px;
}

.tm-video-source-tab {
    min-height: 40px;
    padding: 0 15px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg-2);
    color: var(--tm-muted);

    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
}

.tm-video-source-tab:hover {
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-tab.is-active {
    background: rgba(232, 62, 140, .10);
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-panel {
    width: 100%;
}

.tm-video-label {
    display: block;
    margin-bottom: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    font-weight: 700;
}

.tm-video-url-input,
.tm-video-select,
.tm-video-file-input {
    width: 100%;
    min-height: 48px;

    padding: 11px 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
    color: var(--tm-text);

    outline: none;
}

.tm-video-url-input:focus,
.tm-video-select:focus {
    border-color: var(--tm-accent);

    box-shadow:
        0 0 0 3px rgba(232, 62, 140, .10);
}

.tm-video-field-hint {
    margin-top: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    line-height: 1.45;
}

.tm-video-options {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 14px;

    margin-top: 22px;
}

.tm-video-action {
    display: flex;
    justify-content: flex-end;

    margin-top: 24px;
    padding-top: 18px;

    border-top: 1px solid var(--tm-border);
}

.tm-video-processing {
    margin-top: 18px;
}

.tm-video-status {
    margin-top: 12px;

    font-size: 14px;
    font-weight: 650;
}

.tm-video-status-detail {
    margin-top: 8px;

    color: var(--tm-muted);
    font-size: 12px;
}

.tm-video-progress {
    height: 7px;

    margin-top: 18px;

    overflow: hidden;

    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-progress-bar {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: var(--tm-accent);

    transition: width .3s ease;
}

.tm-video-error {
    margin-top: 18px;

    border-color: #71364f;
}

.tm-video-error-message {
    margin-top: 10px;

    color: var(--tm-soft);

    white-space: pre-wrap;
}

.tm-video-result {
    display: flex;
    flex-direction: column;
    gap: 18px;

    margin-top: 18px;
}

.tm-video-filename {
    margin-top: 10px;

    font-size: 18px;
    font-weight: 700;
}

.tm-video-source {
    margin-top: 4px;

    color: var(--tm-muted);

    font-size: 12px;

    overflow-wrap: anywhere;
}

.tm-video-info-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 10px;

    margin-top: 16px;
}

.tm-video-info-item {
    padding: 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
}

.tm-video-info-label {
    color: var(--tm-muted);

    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.tm-video-info-value {
    margin-top: 4px;

    font-size: 14px;
    font-weight: 650;

    overflow-wrap: anywhere;
}

.tm-video-section-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.tm-video-transcript {
    max-height: 600px;

    margin-top: 16px;
    padding: 15px;

    overflow-y: auto;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);

    font-size: 14px;
    line-height: 1.65;
}

.tm-video-transcript-segment {
    display: grid;
    grid-template-columns: 90px 1fr;

    gap: 12px;

    padding: 9px 0;

    border-bottom: 1px solid rgba(37, 45, 57, .65);
}

.tm-video-transcript-segment:last-child {
    border-bottom: 0;
}

.tm-video-transcript-time {
    color: var(--tm-accent);

    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.tm-video-analysis-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;

    margin-top: 18px;
}

.tm-video-analysis-block {
    padding: 15px;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-analysis-block:first-child,
.tm-video-analysis-block:last-child {
    grid-column: 1 / -1;
}

.tm-video-analysis-label {
    margin-bottom: 9px;

    color: var(--tm-muted);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: .07em;
    text-transform: uppercase;
}

.tm-video-analysis-value {
    color: var(--tm-text);

    font-size: 14px;
    line-height: 1.6;

    white-space: pre-wrap;
}

.tm-video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.tm-video-tag {
    display: inline-flex;
    align-items: center;

    min-height: 29px;
    padding: 0 9px;

    border: 1px solid var(--tm-border);
    border-radius: 999px;

    background: var(--tm-panel-2);

    color: var(--tm-soft);

    font-size: 12px;
}

.tm-video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tm-video-list-item {
    padding: 9px 11px;

    border-left: 2px solid var(--tm-accent);

    background: var(--tm-panel-2);

    font-size: 13px;
    line-height: 1.5;
}


@media (max-width: 700px) {

    .tm-video-source-tabs {
        width: 100%;
    }

    .tm-video-source-tab {
        flex: 1;
    }

    .tm-video-options {
        grid-template-columns: 1fr;
    }

    .tm-video-action {
        justify-content: stretch;
    }

    .tm-video-action .tm-button {
        width: 100%;
    }

    .tm-video-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tm-video-analysis-grid {
        grid-template-columns: 1fr;
    }

    .tm-video-analysis-block:first-child,
    .tm-video-analysis-block:last-child {
        grid-column: auto;
    }

    .tm-video-transcript-segment {
        grid-template-columns: 1fr;
        gap: 3px;
    }

}


@media (max-width: 380px) {

    .tm-video-info-grid {
        grid-template-columns: 1fr;
    }

}


/* ============================================================
   TM01GPT — ANÁLISE DE VÍDEO
   ============================================================ */

.tm-video-page {
    padding-bottom: 40px;
}

.tm-video-intro {
    margin-bottom: 28px;
}

.tm-video-source-card {
    margin-top: 0;
}

.tm-video-section-title {
    font-size: 16px;
    font-weight: 750;
}

.tm-video-source-tabs {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    margin-bottom: 20px;
}

.tm-video-source-tab {
    min-height: 40px;
    padding: 0 15px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg-2);
    color: var(--tm-muted);

    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
}

.tm-video-source-tab:hover {
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-tab.is-active {
    background: rgba(232, 62, 140, .10);
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-panel {
    width: 100%;
}

.tm-video-label {
    display: block;
    margin-bottom: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    font-weight: 700;
}

.tm-video-url-input,
.tm-video-select,
.tm-video-file-input {
    width: 100%;
    min-height: 48px;

    padding: 11px 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
    color: var(--tm-text);

    outline: none;
}

.tm-video-url-input:focus,
.tm-video-select:focus {
    border-color: var(--tm-accent);

    box-shadow:
        0 0 0 3px rgba(232, 62, 140, .10);
}

.tm-video-field-hint {
    margin-top: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    line-height: 1.45;
}

.tm-video-options {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 14px;

    margin-top: 22px;
}

.tm-video-action {
    display: flex;
    justify-content: flex-end;

    margin-top: 24px;
    padding-top: 18px;

    border-top: 1px solid var(--tm-border);
}

.tm-video-processing {
    margin-top: 18px;
}

.tm-video-status {
    margin-top: 12px;

    font-size: 14px;
    font-weight: 650;
}

.tm-video-status-detail {
    margin-top: 8px;

    color: var(--tm-muted);
    font-size: 12px;
}

.tm-video-progress {
    height: 7px;

    margin-top: 18px;

    overflow: hidden;

    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-progress-bar {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: var(--tm-accent);

    transition: width .3s ease;
}

.tm-video-error {
    margin-top: 18px;

    border-color: #71364f;
}

.tm-video-error-message {
    margin-top: 10px;

    color: var(--tm-soft);

    white-space: pre-wrap;
}

.tm-video-result {
    display: flex;
    flex-direction: column;
    gap: 18px;

    margin-top: 18px;
}

.tm-video-filename {
    margin-top: 10px;

    font-size: 18px;
    font-weight: 700;
}

.tm-video-source {
    margin-top: 4px;

    color: var(--tm-muted);

    font-size: 12px;

    overflow-wrap: anywhere;
}

.tm-video-info-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 10px;

    margin-top: 16px;
}

.tm-video-info-item {
    padding: 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
}

.tm-video-info-label {
    color: var(--tm-muted);

    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.tm-video-info-value {
    margin-top: 4px;

    font-size: 14px;
    font-weight: 650;

    overflow-wrap: anywhere;
}

.tm-video-section-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.tm-video-transcript {
    max-height: 600px;

    margin-top: 16px;
    padding: 15px;

    overflow-y: auto;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);

    font-size: 14px;
    line-height: 1.65;
}

.tm-video-transcript-segment {
    display: grid;
    grid-template-columns: 90px 1fr;

    gap: 12px;

    padding: 9px 0;

    border-bottom: 1px solid rgba(37, 45, 57, .65);
}

.tm-video-transcript-segment:last-child {
    border-bottom: 0;
}

.tm-video-transcript-time {
    color: var(--tm-accent);

    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.tm-video-analysis-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;

    margin-top: 18px;
}

.tm-video-analysis-block {
    padding: 15px;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-analysis-block:first-child,
.tm-video-analysis-block:last-child {
    grid-column: 1 / -1;
}

.tm-video-analysis-label {
    margin-bottom: 9px;

    color: var(--tm-muted);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: .07em;
    text-transform: uppercase;
}

.tm-video-analysis-value {
    color: var(--tm-text);

    font-size: 14px;
    line-height: 1.6;

    white-space: pre-wrap;
}

.tm-video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.tm-video-tag {
    display: inline-flex;
    align-items: center;

    min-height: 29px;
    padding: 0 9px;

    border: 1px solid var(--tm-border);
    border-radius: 999px;

    background: var(--tm-panel-2);

    color: var(--tm-soft);

    font-size: 12px;
}

.tm-video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tm-video-list-item {
    padding: 9px 11px;

    border-left: 2px solid var(--tm-accent);

    background: var(--tm-panel-2);

    font-size: 13px;
    line-height: 1.5;
}


@media (max-width: 700px) {

    .tm-video-source-tabs {
        width: 100%;
    }

    .tm-video-source-tab {
        flex: 1;
    }

    .tm-video-options {
        grid-template-columns: 1fr;
    }

    .tm-video-action {
        justify-content: stretch;
    }

    .tm-video-action .tm-button {
        width: 100%;
    }

    .tm-video-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tm-video-analysis-grid {
        grid-template-columns: 1fr;
    }

    .tm-video-analysis-block:first-child,
    .tm-video-analysis-block:last-child {
        grid-column: auto;
    }

    .tm-video-transcript-segment {
        grid-template-columns: 1fr;
        gap: 3px;
    }

}


@media (max-width: 380px) {

    .tm-video-info-grid {
        grid-template-columns: 1fr;
    }

}


/* ============================================================
   TM01GPT — ANÁLISE DE VÍDEO
   ============================================================ */

.tm-video-page {
    padding-bottom: 40px;
}

.tm-video-intro {
    margin-bottom: 28px;
}

.tm-video-source-card {
    margin-top: 0;
}

.tm-video-section-title {
    font-size: 16px;
    font-weight: 750;
}

.tm-video-source-tabs {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    margin-bottom: 20px;
}

.tm-video-source-tab {
    min-height: 40px;
    padding: 0 15px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg-2);
    color: var(--tm-muted);

    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
}

.tm-video-source-tab:hover {
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-tab.is-active {
    background: rgba(232, 62, 140, .10);
    border-color: var(--tm-accent);
    color: var(--tm-text);
}

.tm-video-source-panel {
    width: 100%;
}

.tm-video-label {
    display: block;
    margin-bottom: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    font-weight: 700;
}

.tm-video-url-input,
.tm-video-select,
.tm-video-file-input {
    width: 100%;
    min-height: 48px;

    padding: 11px 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
    color: var(--tm-text);

    outline: none;
}

.tm-video-url-input:focus,
.tm-video-select:focus {
    border-color: var(--tm-accent);

    box-shadow:
        0 0 0 3px rgba(232, 62, 140, .10);
}

.tm-video-field-hint {
    margin-top: 7px;

    color: var(--tm-muted);

    font-size: 12px;
    line-height: 1.45;
}

.tm-video-options {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 14px;

    margin-top: 22px;
}

.tm-video-action {
    display: flex;
    justify-content: flex-end;

    margin-top: 24px;
    padding-top: 18px;

    border-top: 1px solid var(--tm-border);
}

.tm-video-processing {
    margin-top: 18px;
}

.tm-video-status {
    margin-top: 12px;

    font-size: 14px;
    font-weight: 650;
}

.tm-video-status-detail {
    margin-top: 8px;

    color: var(--tm-muted);
    font-size: 12px;
}

.tm-video-progress {
    height: 7px;

    margin-top: 18px;

    overflow: hidden;

    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-progress-bar {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: var(--tm-accent);

    transition: width .3s ease;
}

.tm-video-error {
    margin-top: 18px;

    border-color: #71364f;
}

.tm-video-error-message {
    margin-top: 10px;

    color: var(--tm-soft);

    white-space: pre-wrap;
}

.tm-video-result {
    display: flex;
    flex-direction: column;
    gap: 18px;

    margin-top: 18px;
}

.tm-video-filename {
    margin-top: 10px;

    font-size: 18px;
    font-weight: 700;
}

.tm-video-source {
    margin-top: 4px;

    color: var(--tm-muted);

    font-size: 12px;

    overflow-wrap: anywhere;
}

.tm-video-info-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 10px;

    margin-top: 16px;
}

.tm-video-info-item {
    padding: 13px;

    border: 1px solid var(--tm-border);
    border-radius: 9px;

    background: var(--tm-bg);
}

.tm-video-info-label {
    color: var(--tm-muted);

    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.tm-video-info-value {
    margin-top: 4px;

    font-size: 14px;
    font-weight: 650;

    overflow-wrap: anywhere;
}

.tm-video-section-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.tm-video-transcript {
    max-height: 600px;

    margin-top: 16px;
    padding: 15px;

    overflow-y: auto;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);

    font-size: 14px;
    line-height: 1.65;
}

.tm-video-transcript-segment {
    display: grid;
    grid-template-columns: 90px 1fr;

    gap: 12px;

    padding: 9px 0;

    border-bottom: 1px solid rgba(37, 45, 57, .65);
}

.tm-video-transcript-segment:last-child {
    border-bottom: 0;
}

.tm-video-transcript-time {
    color: var(--tm-accent);

    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.tm-video-analysis-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 14px;

    margin-top: 18px;
}

.tm-video-analysis-block {
    padding: 15px;

    border: 1px solid var(--tm-border);
    border-radius: 10px;

    background: var(--tm-bg);
}

.tm-video-analysis-block:first-child,
.tm-video-analysis-block:last-child {
    grid-column: 1 / -1;
}

.tm-video-analysis-label {
    margin-bottom: 9px;

    color: var(--tm-muted);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: .07em;
    text-transform: uppercase;
}

.tm-video-analysis-value {
    color: var(--tm-text);

    font-size: 14px;
    line-height: 1.6;

    white-space: pre-wrap;
}

.tm-video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.tm-video-tag {
    display: inline-flex;
    align-items: center;

    min-height: 29px;
    padding: 0 9px;

    border: 1px solid var(--tm-border);
    border-radius: 999px;

    background: var(--tm-panel-2);

    color: var(--tm-soft);

    font-size: 12px;
}

.tm-video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tm-video-list-item {
    padding: 9px 11px;

    border-left: 2px solid var(--tm-accent);

    background: var(--tm-panel-2);

    font-size: 13px;
    line-height: 1.5;
}


@media (max-width: 700px) {

    .tm-video-source-tabs {
        width: 100%;
    }

    .tm-video-source-tab {
        flex: 1;
    }

    .tm-video-options {
        grid-template-columns: 1fr;
    }

    .tm-video-action {
        justify-content: stretch;
    }

    .tm-video-action .tm-button {
        width: 100%;
    }

    .tm-video-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tm-video-analysis-grid {
        grid-template-columns: 1fr;
    }

    .tm-video-analysis-block:first-child,
    .tm-video-analysis-block:last-child {
        grid-column: auto;
    }

    .tm-video-transcript-segment {
        grid-template-columns: 1fr;
        gap: 3px;
    }

}


@media (max-width: 380px) {

    .tm-video-info-grid {
        grid-template-columns: 1fr;
    }

}


/* ============================================================
   TM01GPT — BROWSER TABS
   ============================================================ */


.tm-header {

    flex-wrap: wrap;

}


.tm-tabs {

    display:flex;

    align-items:center;

    gap:6px;

    width:100%;

    overflow-x:auto;

    scrollbar-width:none;

}


.tm-tabs::-webkit-scrollbar {

    display:none;

}



.tm-tab {

    display:flex;

    align-items:center;

    justify-content:center;


    min-height:36px;

    padding:0 14px;


    border-radius:9px;


    border:1px solid transparent;


    color:var(--tm-muted);


    font-size:13px;


    white-space:nowrap;


    transition:.2s ease;

}



.tm-tab:hover {

    background:var(--tm-panel);

    color:var(--tm-text);

}



.tm-tab-active {

    background:var(--tm-panel-2);

    border-color:var(--tm-border);

    color:white;

}


/* ============================================================
   TM01GPT — CABEÇALHO UNIFICADO / TABS
   ============================================================ */

.tm-header {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tm-header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.tm-header-actions .tm-button {
    white-space: nowrap;
}

#tm-nav {
    flex: 0 0 auto;
}

.tm-tabs {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.tm-tab {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 8px;

    color: var(--tm-soft);

    font-size: 14px;
    font-weight: 500;

    border-radius: 8px;

    transition:
        background .18s ease,
        color .18s ease;
}

.tm-tab:hover {
    background: var(--tm-panel-2);
    color: var(--tm-text);
}

.tm-tab-active {
    background: var(--tm-panel-2);
    color: var(--tm-text);
}

@media (max-width: 1100px) {

    .tm-header {
        flex-wrap: wrap;
    }

    .tm-header-actions {
        flex: 0 0 auto;
        margin-left: auto;
    }

    #tm-nav {
        width: 100%;
        order: 3;
    }

    .tm-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }
}

@media (max-width: 700px) {

    .tm-header-actions {
        display: none;
    }

    .tm-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .tm-tab {
        flex: 0 0 auto;
        font-size: 13px;
        padding: 0 7px;
    }
}


/* ============================================================
   TM01GPT — CABEÇALHO UNIFICADO / TABS
   ============================================================ */

.tm-header {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tm-header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.tm-header-actions .tm-button {
    white-space: nowrap;
}

#tm-nav {
    flex: 0 0 auto;
}

.tm-tabs {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.tm-tab {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 8px;

    color: var(--tm-soft);

    font-size: 14px;
    font-weight: 500;

    border-radius: 8px;

    transition:
        background .18s ease,
        color .18s ease;
}

.tm-tab:hover {
    background: var(--tm-panel-2);
    color: var(--tm-text);
}

.tm-tab-active {
    background: var(--tm-panel-2);
    color: var(--tm-text);
}

@media (max-width: 1100px) {

    .tm-header {
        flex-wrap: wrap;
    }

    .tm-header-actions {
        flex: 0 0 auto;
        margin-left: auto;
    }

    #tm-nav {
        width: 100%;
        order: 3;
    }

    .tm-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }
}

@media (max-width: 700px) {

    .tm-header-actions {
        display: none;
    }

    .tm-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .tm-tab {
        flex: 0 0 auto;
        font-size: 13px;
        padding: 0 7px;
    }
}



/* =====================================================
   TM01GPT DASHBOARD
   ===================================================== */


.tm-header-actions {

display:flex;

gap:10px;

flex-wrap:wrap;

}



.tm-dashboard-grid {

display:grid;

grid-template-columns:
repeat(auto-fit,minmax(220px,1fr));

gap:20px;

margin-top:20px;

}



.tm-dashboard-item {

background:rgba(255,255,255,0.03);

border:1px solid rgba(255,255,255,0.08);

border-radius:14px;

padding:20px;

}



.tm-dashboard-item h3 {

margin-top:0;

margin-bottom:10px;

}



.tm-topic-list {

display:grid;

gap:12px;

}



.tm-topic-list div {

padding:16px;

background:rgba(255,255,255,0.03);

border-radius:12px;

border:1px solid rgba(255,255,255,0.08);

}



.tm-job-list {

display:grid;

gap:12px;

}



.tm-job {

display:flex;

justify-content:space-between;

align-items:center;

padding:16px;

background:rgba(255,255,255,0.03);

border-radius:12px;

border:1px solid rgba(255,255,255,0.08);

}



.tm-status-success {

color:#40e58c;

}



.tm-tools-grid {

display:grid;

grid-template-columns:
repeat(auto-fit,minmax(180px,1fr));

gap:15px;

}



.tm-tools-grid div {

padding:18px;

background:rgba(255,255,255,0.03);

border-radius:12px;

text-align:center;

border:1px solid rgba(255,255,255,0.08);

}



/* ============================================================
   CHAT — ALTURA FIXA AO ECRÃ
   Caixa de escrita sempre visível
   ============================================================ */

html,
body {
    height: 100%;
}

body {
    overflow-y: hidden;
}

.tm-main {
    height: calc(100dvh - var(--tm-header-height));
    min-height: 0;

    padding:
        20px
        clamp(10px, 4vw, 24px)
        20px;

    overflow: hidden;
}

.tm-container {
    height: 100%;
    min-height: 0;
}

.tm-chat {
    height: 100%;
    min-height: 0;
    max-height: 100%;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.tm-chat-header,
.tm-coder-controls,
.tm-review-panel,
.tm-chat-form {
    flex-shrink: 0;
}

.tm-messages {
    flex: 1 1 auto;

    min-height: 0;
    height: auto;

    overflow-y: auto;
    overflow-x: hidden;
}


/* TABLET */

@media (max-width: 1024px) {

    .tm-chat {
        height: 100%;
        min-height: 0;
    }

    .tm-messages {
        min-height: 0;
    }
}


/* SMARTPHONE */

@media (max-width: 700px) {

    .tm-main {
        height: calc(100dvh - var(--tm-header-height));
        min-height: 0;

        padding: 8px;
    }

    .tm-chat {
        height: 100%;
        min-height: 0;
    }

    .tm-messages {
        min-height: 0;
    }
}


/* Scroll exclusivo da janela de conversa */
.tm-messages {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    min-height: 0;
}

html,
body {
    overflow: hidden;
}



/* ============================================================
   TM01GPT — EXPLORADOR DE RECURSOS
   ============================================================ */

.tm-resource-explorer {
    flex-shrink: 0;
    margin: 10px 0;

    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;

    background: var(--tm-panel);
}

.tm-resource-summary {
    cursor: pointer;

    padding: 12px 14px;

    font-weight: 700;

    user-select: none;
}

.tm-resource-explorer[open]
.tm-resource-summary {
    border-bottom:
        1px solid rgba(255,255,255,0.08);
}

.tm-resource-toolbar,
.tm-resource-actions,
.tm-resource-job-controls {
    display: flex;
    gap: 8px;

    flex-wrap: wrap;
    align-items: center;

    padding: 10px 12px;
}

.tm-resource-node-status {
    margin-left: auto;

    font-size: 0.85rem;
    opacity: 0.8;
}

.tm-resource-path-row {
    display: flex;

    gap: 10px;
    align-items: center;

    padding: 8px 12px;

    font-size: 0.85rem;
}

.tm-resource-path-row code,
.tm-resource-selected code {
    overflow-wrap: anywhere;
}

.tm-resource-entries {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(180px, 1fr)
        );

    gap: 6px;

    max-height: 260px;
    overflow-y: auto;

    padding: 10px 12px;

    border-top:
        1px solid rgba(255,255,255,0.06);

    border-bottom:
        1px solid rgba(255,255,255,0.06);
}

.tm-resource-entry {
    appearance: none;

    display: flex;

    align-items: center;
    gap: 8px;

    min-width: 0;

    padding: 10px;

    border:
        1px solid rgba(255,255,255,0.08);

    border-radius: 9px;

    background:
        rgba(255,255,255,0.025);

    color: inherit;

    text-align: left;

    cursor: pointer;
}

.tm-resource-entry:hover {
    background:
        rgba(255,255,255,0.07);
}

.tm-resource-entry.is-selected {
    outline:
        2px solid currentColor;

    outline-offset: -2px;
}

.tm-resource-entry-icon {
    flex-shrink: 0;
}

.tm-resource-entry-name {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.tm-resource-selected {
    padding: 10px 12px;
}

.tm-resource-selected-label {
    margin-bottom: 5px;

    font-size: 0.75rem;
    opacity: 0.65;

    text-transform: uppercase;
}

.tm-resource-selected-type {
    margin-top: 4px;

    font-size: 0.8rem;
    opacity: 0.7;
}

.tm-resource-job-controls label {
    display: flex;

    align-items: center;
    gap: 7px;

    font-size: 0.85rem;
}

.tm-resource-result {
    padding: 10px 12px;

    border-top:
        1px solid rgba(255,255,255,0.06);

    font-size: 0.85rem;

    overflow-wrap: anywhere;
}

.tm-resource-empty {
    padding: 15px;

    opacity: 0.7;
}


@media (max-width: 700px) {

    .tm-resource-entries {
        grid-template-columns:
            1fr;

        max-height: 210px;
    }

    .tm-resource-node-status {
        width: 100%;
        margin-left: 0;
    }

    .tm-resource-actions
    .tm-button {
        flex: 1 1 auto;
    }
}



/* ============================================================
   TM01GPT — LAYOUT PRODUÇÃO CHAT / RECURSOS
   ============================================================ */

.tm-chat {

    display: grid;

    grid-template-columns:
        minmax(290px, 340px)
        minmax(0, 1fr);

    grid-template-rows:
        auto
        auto
        auto
        minmax(0, 1fr)
        auto;

    grid-template-areas:
        "header   header"
        "coder    coder"
        "explorer composer"
        "explorer messages"
        "review   review";

    column-gap: 16px;

    height: 100%;
    min-height: 0;

    overflow: hidden;
}


/* ------------------------------------------------------------
   HEADER
   ------------------------------------------------------------ */

.tm-chat-header {

    grid-area: header;

    margin-bottom: 14px;
}


/* ------------------------------------------------------------
   CODER
   ------------------------------------------------------------ */

.tm-coder-controls {

    grid-area: coder;

    margin-bottom: 14px;
}


/* ------------------------------------------------------------
   EXPLORADOR — COLUNA ESQUERDA
   ------------------------------------------------------------ */

.tm-resource-explorer {

    grid-area: explorer;

    margin: 0;

    min-width: 0;
    min-height: 0;

    height: 100%;

    align-self: stretch;

    overflow: hidden;

    border-radius: 14px;
}


.tm-resource-explorer[open] {

    display: flex;

    flex-direction: column;

    min-height: 0;
}


.tm-resource-summary {

    flex: 0 0 auto;

    padding: 14px 16px;

    font-size: 0.95rem;
}


.tm-resource-toolbar {

    flex: 0 0 auto;

    padding:
        10px
        12px;
}


.tm-resource-node-status {

    width: 100%;

    margin: 4px 0 0;

    padding: 7px 9px;

    border-radius: 8px;

    background:
        rgba(255,255,255,0.035);

    font-size: 0.78rem;
}


.tm-resource-path-row {

    flex: 0 0 auto;

    display: block;

    padding:
        10px
        12px;
}


.tm-resource-path-row > span {

    display: block;

    margin-bottom: 5px;

    font-size: 0.7rem;

    text-transform: uppercase;

    opacity: 0.55;
}


.tm-resource-path-row code {

    display: block;

    padding: 8px;

    border-radius: 7px;

    background:
        rgba(0,0,0,0.20);

    font-size: 0.78rem;

    line-height: 1.35;
}


/* lista de ficheiros passa a ocupar o espaço disponível */

.tm-resource-entries {

    flex: 1 1 auto;

    min-height: 120px;

    max-height: none;

    overflow-y: auto;

    grid-template-columns: 1fr;

    align-content: start;

    padding:
        8px
        10px;
}


.tm-resource-entry {

    width: 100%;

    min-height: 38px;

    padding:
        8px
        9px;
}


.tm-resource-entry-name {

    font-size: 0.83rem;
}


/* ------------------------------------------------------------
   SELEÇÃO
   ------------------------------------------------------------ */

.tm-resource-selected {

    flex: 0 0 auto;

    padding:
        10px
        12px;
}


.tm-resource-selected code {

    display: block;

    max-height: 55px;

    overflow: auto;

    padding: 7px;

    border-radius: 7px;

    background:
        rgba(0,0,0,0.20);

    font-size: 0.75rem;
}


/* ------------------------------------------------------------
   JOB
   ------------------------------------------------------------ */

.tm-resource-job-controls {

    flex: 0 0 auto;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 8px;

    padding:
        8px
        12px;
}


.tm-resource-job-controls label {

    display: grid;

    gap: 5px;

    align-items: initial;

    font-size: 0.72rem;

    opacity: 0.9;
}


.tm-resource-job-controls
.tm-mode-select {

    width: 100%;
}


/* ------------------------------------------------------------
   BOTÕES DO EXPLORADOR
   ------------------------------------------------------------ */

.tm-resource-actions {

    flex: 0 0 auto;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 7px;

    padding:
        8px
        12px
        10px;
}


.tm-resource-actions
.tm-button {

    width: 100%;

    min-width: 0;

    padding:
        8px
        7px;

    font-size: 0.76rem;
}


.tm-resource-result {

    flex: 0 0 auto;

    max-height: 72px;

    overflow-y: auto;

    padding:
        9px
        12px;

    font-size: 0.76rem;
}


/* ============================================================
   COMPOSITOR — COLUNA DIREITA
   ============================================================ */

.tm-chat-form {

    grid-area: composer;

    display: grid;

    grid-template-columns: 1fr;

    gap: 8px;

    min-width: 0;

    margin: 0 0 12px;

    padding: 0;
}


.tm-chat-input {

    width: 100%;

    min-height: 88px;

    max-height: 180px;

    resize: vertical;
}


.tm-chat-form-footer {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;
}


.tm-chat-hint {

    font-size: 0.78rem;

    opacity: 0.60;
}


/* ============================================================
   CONVERSA — COLUNA DIREITA
   ============================================================ */

.tm-messages {

    grid-area: messages;

    min-width: 0;
    min-height: 0;

    height: auto;

    overflow-y: auto;
    overflow-x: hidden;

    padding:
        2px
        4px
        20px;

    border-top:
        1px solid rgba(255,255,255,0.05);
}


/* mensagens passam a aproveitar melhor a largura */

.tm-message {

    max-width: 92%;
}


.tm-message-user {

    margin-left: auto;
}


.tm-message-assistant {

    margin-right: auto;
}


/* ============================================================
   REVIEW
   ============================================================ */

.tm-review-panel {

    grid-area: review;
}


/* ============================================================
   DESKTOP GRANDE
   ============================================================ */

@media (min-width: 1500px) {

    .tm-chat {

        grid-template-columns:
            360px
            minmax(0, 1fr);

        column-gap: 20px;
    }

}


/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 1050px) {

    .tm-chat {

        grid-template-columns:
            270px
            minmax(0, 1fr);

        column-gap: 12px;
    }

}


/* ============================================================
   TABLET PEQUENO / SMARTPHONE
   ============================================================ */

@media (max-width: 800px) {

    .tm-chat {

        display: flex;

        flex-direction: column;

        height: 100%;

        overflow: hidden;
    }


    .tm-chat-header {

        flex: 0 0 auto;

        margin-bottom: 8px;
    }


    .tm-coder-controls {

        flex: 0 0 auto;

        margin-bottom: 8px;
    }


    .tm-resource-explorer {

        flex: 0 0 auto;

        height: auto;

        max-height: 42vh;

        margin-bottom: 8px;
    }


    .tm-resource-explorer[open] {

        display: block;

        overflow-y: auto;
    }


    .tm-resource-entries {

        max-height: 180px;
    }


    .tm-chat-form {

        flex: 0 0 auto;

        margin-bottom: 8px;
    }


    .tm-messages {

        flex: 1 1 auto;

        min-height: 0;
    }

}


/* ============================================================
   SMARTPHONE
   ============================================================ */

@media (max-width: 520px) {

    .tm-resource-job-controls {

        grid-template-columns:
            1fr;
    }


    .tm-resource-actions {

        grid-template-columns:
            1fr;
    }


    .tm-chat-form-footer {

        align-items: stretch;

        flex-direction: column;
    }


    .tm-chat-form-footer
    .tm-button {

        width: 100%;
    }


    .tm-message {

        max-width: 100%;
    }

}



/* ============================================================
   TM01GPT WORKSTATION — CHAT V2
   ============================================================ */

.tm-chat-page {
    padding: 18px;
    height:
        calc(
            100dvh -
            var(--tm-header-height)
        );

    overflow: hidden;
}


.tm-chat-shell {
    width: min(
        1500px,
        100%
    );

    height: 100%;

    margin: 0 auto;

    display: flex;
    flex-direction: column;

    min-height: 0;

    border:
        1px solid
        rgba(255,255,255,.08);

    border-radius: 18px;

    background:
        #0c1119;

    overflow: hidden;

    box-shadow:
        0 20px 60px
        rgba(0,0,0,.18);
}


/* ============================================================
   HEADER
   ============================================================ */

.tm-workstation-header {
    flex: 0 0 auto;

    min-height: 84px;

    padding:
        18px
        22px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    border-bottom:
        1px solid
        rgba(255,255,255,.08);

    background:
        #141b26;
}


.tm-workstation-title {
    font-size: 1.1rem;
    font-weight: 750;
}


.tm-workstation-status {
    display: flex;
    align-items: center;

    gap: 7px;

    margin-top: 5px;

    font-size: .76rem;

    opacity: .65;
}


.tm-status-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: #42df93;

    box-shadow:
        0 0 10px
        rgba(66,223,147,.7);
}


.tm-workstation-mode {
    display: flex;
    align-items: center;

    gap: 10px;
}


.tm-workstation-mode label {
    font-size: .78rem;
    opacity: .6;
}


.tm-mode-status {
    min-width: 155px;

    font-size: .8rem;

    opacity: .7;
}


/* ============================================================
   CODER BAR
   ============================================================ */

.tm-coder-bar {
    flex: 0 0 auto;

    padding:
        10px
        18px;

    display: flex;

    align-items: end;

    gap: 12px;

    border-bottom:
        1px solid
        rgba(255,255,255,.07);

    background:
        #101721;
}


.tm-coder-bar[hidden] {
    display: none;
}


.tm-coder-field {
    display: grid;
    gap: 5px;
}


.tm-coder-field label {
    font-size: .7rem;
    opacity: .6;
}


.tm-coder-status {
    margin-left: auto;

    padding-bottom: 9px;

    font-size: .78rem;
    opacity: .65;
}


/* ============================================================
   ÁREA CENTRAL
   ============================================================ */

.tm-ai-workspace {
    flex: 1 1 auto;

    min-height: 0;

    display: grid;

    grid-template-columns:
        320px
        minmax(0, 1fr);
}


/* ============================================================
   SIDEBAR
   ============================================================ */

.tm-resource-sidebar {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    border-right:
        1px solid
        rgba(255,255,255,.08);

    background:
        #0f151e;
}


.tm-resource-sidebar-header {
    flex: 0 0 auto;

    padding:
        17px
        16px
        13px;
}


.tm-sidebar-title {
    font-size: .95rem;
    font-weight: 700;
}


.tm-sidebar-subtitle {
    margin-top: 3px;

    font-size: .72rem;
    opacity: .48;
}


/* ============================================================
   TABS
   ============================================================ */

.tm-resource-tabs {
    flex: 0 0 auto;

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    padding:
        0
        10px
        10px;

    gap: 5px;

    border-bottom:
        1px solid
        rgba(255,255,255,.06);
}


.tm-resource-tab {
    appearance: none;

    border:
        1px solid
        transparent;

    border-radius: 8px;

    background:
        transparent;

    color: inherit;

    padding:
        8px
        5px;

    font-size: .72rem;

    cursor: pointer;
}


.tm-resource-tab:hover {
    background:
        rgba(255,255,255,.05);
}


.tm-resource-tab.is-active {
    background:
        rgba(255,255,255,.07);

    border-color:
        rgba(255,255,255,.08);
}


.tm-resource-tab-panel {
    display: none;

    flex: 1 1 auto;

    min-height: 0;
}


.tm-resource-tab-panel.is-active {
    display: flex;
    flex-direction: column;
}


/* ============================================================
   FILE EXPLORER
   ============================================================ */

.tm-resource-explorer {
    margin: 0;

    border: 0;
    border-radius: 0;

    background: transparent;

    height: 100%;

    min-height: 0;

    display: flex;
    flex-direction: column;
}


.tm-resource-summary {
    display: none;
}


.tm-resource-toolbar {
    flex: 0 0 auto;

    display: flex;

    gap: 6px;

    padding:
        10px
        12px;
}


.tm-resource-tool-button {
    border:
        1px solid
        rgba(255,255,255,.08);

    border-radius: 8px;

    background:
        rgba(255,255,255,.035);

    color: inherit;

    padding:
        7px
        10px;

    font-size: .75rem;

    cursor: pointer;
}


.tm-resource-tool-button:hover {
    background:
        rgba(255,255,255,.08);
}


.tm-resource-path,
.tm-resource-selection {
    flex: 0 0 auto;

    padding:
        9px
        12px;
}


.tm-resource-label {
    margin-bottom: 5px;

    font-size: .65rem;

    opacity: .45;

    text-transform: uppercase;

    letter-spacing: .04em;
}


.tm-resource-path code,
.tm-resource-selection code {
    display: block;

    padding:
        7px
        8px;

    border-radius: 7px;

    background:
        rgba(0,0,0,.22);

    font-size: .72rem;

    line-height: 1.35;

    overflow-wrap: anywhere;
}


.tm-resource-entries {
    flex: 1 1 auto;

    min-height: 100px;
    max-height: none;

    overflow-y: auto;

    display: flex;
    flex-direction: column;

    gap: 2px;

    padding:
        5px
        8px;

    border-top:
        1px solid
        rgba(255,255,255,.045);

    border-bottom:
        1px solid
        rgba(255,255,255,.045);
}


.tm-resource-entry {
    width: 100%;

    flex: 0 0 auto;

    min-height: 34px;

    display: flex;

    align-items: center;

    gap: 8px;

    border: 0;

    border-radius: 7px;

    background:
        transparent;

    color: inherit;

    padding:
        6px
        8px;

    text-align: left;

    cursor: pointer;
}


.tm-resource-entry:hover {
    background:
        rgba(255,255,255,.055);
}


.tm-resource-entry.is-selected {
    background:
        rgba(210,54,121,.14);

    outline:
        1px solid
        rgba(210,54,121,.40);
}


.tm-resource-entry-icon {
    width: 20px;

    flex-shrink: 0;

    text-align: center;
}


.tm-resource-entry-name {
    min-width: 0;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;

    font-size: .8rem;
}


.tm-resource-selection-actions {
    flex: 0 0 auto;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 6px;

    padding:
        8px
        12px
        12px;
}


/* ============================================================
   WORKERS
   ============================================================ */

.tm-worker-panel,
.tm-job-panel {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    padding:
        14px
        12px;
}


.tm-worker-summary {
    margin-bottom: 12px;

    padding:
        9px;

    border-radius: 8px;

    background:
        rgba(255,255,255,.035);

    font-size: .75rem;
}


.tm-worker-static-list {
    display: grid;

    gap: 6px;
}


.tm-worker-card {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 10px;

    padding:
        10px;

    border:
        1px solid
        rgba(255,255,255,.06);

    border-radius: 9px;

    background:
        rgba(255,255,255,.025);
}


.tm-worker-card > div {
    display: grid;
    gap: 3px;
}


.tm-worker-card strong {
    font-size: .82rem;
}


.tm-worker-card span {
    font-size: .69rem;
    opacity: .55;
}


.tm-worker-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: #42df93;
}


/* ============================================================
   JOB
   ============================================================ */

.tm-job-panel {
    display: flex;
    flex-direction: column;

    gap: 12px;
}


.tm-job-field {
    display: grid;

    gap: 5px;

    font-size: .72rem;
}


.tm-job-field > span {
    opacity: .55;
}


.tm-resource-action {
    min-height: 36px;

    border:
        1px solid
        rgba(255,255,255,.09);

    border-radius: 8px;

    background:
        rgba(255,255,255,.04);

    color: inherit;

    padding:
        7px
        10px;

    cursor: pointer;

    font-size: .75rem;
}


.tm-resource-action:hover:not(:disabled) {
    background:
        rgba(255,255,255,.09);
}


.tm-resource-action:disabled {
    opacity: .35;

    cursor: not-allowed;
}


.tm-resource-run {
    background:
        #cf3678;

    border-color:
        #cf3678;

    color: white;

    font-weight: 650;
}


.tm-job-result {
    margin-top: auto;

    padding:
        10px;

    border-radius: 8px;

    background:
        rgba(255,255,255,.03);

    font-size: .72rem;

    line-height: 1.4;

    overflow-wrap: anywhere;
}


/* ============================================================
   CONVERSATION WORKSPACE
   ============================================================ */

.tm-conversation-workspace {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    background:
        #0b1017;
}


/* ============================================================
   COMPOSER
   ============================================================ */

.tm-composer {
    flex: 0 0 auto;

    margin: 0;

    padding:
        18px
        20px;

    border-bottom:
        1px solid
        rgba(255,255,255,.07);

    background:
        #101721;
}


.tm-composer-title-row {
    margin-bottom: 10px;
}


.tm-composer-title {
    font-size: .88rem;
    font-weight: 700;
}


.tm-composer-subtitle {
    margin-top: 2px;

    font-size: .69rem;

    opacity: .45;
}


.tm-composer-input {
    width: 100%;

    min-height: 95px;

    resize: vertical;

    padding:
        13px
        14px;

    border:
        1px solid
        rgba(255,255,255,.08);

    border-radius: 10px;

    background:
        #080d13;

    color: inherit;

    outline: none;

    line-height: 1.45;
}


.tm-composer-input:focus {
    border-color:
        rgba(210,54,121,.65);

    box-shadow:
        0 0 0 2px
        rgba(210,54,121,.09);
}


.tm-composer-footer {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 12px;

    margin-top: 9px;
}


.tm-send-button {
    min-width: 110px;
}


/* ============================================================
   CONVERSA
   ============================================================ */

.tm-conversation-header {
    flex: 0 0 auto;

    padding:
        13px
        20px
        10px;

    border-bottom:
        1px solid
        rgba(255,255,255,.045);
}


.tm-conversation-title {
    font-size: .85rem;
    font-weight: 700;
}


.tm-conversation-subtitle {
    margin-top: 2px;

    font-size: .68rem;

    opacity: .4;
}


.tm-conversation-stream {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    padding:
        18px
        20px
        40px;

    border: 0;
}


.tm-conversation-stream
.tm-message {
    max-width: 820px;
}


/* ============================================================
   SCROLLBARS
   ============================================================ */

.tm-resource-entries,
.tm-worker-panel,
.tm-job-panel,
.tm-conversation-stream {
    scrollbar-width: thin;
}


/* ============================================================
   DESKTOP LARGO
   ============================================================ */

@media (min-width: 1500px) {

    .tm-ai-workspace {
        grid-template-columns:
            350px
            minmax(0, 1fr);
    }

}


/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 1000px) {

    .tm-ai-workspace {
        grid-template-columns:
            270px
            minmax(0, 1fr);
    }


    .tm-mode-status {
        display: none;
    }

}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 760px) {

    .tm-chat-page {
        padding: 6px;
    }


    .tm-chat-shell {
        border-radius: 12px;
    }


    .tm-workstation-header {
        min-height: auto;

        padding:
            12px
            13px;
    }


    .tm-ai-workspace {
        display: flex;
        flex-direction: column;
    }


    .tm-resource-sidebar {
        flex: 0 0 auto;

        max-height: 42vh;

        border-right: 0;

        border-bottom:
            1px solid
            rgba(255,255,255,.08);
    }


    .tm-resource-tab-panel.is-active {
        max-height: 32vh;
    }


    .tm-resource-entries {
        max-height: 180px;
    }


    .tm-conversation-workspace {
        flex: 1 1 auto;
        min-height: 0;
    }


    .tm-composer {
        padding: 12px;
    }


    .tm-conversation-stream {
        padding:
            12px
            12px
            30px;
    }

}


/* ============================================================
   PHONE
   ============================================================ */

@media (max-width: 520px) {

    .tm-workstation-mode label,
    .tm-sidebar-subtitle {
        display: none;
    }


    .tm-workstation-header {
        gap: 8px;
    }


    .tm-resource-tabs {
        padding:
            0
            6px
            6px;
    }


    .tm-resource-tab {
        font-size: .67rem;
    }


    .tm-composer-footer {
        flex-direction: column;

        align-items: stretch;
    }


    .tm-send-button {
        width: 100%;
    }

}



/* ============================================================
   TM01GPT — SCROLL INDEPENDENTE DO EXPLORADOR
   ============================================================ */

.tm-resource-sidebar {
    min-height: 0;
    overflow: hidden;
}


/* Tab ativa ocupa a altura disponível */
.tm-resource-tab-panel.is-active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}


/* Explorador completo */
.tm-resource-explorer {
    flex: 1 1 auto;
    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


/* Só a lista de ficheiros faz scroll */
.tm-resource-entries {
    flex: 1 1 auto;

    min-height: 0;
    max-height: none;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;

    scrollbar-width: thin;
}


/* Workers */
.tm-worker-panel {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;

    scrollbar-width: thin;
}


/* Jobs */
.tm-job-panel {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;

    scrollbar-width: thin;
}


/* Conversa */
.tm-conversation-stream {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;

    scrollbar-width: thin;
}


/* Chrome / Edge */
.tm-resource-entries::-webkit-scrollbar,
.tm-worker-panel::-webkit-scrollbar,
.tm-job-panel::-webkit-scrollbar,
.tm-conversation-stream::-webkit-scrollbar {
    width: 8px;
}


.tm-resource-entries::-webkit-scrollbar-thumb,
.tm-worker-panel::-webkit-scrollbar-thumb,
.tm-job-panel::-webkit-scrollbar-thumb,
.tm-conversation-stream::-webkit-scrollbar-thumb {
    background:
        rgba(255,255,255,.14);

    border-radius: 10px;
}


.tm-resource-entries::-webkit-scrollbar-thumb:hover,
.tm-worker-panel::-webkit-scrollbar-thumb:hover,
.tm-job-panel::-webkit-scrollbar-thumb:hover,
.tm-conversation-stream::-webkit-scrollbar-thumb:hover {
    background:
        rgba(255,255,255,.24);
}



/* ============================================================
   EXPLORADOR — AÇÕES DIRETAS
   ============================================================ */

.tm-resource-selection-actions {
    grid-template-columns:
        repeat(3, 1fr);
}


.tm-resource-worker-button:not(:disabled) {
    border-color:
        rgba(210,54,121,.45);

    background:
        rgba(210,54,121,.10);
}


.tm-resource-worker-button:not(:disabled):hover {
    background:
        rgba(210,54,121,.20);
}


/* Indicação visual de pasta navegável */

.tm-resource-entry[data-type="directory"] {
    cursor: default;
}


/* Mantém lista de ficheiros com scroll próprio */

.tm-resource-entries {
    overflow-y: auto !important;
    overflow-x: hidden !important;

    min-height: 0 !important;

    scrollbar-width: thin;
}


@media (max-width: 520px) {

    .tm-resource-selection-actions {
        grid-template-columns:
            1fr;
    }

}



/* ============================================================
   EXPLORADOR — SELEÇÃO E AÇÕES NO TOPO
   ============================================================ */

.tm-resource-explorer,
.tm-resource-explorer[open] {
    display: flex !important;
    flex-direction: column !important;
}


/* ordem dos blocos */

.tm-resource-selection {
    order: 1 !important;
}

.tm-resource-selection-actions {
    order: 2 !important;
}

.tm-resource-toolbar {
    order: 3 !important;
}

.tm-resource-path {
    order: 4 !important;
}

.tm-resource-entries {
    order: 5 !important;
}


/* seleção destacada no topo */

.tm-resource-selection {
    flex: 0 0 auto !important;

    padding:
        10px
        12px
        7px !important;

    border-bottom:
        1px solid rgba(255,255,255,.06);

    background:
        rgba(255,255,255,.02);
}


/* botões logo a seguir ao selecionado */

.tm-resource-selection-actions {
    flex: 0 0 auto !important;

    display: grid !important;

    grid-template-columns:
        repeat(3, minmax(0,1fr)) !important;

    gap: 6px !important;

    padding:
        7px
        12px
        10px !important;

    border-bottom:
        1px solid rgba(255,255,255,.06);

    background:
        rgba(255,255,255,.02);
}


/* navegação vem depois */

.tm-resource-toolbar {
    flex: 0 0 auto !important;

    padding:
        10px
        12px
        6px !important;
}


.tm-resource-path {
    flex: 0 0 auto !important;

    padding:
        6px
        12px
        10px !important;
}


/* lista ocupa todo o espaço restante e faz scroll */

.tm-resource-entries {
    flex: 1 1 0 !important;

    min-height: 0 !important;
    height: 0 !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    border-top:
        1px solid rgba(255,255,255,.05);
}


/* selecionado mais compacto */

.tm-resource-selection code {
    display: block !important;

    max-height: 45px !important;

    overflow-y: auto !important;

    font-size: .72rem !important;
}


/* mobile */

@media (max-width: 520px) {

    .tm-resource-selection-actions {
        grid-template-columns:
            repeat(3,1fr) !important;
    }

}



/* ============================================================
   TM01GPT — SMARTPHONE / MOBILE
   ============================================================ */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}


/* ------------------------------------------------------------
   TABLET / SMARTPHONE
   ------------------------------------------------------------ */

@media (max-width: 900px) {

    .tm-main {
        width: 100%;
        max-width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }


    /*
     * Layout principal:
     * no mobile ficamos essencialmente com a conversa.
     */

    .tm-workspace,
    .tm-chat-layout,
    .tm-layout,
    .tm-grid {
        grid-template-columns: 1fr !important;
    }


    /*
     * Barras laterais deixam de consumir espaço.
     * Mais tarde podemos ligá-las a botões drawer.
     */

    .tm-resource-sidebar,
    .tm-resources-panel,
    .tm-left-sidebar,
    .tm-right-sidebar,
    .tm-workspace-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;

        width: min(88vw, 360px);
        max-width: 360px;

        z-index: 1000;

        background: var(--tm-panel, #11161f);

        box-shadow:
            0 0 24px
            rgba(0, 0, 0, 0.35);

        overflow-y: auto;

        transition:
            transform 0.22s ease;
    }


    .tm-left-sidebar,
    .tm-resource-sidebar,
    .tm-resources-panel {
        left: 0;

        transform:
            translateX(-105%);
    }


    .tm-right-sidebar,
    .tm-workspace-sidebar {
        right: 0;

        transform:
            translateX(105%);
    }


    .tm-left-sidebar.is-open,
    .tm-resource-sidebar.is-open,
    .tm-resources-panel.is-open,
    .tm-right-sidebar.is-open,
    .tm-workspace-sidebar.is-open {
        transform:
            translateX(0);
    }


    /*
     * Conversa principal.
     */

    .tm-chat {
        width: 100%;
        min-width: 0;
        max-width: 100%;

        border-radius: 12px;
    }


    .tm-chat-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;

        padding: 10px 12px;
    }


    .tm-chat-title {
        width: 100%;
    }


    .tm-chat-status {
        width: 100%;

        font-size: 12px;
    }


    /*
     * Selector Chat / Coder / Kiwi.
     */

    #tm-mode {
        width: 100%;

        min-height: 42px;

        font-size: 16px;
    }


    /*
     * Área de mensagens.
     */

    .tm-messages {
        width: 100%;

        padding-left: 8px;
        padding-right: 8px;
    }


    .tm-message {
        max-width: 94%;

        padding: 10px 12px;

        font-size: 15px;
        line-height: 1.45;

        word-break: break-word;
        overflow-wrap: anywhere;
    }


    .tm-message-user {
        max-width: 90%;
    }


    .tm-message-assistant {
        max-width: 96%;
    }


    .tm-message pre {
        max-width: 100%;

        overflow-x: auto;

        font-size: 13px;
    }


    .tm-message code {
        word-break: break-word;
    }


    /*
     * Composer.
     */

    .tm-chat-form {
        width: 100%;

        padding:
            8px
            8px
            calc(8px + env(safe-area-inset-bottom));
    }


    .tm-chat-input {
        width: 100%;

        min-height: 88px;
        max-height: 38vh;

        padding: 12px;

        font-size: 16px;
        line-height: 1.4;

        resize: vertical;
    }


    /*
     * 16px evita zoom automático
     * do browser em vários smartphones.
     */

    textarea,
    input,
    select,
    button {
        font-size: 16px;
    }


    .tm-chat-form-footer {
        display: grid;

        grid-template-columns:
            minmax(0, 1fr)
            auto;

        gap: 8px;

        align-items: center;
    }


    .tm-chat-hint {
        font-size: 11px;

        opacity: 0.65;
    }


    #send-button {
        min-width: 92px;
        min-height: 44px;

        padding: 9px 14px;

        border-radius: 9px;
    }


    /*
     * Controlos Coder.
     */

    .tm-coder-controls {
        display: grid;

        grid-template-columns: 1fr;

        gap: 10px;

        padding: 10px;
    }


    .tm-coder-control {
        width: 100%;
    }


    .tm-coder-control select,
    .tm-coder-control input {
        width: 100%;

        min-height: 42px;
    }


    /*
     * KIWI MOBILE
     */

    .tm-kiwi-controls {
        display: grid;

        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );

        gap: 8px;

        padding: 10px;
        margin-top: 8px;
    }


    .tm-kiwi-control {
        min-width: 0;
        width: 100%;
    }


    .tm-kiwi-control label {
        font-size: 11px;
    }


    .tm-kiwi-control select,
    .tm-kiwi-control input {
        width: 100%;

        min-width: 0;
        min-height: 42px;

        font-size: 16px;
    }


    .tm-kiwi-status {
        grid-column:
            1 / -1;

        width: 100%;

        margin: 0;

        padding: 7px 8px;

        text-align: left;

        font-size: 11px;
    }


    /*
     * Conversas / Projectos.
     */

    .tm-conversation-item,
    .tm-project-item {
        min-height: 44px;

        padding: 10px;
    }


    /*
     * Navegação superior.
     */

    .tm-tabs {
        width: 100%;

        overflow-x: auto;

        flex-wrap: nowrap;

        scrollbar-width: none;
    }


    .tm-tabs::-webkit-scrollbar {
        display: none;
    }


    .tm-tab {
        flex: 0 0 auto;

        min-height: 42px;

        padding: 9px 12px;
    }
}


/* ------------------------------------------------------------
   SMARTPHONES PEQUENOS
   ------------------------------------------------------------ */

@media (max-width: 520px) {

    .tm-main {
        padding-left: 4px;
        padding-right: 4px;
    }


    .tm-chat {
        border-radius: 8px;
    }


    .tm-chat-header {
        padding: 8px;
    }


    .tm-messages {
        padding-left: 4px;
        padding-right: 4px;
    }


    .tm-message {
        max-width: 98%;

        padding: 9px 10px;

        font-size: 14px;
    }


    .tm-message-user {
        max-width: 94%;
    }


    /*
     * Kiwi passa a uma coluna
     * em ecrãs muito estreitos.
     */

    .tm-kiwi-controls {
        grid-template-columns: 1fr;
    }


    .tm-kiwi-status {
        grid-column: 1;
    }


    .tm-chat-form-footer {
        grid-template-columns: 1fr;
    }


    .tm-chat-hint {
        order: 2;

        text-align: center;
    }


    #send-button {
        width: 100%;

        min-height: 46px;
    }


    .tm-chat-input {
        min-height: 96px;
    }
}


/* ------------------------------------------------------------
   SAFE AREA — ANDROID / IOS
   ------------------------------------------------------------ */

@supports (
    padding-bottom:
        env(safe-area-inset-bottom)
) {

    .tm-chat-form {
        padding-bottom:
            calc(
                8px
                +
                env(safe-area-inset-bottom)
            );
    }


    .tm-tabs {
        padding-left:
            env(safe-area-inset-left);

        padding-right:
            env(safe-area-inset-right);
    }
}


/* ------------------------------------------------------------
   TOUCH
   ------------------------------------------------------------ */

@media (hover: none) and (pointer: coarse) {

    button,
    select,
    input,
    textarea,
    .tm-tab,
    .tm-conversation-item {
        touch-action: manipulation;
    }


    button,
    .tm-tab {
        min-height: 44px;
    }
}


/* ============================================================
   TM01GPT — MOBILE WORKSPACE FINAL
   conversa prioritária
   ============================================================ */

@media (max-width: 760px) {

    html,
    body {
        width: 100%;
        max-width: 100%;

        overflow-x: hidden;
    }


    .tm-chat-page {
        padding: 4px !important;
    }


    .tm-chat-shell {
        width: 100% !important;
        max-width: 100% !important;

        min-height: calc(100dvh - 150px);

        border-radius: 10px !important;
    }


    /* --------------------------------------------------------
       CABEÇALHO DA WORKSTATION
       -------------------------------------------------------- */

    .tm-workstation-header {
        display: grid !important;

        grid-template-columns:
            minmax(0, 1fr)
            auto !important;

        gap: 6px !important;

        padding: 8px 10px !important;
    }


    .tm-workstation-title,
    .tm-workstation-mode {
        min-width: 0;
    }


    .tm-workstation-mode select,
    #tm-mode {
        width: 100% !important;
        max-width: 170px;

        min-height: 40px;
    }


    .tm-mode-status {
        display: none !important;
    }


    /* --------------------------------------------------------
       WORKSPACE
       -------------------------------------------------------- */

    .tm-ai-workspace {
        position: relative !important;

        display: block !important;

        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;

        overflow: visible !important;
    }


    /* --------------------------------------------------------
       RECURSOS:
       deixam de ocupar espaço permanente
       -------------------------------------------------------- */

    .tm-resource-sidebar {
        position: fixed !important;

        z-index: 5000 !important;

        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;

        width: min(88vw, 360px) !important;
        height: 100dvh !important;
        max-height: none !important;

        transform:
            translateX(-105%) !important;

        transition:
            transform .22s ease !important;

        border-right:
            1px solid rgba(255,255,255,.10) !important;

        border-bottom: 0 !important;

        box-shadow:
            12px 0 35px
            rgba(0,0,0,.45);

        overflow: hidden !important;
    }


    .tm-resource-sidebar.is-open {
        transform:
            translateX(0) !important;
    }


    /* --------------------------------------------------------
       CONVERSA PRINCIPAL
       -------------------------------------------------------- */

    .tm-conversation-workspace {
        width: 100% !important;

        min-width: 0 !important;
        min-height: 0 !important;

        display: flex !important;
        flex-direction: column !important;
    }


    .tm-conversation-stream,
    .tm-messages {
        width: 100% !important;

        min-height: 40vh;

        padding:
            10px
            8px
            18px !important;
    }


    .tm-message {
        max-width: 96% !important;

        font-size: .93rem !important;

        line-height: 1.48 !important;
    }


    .tm-message-user {
        max-width: 90% !important;
    }


    /* --------------------------------------------------------
       COMPOSER
       -------------------------------------------------------- */

    .tm-chat-form,
    .tm-composer {
        width: 100% !important;

        padding:
            8px
            8px
            calc(
                8px
                +
                env(safe-area-inset-bottom)
            ) !important;
    }


    .tm-chat-input,
    #message {
        width: 100% !important;

        min-height: 100px !important;
        max-height: 34vh !important;

        padding: 12px !important;

        font-size: 16px !important;

        box-sizing: border-box;
    }


    .tm-chat-form-footer,
    .tm-composer-footer {
        display: grid !important;

        grid-template-columns:
            minmax(0,1fr)
            auto !important;

        gap: 7px !important;

        align-items: center !important;
    }


    #send-button,
    .tm-send-button {
        min-width: 92px !important;
        min-height: 44px !important;
    }


    /* --------------------------------------------------------
       KIWI
       -------------------------------------------------------- */

    .tm-kiwi-controls {
        display: grid !important;

        grid-template-columns:
            repeat(2,minmax(0,1fr)) !important;

        gap: 7px !important;

        margin: 6px 8px !important;

        padding: 9px !important;
    }


    .tm-kiwi-controls[hidden] {
        display: none !important;
    }


    .tm-kiwi-control {
        min-width: 0 !important;
    }


    .tm-kiwi-control select,
    .tm-kiwi-control input {
        width: 100% !important;

        min-height: 40px !important;

        font-size: 16px !important;
    }


    .tm-kiwi-status {
        grid-column:
            1 / -1;

        width: 100% !important;

        margin: 0 !important;

        font-size: .70rem !important;
    }


    /* --------------------------------------------------------
       CODER
       -------------------------------------------------------- */

    .tm-coder-controls,
    .tm-coder-bar {
        display: grid !important;

        grid-template-columns:
            1fr !important;

        gap: 8px !important;
    }


    /* --------------------------------------------------------
       NAV SUPERIOR
       -------------------------------------------------------- */

    .tm-tabs {
        display: flex !important;

        width: 100% !important;

        flex-wrap: nowrap !important;

        overflow-x: auto !important;

        overscroll-behavior-x:
            contain;

        scrollbar-width: none;
    }


    .tm-tabs::-webkit-scrollbar {
        display: none;
    }


    .tm-tab {
        flex: 0 0 auto !important;

        white-space: nowrap;

        padding:
            9px
            11px !important;
    }


    /* --------------------------------------------------------
       BOTÃO MOBILE RECURSOS
       -------------------------------------------------------- */

    #tm-mobile-resources-button {
        position: fixed;

        left: 12px;
        bottom:
            calc(
                12px
                +
                env(safe-area-inset-bottom)
            );

        z-index: 4900;

        width: 46px;
        height: 46px;

        border: 1px solid
            rgba(255,255,255,.12);

        border-radius: 50%;

        background:
            #151d29;

        color: inherit;

        font-size: 21px;

        box-shadow:
            0 5px 18px
            rgba(0,0,0,.35);
    }


    #tm-mobile-resource-overlay {
        position: fixed;

        inset: 0;

        z-index: 4990;

        display: none;

        background:
            rgba(0,0,0,.52);
    }


    #tm-mobile-resource-overlay.is-open {
        display: block;
    }
}


/* ============================================================
   TELEFONES PEQUENOS
   ============================================================ */

@media (max-width: 520px) {

    .tm-workstation-header {
        grid-template-columns:
            1fr !important;
    }


    .tm-workstation-mode select,
    #tm-mode {
        max-width: none !important;
    }


    .tm-kiwi-controls {
        grid-template-columns:
            1fr !important;
    }


    .tm-chat-form-footer,
    .tm-composer-footer {
        grid-template-columns:
            1fr !important;
    }


    #send-button,
    .tm-send-button {
        width: 100% !important;
    }


    .tm-chat-hint {
        text-align: center;
    }
}

.tm-user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--tm-soft);
    font-size: 13px;
    white-space: nowrap;
}

.tm-user-logout {
    border: 1px solid var(--tm-border);
    border-radius: 7px;
    padding: 6px 10px;
    background: var(--tm-panel);
    color: var(--tm-muted);
    cursor: pointer;
}

.tm-user-logout:hover {
    color: var(--tm-text);
    border-color: var(--tm-accent);
}


/* ============================================================
   TM01GPT — MOBILE HEADER DEFINITIVO
   2026-10
   ============================================================ */

@media (max-width: 760px) {

    /* Cabeçalho principal numa única linha */
    .tm-header {
        min-height: 58px !important;
        height: auto !important;

        display: flex !important;
        flex-wrap: nowrap !important;

        align-items: center !important;
        justify-content: space-between !important;

        gap: 8px !important;

        padding:
            7px
            10px !important;
    }


    /* Marca */
    .tm-brand {
        flex: 0 1 auto !important;

        min-width: 0 !important;

        gap: 8px !important;
    }


    .tm-brand-mark {
        width: 36px !important;
        height: 36px !important;

        border-radius: 9px !important;

        font-size: 12px !important;
    }


    .tm-brand-name {
        font-size: 14px !important;
    }


    /*
     * No telefone não precisamos da segunda linha
     * "Inteligência interna".
     */
    .tm-brand-subtitle {
        display: none !important;
    }


    /*
     * Os atalhos grandes pertencem ao desktop.
     * A navegação já dá acesso ao Chat e Vídeo.
     */
    .tm-header-actions {
        display: none !important;
    }


    /*
     * Utilizador/logout deixa de ocupar uma linha
     * inteira no smartphone.
     */
    .tm-user-menu {
        display: none !important;
    }


    /*
     * Navegação continua disponível, mas ocupa apenas
     * o espaço restante da mesma linha.
     */
    #tm-nav {
        width: auto !important;

        min-width: 0 !important;

        flex:
            1
            1
            auto !important;

        order: initial !important;

        overflow: hidden;
    }


    .tm-tabs {
        width: 100% !important;

        display: flex !important;

        align-items: center !important;
        justify-content: flex-end !important;

        gap: 2px !important;

        padding: 0 !important;

        overflow-x: auto !important;

        scrollbar-width: none;
    }


    .tm-tabs::-webkit-scrollbar {
        display: none;
    }


    .tm-tab {
        flex: 0 0 auto !important;

        min-height: 36px !important;

        padding:
            0
            6px !important;

        font-size: 12px !important;
    }

}


/* Telefones particularmente estreitos */
@media (max-width: 420px) {

    .tm-header {
        padding:
            6px
            8px !important;
    }


    .tm-brand-mark {
        width: 34px !important;
        height: 34px !important;
    }


    .tm-brand-name {
        font-size: 13px !important;
    }


    .tm-tab {
        padding:
            0
            5px !important;

        font-size: 11px !important;
    }

}


/* ============================================================
   TM01GPT — MOBILE HEADER ESTÁVEL
   2026-10-03
   ============================================================ */

@media (max-width: 760px) {

    .tm-header {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;

        width: 100% !important;
        max-width: 100% !important;

        gap: 8px !important;

        overflow: hidden !important;
    }


    /* Marca fica sempre visível */
    .tm-brand {
        flex: 0 0 auto !important;
        min-width: auto !important;
        max-width: none !important;
    }


    /* Navegação recebe apenas o espaço que sobra */
    #tm-nav {
        display: block !important;

        flex: 1 1 0 !important;

        width: 0 !important;
        min-width: 0 !important;
        max-width: 100% !important;

        overflow: hidden !important;
    }


    /* Separadores começam à esquerda.
       Se não couberem, fazem scroll horizontal. */
    #tm-nav .tm-tabs {
        display: flex !important;

        width: 100% !important;
        max-width: 100% !important;

        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        align-items: center !important;

        gap: 2px !important;

        overflow-x: auto !important;
        overflow-y: hidden !important;

        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch;
    }


    #tm-nav .tm-tabs::-webkit-scrollbar {
        display: none !important;
    }


    #tm-nav .tm-tab {
        flex: 0 0 auto !important;

        min-width: 0 !important;
        min-height: 36px !important;

        padding: 0 6px !important;

        white-space: nowrap !important;

        font-size: 12px !important;
    }

}


@media (max-width: 420px) {

    #tm-nav .tm-tab {
        padding: 0 5px !important;
        font-size: 11px !important;
    }

}
