:root {
    --bg-black:    #000000;
    --grid-border: #323232;
    --text-main:   #ffffff;
    --text-dim:    #8e8e93;
    --apple-blue:  #0a84ff;
    --apple-orange:#ff9f0a;
    --apple-red:   #ff453a;
    --apple-green: #30d158;
    /* Superfícies (usadas em modal, bottom sheet, botões) */
    --s1: #1c1c1e;
    --s2: #2c2c2e;
    --s3: #3a3a3c;
    --s4: #48484a;
}

/* ── TEMA CLARO ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-black:    #f2f2f7;
    --grid-border: #c6c6c8;
    --text-main:   #000000;
    --text-dim:    #6d6d72;
    --apple-blue:  #007aff;
    --apple-orange:#ff9500;
    --apple-red:   #ff3b30;
    --apple-green: #34c759;
    --s1: #ffffff;
    --s2: #f2f2f7;
    --s3: #e5e5ea;
    --s4: #d1d1d6;
}
[data-theme="light"] body, [data-theme="light"] html { background-color: var(--bg-black); }
[data-theme="light"] .day                    { background: #fff; }
[data-theme="light"] .day.weekend            { background: #f9f9fb; }
[data-theme="light"] .other-month            { background: #f5f5f7; }
[data-theme="light"] .other-month.weekend    { background: #f2f2f4; }
[data-theme="light"] .weekday                { background: #f5f5f7; }
[data-theme="light"] .day.day-blue           { background: rgba(0,122,255,0.05);  border-top-color: rgba(0,122,255,0.4); }
[data-theme="light"] .day.day-orange         { background: rgba(255,149,0,0.05);  border-top-color: rgba(255,149,0,0.4); }
[data-theme="light"] .day.day-green          { background: rgba(52,199,89,0.05);  border-top-color: rgba(52,199,89,0.4); }
[data-theme="light"] .day.day-red            { background: rgba(255,59,48,0.05);  border-top-color: rgba(255,59,48,0.4); }
[data-theme="light"] .modal-card             { background: #fff; }
[data-theme="light"] .modal-close            { background: var(--s3); }
[data-theme="light"] .bottom-sheet          { background: #fff; border-color: var(--grid-border); }
[data-theme="light"] .bs-event-item         { background: var(--s2); }
[data-theme="light"] .btn-nav               { background: var(--s3); }
[data-theme="light"] .btn-action            { background: var(--s3); border-color: var(--grid-border); }
[data-theme="light"] .search-bar input      { background: var(--s3); border-color: var(--grid-border); }
[data-theme="light"] .search-clear          { background: var(--s4); }
[data-theme="light"] .agenda-view           { background: var(--bg-black); }
[data-theme="light"] .agenda-month-title    { background: rgba(242,242,247,0.95); }
[data-theme="light"] .agenda-row            { border-color: var(--grid-border); }
[data-theme="light"] .agenda-row:hover      { background: rgba(0,0,0,0.02); }
[data-theme="light"] .event.blue   { background: rgba(0,122,255,0.08); color: #0055cc; }
[data-theme="light"] .event.orange { background: rgba(255,149,0,0.08); color: #a05800; }
[data-theme="light"] .event.green  { background: rgba(52,199,89,0.08); color: #1a7a3a; }
[data-theme="light"] .event.red    { background: rgba(255,59,48,0.08); color: #cc1a12; }
[data-theme="light"] .legend-item.active    { background: var(--s3); }

/* ── SKIP LINK (acessibilidade) ──────────────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--apple-blue);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.2s;
}
.skip-link:focus { top: 8px; }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Transição suave ao trocar de tema */
*, *::before, *::after {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.1s ease;
}
/* Exceções — não anima animações de layout/transform */
.calendar-grid, .day, .modal-overlay, .bottom-sheet,
.slide-out-left, .slide-out-right, .slide-in,
.btn-nav, .btn-today, .btn-action, .btn-view, .btn-theme {
    transition: background-color 0.25s ease, border-color 0.25s ease,
                color 0.1s ease, opacity 0.2s ease, filter 0.15s ease,
                transform 0.15s ease;
}

body, html {
    background-color: var(--bg-black);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Trava a tela para não ter rolagem */
}

.calendar-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

header {
    height: 70px;
    padding: 0 30px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--grid-border);
    flex-shrink: 0;
}

.nav-controls { display: flex; align-items: center; gap: 15px; }

.btn-nav {
    background: #1c1c1e;
    border: none;
    color: var(--apple-blue);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Botão Hoje */
.btn-today {
    background: none;
    border: 1px solid var(--apple-blue);
    color: var(--apple-blue);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 10px;
    border-radius: 20px;
    transition: background 0.15s, color 0.15s;
    text-transform: lowercase;
    letter-spacing: 0.3px;
}
.btn-today:hover { background: var(--apple-blue); color: #000; }
.btn-today.hidden { display: none; }

/* Barra de busca */
.search-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 0 30px;
    height: 0;
    overflow: hidden;
    border-bottom: 1px solid transparent;
    transition: height 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
    flex-shrink: 0;
}
.search-bar.open {
    display: flex;
    height: 46px;
    border-color: var(--grid-border);
}

.search-bar input {
    flex: 1;
    background: #1c1c1e;
    border: 1px solid var(--grid-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    padding: 6px 12px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--apple-blue); }
.search-bar input::placeholder { color: var(--text-dim); }

.search-clear {
    background: #3a3a3c;
    border: none;
    color: var(--text-dim);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.search-clear:hover { background: #555; color: var(--text-main); }

.month-display { font-size: 24px; font-weight: 700; text-transform: lowercase; }
.month-display span { font-weight: 400; color: var(--text-dim); margin-left: 8px; }

/* Título central do header */
.header-title {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Área do logo no canto direito */
.logo-area {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo-placeholder {
    display: none;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 40px;
    border: 1px dashed var(--grid-border);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 1px;
}

/* GRID QUE OCUPA O RESTO DA TELA */
.calendar-grid {
    flex-grow: 1; /* Ocupa 100% do espaço abaixo do header */
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: 35px repeat(6, 1fr); /* Força 6 linhas iguais */
    width: 100%;
}

.weekday {
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-right: 1px solid var(--grid-border);
    border-bottom: 1px solid var(--grid-border);
    text-transform: uppercase;
}

/* Cabeçalhos de fim de semana levemente diferentes */
.weekday.weekend-header { color: #555; }

/* Domingo em vermelho */
.weekday.sunday-header { color: rgba(255, 69, 58, 0.6); }

/* Nome completo / abreviado dos dias — desktop mostra full, mobile mostra short */
.wd-short { display: none; }
.wd-full  { display: inline; }

.day {
    border-right: 1px solid var(--grid-border);
    border-bottom: 1px solid var(--grid-border);
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: background 0.15s;
}

/* Hover suave em dias com eventos */
.day.has-day-events:hover { background: rgba(255,255,255,0.03); }

/* Fins de semana com fundo levemente diferente */
.day.weekend { background: #030303; }
.day.weekend:hover { background: rgba(255,255,255,0.03); }

/* ── CORES POR TIPO DE EVENTO (fundo sutil + borda superior) ────────────── */
/* Hierarquia: red > orange > green > blue                                    */
.day.day-blue   { background: rgba(10,132,255,0.06);  border-top: 2px solid rgba(10,132,255,0.35); }
.day.day-orange { background: rgba(255,159,10,0.06);  border-top: 2px solid rgba(255,159,10,0.35); }
.day.day-green  { background: rgba(48,209,88,0.06);   border-top: 2px solid rgba(48,209,88,0.35);  }
.day.day-red    { background: rgba(255,69,58,0.06);   border-top: 2px solid rgba(255,69,58,0.35);  }

/* Hover sobre dias coloridos */
.day.day-blue:hover   { background: rgba(10,132,255,0.10); }
.day.day-orange:hover { background: rgba(255,159,10,0.10); }
.day.day-green:hover  { background: rgba(48,209,88,0.10);  }
.day.day-red:hover    { background: rgba(255,69,58,0.10);  }

.day-num {
    align-self: flex-end;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1;
    min-width: 24px;
    text-align: center;
}

/* Número de domingo em vermelho */
.day-num.sunday-num { color: var(--apple-red); }

/* Número do dia clicável (quando tem eventos) */
.day-num.has-events {
    cursor: pointer;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.day-num.has-events:hover { background: rgba(255,255,255,0.12); }

/* Círculo do dia atual */
.today .day-num {
    background: var(--apple-red) !important;
    color: white !important;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.today .day-num.has-events:hover { background: #ff6152 !important; }

.other-month { background: #050505; }
.other-month.weekend { background: #020202; }
.other-month .day-num { opacity: 0.3; }

/* Eventos Estilizados */
.event {
    margin-top: 5px;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event.blue { border-left: 3px solid var(--apple-blue); background: rgba(10, 132, 255, 0.1); color: #40a0ff; }
.event.orange { border-left: 3px solid var(--apple-orange); background: rgba(255, 159, 10, 0.1); color: #ffb340; }
.event.green { border-left: 3px solid var(--apple-green); background: rgba(48, 209, 88, 0.1); color: #66ff8d; }
.event.red { border-left: 3px solid var(--apple-red); background: rgba(255, 69, 58, 0.1); color: #ff6961; }

/* Eventos clicáveis */
.event { cursor: pointer; transition: filter 0.15s; }
.event:hover { filter: brightness(1.3); }

/* Indicador de mais eventos */
.more-events {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s;
}
.more-events:hover { color: var(--text-main); }

/* ── LEGENDA ─────────────────────────────────────────────────────────────── */
.legend-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 30px;
    height: 38px;
    border-bottom: 1px solid var(--grid-border);
    flex-shrink: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
    user-select: none;
}
.legend-item:hover { opacity: 0.8; }
.legend-item.active { border-color: var(--grid-border); }
.legend-item:not(.active) { opacity: 0.3; }

/* Ações da legenda (busca e PDF) */
.legend-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-action {
    background: #1c1c1e;
    border: 1px solid var(--grid-border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.btn-action:hover { background: #2c2c2e; color: var(--text-main); }

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-dot.blue   { background: var(--apple-blue); }
.legend-dot.orange { background: var(--apple-orange); }
.legend-dot.green  { background: var(--apple-green); }
.legend-dot.red    { background: var(--apple-red); }

/* ── ANIMAÇÕES DE TROCA DE MÊS ───────────────────────────────────────────── */
@keyframes slideOutLeft  { from { opacity:1; transform:translateX(0);     } to { opacity:0; transform:translateX(-40px); } }
@keyframes slideOutRight { from { opacity:1; transform:translateX(0);     } to { opacity:0; transform:translateX(40px);  } }
@keyframes slideIn       { from { opacity:0; transform:translateX(20px);  } to { opacity:1; transform:translateX(0);     } }

.slide-out-left  { animation: slideOutLeft  0.22s ease forwards; }
.slide-out-right { animation: slideOutRight 0.22s ease forwards; }
.slide-in        { animation: slideIn       0.25s ease forwards; }

/* ── MODAL ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-card {
    background: #1c1c1e;
    border: 1px solid var(--grid-border);
    border-radius: 16px;
    padding: 28px 32px;
    min-width: 300px;
    max-width: 420px;
    width: 90%;
    position: relative;
    animation: cardIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes cardIn { from { opacity:0; transform:scale(0.88); } to { opacity:1; transform:scale(1); } }

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: #3a3a3c;
    border: none;
    color: var(--text-dim);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.modal-close:hover { background: #555; }

.modal-date {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: capitalize;
    margin-bottom: 10px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
    line-height: 1.3;
}

.modal-badge {
    display: inline-block;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}
.modal-badge.blue   { background: rgba(10,132,255,0.15);  color: #40a0ff; }
.modal-badge.orange { background: rgba(255,159,10,0.15);  color: #ffb340; }
.modal-badge.green  { background: rgba(48,209,88,0.15);   color: #66ff8d; }
.modal-badge.red    { background: rgba(255,69,58,0.15);   color: #ff6961; }

.modal-desc {
    margin-top: 14px;
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.6;
}

/* Lista de eventos ("+X mais") */
.modal-list { display: none; }

.modal-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--grid-border);
}
.modal-list-item:last-child { border-bottom: none; }

.modal-list-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.modal-list-dot.blue   { background: var(--apple-blue); }
.modal-list-dot.orange { background: var(--apple-orange); }
.modal-list-dot.green  { background: var(--apple-green); }
.modal-list-dot.red    { background: var(--apple-red); }

.modal-list-title { font-size: 14px; color: var(--text-main); font-weight: 500; }
.modal-list-type  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ── DOTS (indicadores mobile no dia) ───────────────────────────────────── */
.day-dots {
    display: none; /* escondido no desktop */
    flex-direction: row;
    gap: 3px;
    margin-top: auto;
    padding-top: 4px;
    align-items: center;
}

.day-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.day-dot.blue   { background: var(--apple-blue); }
.day-dot.orange { background: var(--apple-orange); }
.day-dot.green  { background: var(--apple-green); }
.day-dot.red    { background: var(--apple-red); }

.dot-extra {
    font-size: 9px;
    color: var(--text-dim);
    line-height: 1;
}

/* ── BOTTOM SHEET (mobile) ───────────────────────────────────────────────── */
.bs-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 200;
}
.bs-overlay.active { display: block; animation: fadeIn 0.2s ease; }

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--grid-border);
    z-index: 201;
    padding: 12px 20px 40px;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
}
.bottom-sheet.active { transform: translateY(0); }

.bs-handle {
    width: 36px;
    height: 4px;
    background: #48484a;
    border-radius: 2px;
    margin: 0 auto 16px;
}

.bs-date {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: capitalize;
    margin-bottom: 14px;
    text-align: center;
}

.bs-events { display: flex; flex-direction: column; gap: 10px; }

.bs-event-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #2c2c2e;
    border-radius: 10px;
}

.bs-event-color {
    width: 4px;
    min-height: 36px;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}
.bs-event-color.blue   { background: var(--apple-blue); }
.bs-event-color.orange { background: var(--apple-orange); }
.bs-event-color.green  { background: var(--apple-green); }
.bs-event-color.red    { background: var(--apple-red); }

.bs-event-info { flex: 1; }

.bs-event-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
}

.bs-event-type {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}

.bs-event-desc {
    font-size: 12px;
    color: #8e8e93;
    margin-top: 6px;
    line-height: 1.5;
}

/* ── BOTÃO DE TEMA ───────────────────────────────────────────────────────── */
.btn-theme {
    background: none;
    border: 1px solid var(--grid-border);
    color: var(--text-dim);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    margin-right: 10px;
}
.btn-theme:hover { background: var(--s1); color: var(--text-main); }

/* ── VIEW TOGGLE ─────────────────────────────────────────────────────────── */
.view-toggle {
    display: flex;
    background: var(--s2);
    border: 1px solid var(--grid-border);
    border-radius: 8px;
    overflow: hidden;
    margin-left: 4px;
}
.btn-view {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    transition: background 0.15s, color 0.15s;
}
.btn-view.active { background: var(--s3); color: var(--text-main); }
.btn-view:hover  { color: var(--text-main); }

/* ── VISTA DE AGENDA / LISTA ─────────────────────────────────────────────── */
.agenda-view {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 0 0 40px;
}

.agenda-month { }

.agenda-month-title {
    position: sticky;
    top: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 24px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--grid-border);
    z-index: 5;
}

.agenda-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(50,50,50,0.4);
    transition: background 0.12s;
    cursor: default;
}
.agenda-row:hover { background: rgba(255,255,255,0.03); }

.agenda-date-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 36px;
    flex-shrink: 0;
}
.agenda-day {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}
.agenda-weekday {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: lowercase;
    margin-top: 2px;
}

.agenda-bar {
    width: 3px;
    min-height: 44px;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}
.agenda-bar.blue   { background: var(--apple-blue); }
.agenda-bar.orange { background: var(--apple-orange); }
.agenda-bar.green  { background: var(--apple-green); }
.agenda-bar.red    { background: var(--apple-red); }

.agenda-info { flex: 1; }
.agenda-title { font-size: 15px; font-weight: 600; color: var(--text-main); line-height: 1.3; }
.agenda-type  { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.agenda-desc  { font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }

.agenda-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ── CONTADOR REGRESSIVO ─────────────────────────────────────────────────── */
.countdown-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    flex-shrink: 0;
    align-self: center;
    letter-spacing: 0.2px;
}
.cd-today    { background: rgba(255,69,58,0.15);  color: var(--apple-red);   border: 1px solid rgba(255,69,58,0.3);  }
.cd-tomorrow { background: rgba(255,159,10,0.15); color: var(--apple-orange); border: 1px solid rgba(255,159,10,0.3);}
.cd-soon     { background: rgba(10,132,255,0.12); color: var(--apple-blue);  border: 1px solid rgba(10,132,255,0.3); }

/* Badge dentro do chip da grade */
.chip-cd {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── SKELETON LOADING ───────────────────────────────────────────────────── */
.skeleton-grid {
    display: none;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: 35px repeat(6, 1fr);
    flex-grow: 1;
    width: 100%;
}

@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.sk-header, .sk-cell {
    border-right: 1px solid var(--grid-border);
    border-bottom: 1px solid var(--grid-border);
    background: linear-gradient(
        90deg,
        var(--s1) 25%,
        var(--s2) 50%,
        var(--s1) 75%
    );
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
}
.sk-header { opacity: 0.5; }

/* ── FOCO ACESSÍVEL ─────────────────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
    border-radius: 4px;
}
button:focus:not(:focus-visible),
div:focus:not(:focus-visible) { outline: none; }

/* Micro-interação: botões de ação com scale ao clicar */
.btn-nav:active, .btn-today:active,
.btn-action:active, .btn-view:active,
.btn-theme:active { transform: scale(0.92); }

/* ── BUSCA — highlight e dim ─────────────────────────────────────────────── */
.day.search-match {
    outline: 2px solid var(--apple-blue);
    outline-offset: -2px;
    z-index: 1;
}
.day.search-match .day-num { color: var(--apple-blue); }

.day.search-dim {
    opacity: 0.25;
    pointer-events: none;
}

/* ── IMPRESSÃO / EXPORTAR PDF ────────────────────────────────────────────── */
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    body, html { background: #fff !important; color: #000 !important; overflow: visible !important; height: auto !important; }

    .calendar-main { height: auto !important; }

    header { border-bottom: 1px solid #ccc !important; }
    .btn-nav, .btn-today, .legend-actions,
    .search-bar, .bs-overlay, .bottom-sheet,
    .modal-overlay { display: none !important; }

    .month-display { color: #000 !important; }
    .month-display span { color: #555 !important; }
    .header-title { color: #000 !important; }

    .legend-bar { border-bottom: 1px solid #ccc !important; }
    .legend-item { color: #333 !important; border-color: #ccc !important; }

    .calendar-grid {
        flex-grow: 0 !important;
        height: auto !important;
        page-break-inside: avoid;
    }

    .weekday { color: #555 !important; border-color: #ddd !important; background: #f5f5f5 !important; }
    .weekday.sunday-header { color: #c00 !important; }

    .day { border-color: #ddd !important; background: #fff !important; min-height: 80px; }
    .day.weekend { background: #fafafa !important; }
    .day.day-red    { background: rgba(255,69,58,0.05) !important;  border-top: 2px solid rgba(200,0,0,0.3) !important; }
    .day.day-orange { background: rgba(255,159,10,0.05) !important; border-top: 2px solid rgba(200,120,0,0.3) !important; }
    .day.day-green  { background: rgba(48,209,88,0.05) !important;  border-top: 2px solid rgba(0,150,50,0.3) !important; }
    .day.day-blue   { background: rgba(10,132,255,0.05) !important; border-top: 2px solid rgba(0,80,200,0.3) !important; }

    .day-num { color: #000 !important; }
    .day-num.sunday-num { color: #c00 !important; }
    .today .day-num { background: #c00 !important; color: #fff !important; }

    .event { font-size: 9px !important; }
    .event.blue   { color: #0055cc !important; background: rgba(0,85,204,0.08) !important; }
    .event.orange { color: #994400 !important; background: rgba(153,68,0,0.08) !important; }
    .event.green  { color: #006622 !important; background: rgba(0,102,34,0.08) !important; }
    .event.red    { color: #cc0000 !important; background: rgba(204,0,0,0.08) !important; }

    .day-dots { display: none !important; }
    .search-dim { opacity: 1 !important; pointer-events: auto !important; }
    .search-match { outline: none !important; }
}

/* ── RESPONSIVIDADE MOBILE ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    header { padding: 0 15px; height: 60px; }
    .header-title { font-size: 13px; }
    .logo-img { height: 30px; }
    .logo-placeholder { width: 60px; height: 30px; font-size: 9px; }
    .btn-today { font-size: 10px; padding: 2px 8px; }

    .legend-bar { padding: 0 10px; gap: 6px; overflow-x: auto; height: 38px; }
    .legend-item { font-size: 10px; padding: 2px 5px; }

    .search-bar { padding: 0 15px; }
    .search-bar input { font-size: 12px; }

    /* Células do calendário: sem padding excessivo */
    .day { padding: 6px 5px; }
    .day-num { font-size: 12px; }

    /* No mobile: esconde os chips de evento e mostra os dots */
    .event, .more-events { display: none; }
    .day-dots { display: flex; }

    /* Dias da semana: mostra abreviado, esconde nome completo */
    .wd-full  { display: none; }
    .wd-short { display: inline; }

    /* Modal desktop some no mobile (usa bottom sheet) */
    .modal-overlay { display: none !important; }

    .modal-card { padding: 22px 20px; }
    .modal-title { font-size: 17px; }

    /* Agenda mobile */
    .agenda-row         { padding: 12px 16px; gap: 12px; }
    .agenda-day         { font-size: 18px; }
    .agenda-month-title { padding: 7px 16px; }
    .agenda-title       { font-size: 14px; }

    /* Botão tema mobile */
    .btn-theme { width: 26px; height: 26px; font-size: 12px; margin-right: 6px; }

    /* View toggle mobile */
    .btn-view { padding: 3px 6px; font-size: 13px; }

    /* Contador no bottom sheet */
    .countdown-badge { font-size: 10px; padding: 2px 7px; }
}