/* TechTools Calendar — dark theme, mobile-first */
:root {
    --primary-bg: #0a0a0f;
    --secondary-bg: #141419;
    --card-bg: #1a1a24;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --danger: #ef4444;
    --brain: #8b5cf6;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition-fast: 0.15s ease;
    --tt-topnav-h: 64px; /* seed; tt-navbar.js publishes the exact value at runtime */
    color-scheme: dark;  /* native date/time inputs render dark */
}

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

/* The HTML `hidden` attribute must ALWAYS win — author display rules on .gate/.btn
   etc. otherwise override the UA's [hidden]{display:none} and "hidden" elements
   stay on screen (bit this exact page: gate + admin chip showed for everyone). */
[hidden] { display: none !important; }

html, body { overflow-x: clip; } /* never overflow-x:hidden — it breaks the sticky navbar */

body {
    background: var(--primary-bg);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.55rem 1rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn:hover { background: #232330; border-color: rgba(255, 255, 255, 0.2); }
.btn-primary { background: var(--accent-gradient); border: none; }
.btn-primary:hover { filter: brightness(1.1); background: var(--accent-gradient); }
.btn-danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }
.btn-icon { min-width: 44px; padding: 0.55rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.chip[aria-pressed="true"] { border-color: var(--brain); color: #c4b5fd; background: rgba(139, 92, 246, 0.12); }
.chip[aria-pressed="false"] { opacity: 0.55; }

/* ---------- signed-out gate ---------- */
.gate { display: flex; justify-content: center; padding: 8vh var(--spacing-sm) 4vh; }
.gate-card {
    max-width: 480px;
    text-align: center;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.2rem 1.6rem;
}
.gate-icon {
    width: 74px; height: 74px;
    margin: 0 auto 1.1rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
}
.gate-card h1 { font-size: 1.45rem; margin-bottom: 0.6rem; }
.gate-card p { color: var(--text-secondary); margin-bottom: 1.4rem; line-height: 1.55; }

/* ---------- toolbar ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}
.toolbar-nav { display: flex; gap: var(--spacing-xs); }
.month-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    min-width: 10rem;
}
.toolbar-actions { display: flex; gap: var(--spacing-sm); margin-left: auto; }

/* ---------- month grid ---------- */
.cal-wrap {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
/* minmax(0,1fr), NOT 1fr — grid items' min-width:auto otherwise lets long event
   chips expand their column and the 7 tracks drift out of line with the headers */
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day { min-width: 0; }
.weekdays span {
    padding: 0.5rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.day {
    position: relative;
    min-height: 74px;
    padding: 0.3rem;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background var(--transition-fast);
}
.day:hover { background: rgba(255, 255, 255, 0.04); }
.day.other { color: var(--text-muted); background: rgba(0, 0, 0, 0.25); }
.day.selected { background: rgba(99, 102, 241, 0.14); box-shadow: inset 0 0 0 1px var(--accent-primary); }
.day .num {
    font-size: 0.8rem;
    font-weight: 600;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.day.today .num { background: var(--accent-gradient); }
.ev-chip {
    display: block;
    width: 100%;
    font-size: 0.68rem;
    line-height: 1.35;
    padding: 1px 4px;
    border-radius: 4px;
    border-left: 3px solid var(--ev, var(--accent-primary));
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ev-chip.decision { border-left-style: dashed; border-left-color: var(--brain); color: #c4b5fd; }
.ev-more { font-size: 0.65rem; color: var(--text-muted); padding-left: 4px; }
.dots { display: none; gap: 3px; flex-wrap: wrap; padding: 2px 0 0 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ev, var(--accent-primary)); }
.dot.decision { background: transparent; border: 1.5px dashed var(--brain); }

/* ---------- agenda ---------- */
.agenda { margin-top: var(--spacing-lg); }
.agenda-title { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--spacing-sm); }
.agenda-list { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.agenda-empty { color: var(--text-muted); font-size: 0.9rem; padding: var(--spacing-sm) 0; }
.ag-item {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    width: 100%;
    text-align: left;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--ev, var(--accent-primary));
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
    min-height: 44px;
    transition: background var(--transition-fast);
}
.ag-item:hover { background: #232330; }
.ag-item.decision { border-left-style: dashed; border-left-color: var(--brain); }
.ag-time {
    flex: 0 0 auto;
    min-width: 6.2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    padding-top: 2px;
}
.ag-main { flex: 1; min-width: 0; }
.ag-title-line, .ag-sub { display: block; }
.ag-title-line { font-weight: 600; font-size: 0.95rem; overflow-wrap: anywhere; }
.ag-title-line .fa-brain { color: var(--brain); font-size: 0.8em; margin-left: 0.3rem; }
.ag-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }

/* ---------- modals (must clear the shared navbar/auth modal layers) ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    z-index: calc(var(--tt-z-modal, 1000) + 10);
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    max-height: min(88vh, 88dvh);
    display: flex;
    flex-direction: column;
}
.modal-wide { max-width: 720px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-head h3 { font-size: 1.05rem; overflow-wrap: anywhere; }
.modal-head .fa-brain { color: var(--brain); }
.modal-body { padding: 1rem 1.1rem; overflow-y: auto; }
.modal-foot {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.85rem 1.1rem;
    border-top: 1px solid var(--border-color);
}
.modal-foot .spacer { flex: 1; }
.brain-note { font-size: 0.8rem; color: #c4b5fd; margin-bottom: 0.7rem; }

.field { display: block; margin-bottom: 0.85rem; }
.field > span { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.3rem; }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.7rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.92rem;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent-primary); }
.field-row { display: flex; gap: var(--spacing-sm); align-items: flex-end; }
.field-row .field { flex: 1; margin-bottom: 0.85rem; }
.field.checkbox { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; flex: 0 0 auto; }
.field.checkbox input { width: 20px; height: 20px; accent-color: var(--accent-primary); }
.field.checkbox span { margin: 0; font-size: 0.88rem; color: var(--text-primary); font-weight: 500; }

/* dark-theme select/option guard (no <select> in this tool today, but the rule is
   mandatory if one is ever added — native options don't inherit the dark theme) */
select option { background-color: #1a1a24; color: #ffffff; }

.swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.swatch {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.swatch[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 2px var(--primary-bg), 0 0 0 4px rgba(255,255,255,0.35); }

/* decision detail body — server markdown rendered through a safe minimal renderer */
.decision-body { font-size: 0.92rem; line-height: 1.65; color: var(--text-secondary); }
.decision-body h1, .decision-body h2, .decision-body h3 { color: var(--text-primary); margin: 1rem 0 0.45rem; font-size: 1.02rem; }
.decision-body h1 { font-size: 1.15rem; margin-top: 0.2rem; }
.decision-body p { margin-bottom: 0.7rem; }
.decision-body ul { margin: 0 0 0.7rem 1.2rem; }
.decision-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-size: 0.86em;
    color: #c4b5fd;
    overflow-wrap: anywhere;
}
.decision-body pre {
    background: #0d0d14;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.7rem;
    overflow-x: auto;
    margin-bottom: 0.7rem;
}
.decision-body pre code { background: none; padding: 0; }
.decision-body a { color: var(--accent-primary); }
.decision-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.8rem; }

.foot { text-align: center; padding: 2rem 0 1rem; color: var(--text-muted); font-size: 0.8rem; }
.foot a { color: var(--accent-primary); text-decoration: none; }

/* ---------- phone (≤640px) ---------- */
@media (max-width: 640px) {
    .page { padding: var(--spacing-sm); }
    .toolbar { gap: var(--spacing-xs); }
    .month-title { order: -1; flex-basis: 100%; text-align: left; font-size: 1.1rem; }
    .toolbar-actions { margin-left: auto; }
    .day { min-height: 58px; padding: 0.2rem; }
    .ev-chip, .ev-more { display: none; }   /* chips → dots on phones; detail lives in the agenda */
    .dots { display: flex; }
    .ag-time { min-width: 4.6rem; }
    .modal-overlay { padding: var(--spacing-sm); align-items: flex-end; }
    .modal { max-height: 92dvh; }
}

@media (max-width: 768px) {
    .animated-element { animation: none !important; transform: none !important; will-change: auto !important; }
}
