  :root {
    --bg: #ffffff;
    --bg2: #f5f5f3;
    --bg3: #eeede9;
    --text: #1a1a18;
    --text2: #6b6b67;
    --text3: #9e9e9a;
    --border: rgba(0, 0, 0, 0.12);
    --border2: rgba(0, 0, 0, 0.22);
    --radius: 10px;
    --radius-sm: 6px;
    --tow: #0F6E56;
    --tow-bg: #E1F5EE;
    --gym: #185FA5;
    --gym-bg: #E6F1FB;
    --task-green: #1D9E75;
    --amber: #854F0B;
    --amber-bg: #FAEEDA;
    --status-active: #1D9E75;
    --status-paused: #854F0B;
    --status-paused-bg: #FAEEDA;
    --status-done: #9e9e9a;
    --status-prospect: #185FA5;
    --status-prospect-bg: #E6F1FB;
    --security: #1a6b3a;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #1c1c1a;
      --bg2: #252523;
      --bg3: #2e2e2b;
      --text: #f0ede8;
      --text2: #9e9e9a;
      --text3: #6b6b67;
      --border: rgba(255, 255, 255, 0.1);
      --border2: rgba(255, 255, 255, 0.2);
      --tow: #5DCAA5;
      --tow-bg: #083d2e;
      --gym: #85B7EB;
      --gym-bg: #0c2e50;
      --amber: #EF9F27;
      --amber-bg: #3d2800;
      --status-paused: #EF9F27;
      --status-paused-bg: #3d2800;
      --status-prospect: #85B7EB;
      --status-prospect-bg: #0c2e50;
    }
  }

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

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg3);
    color: var(--text);
    min-height: 100vh;
  }

  .app {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
  }

  h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
  }

  .subtitle {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 12px;
  }

  /* ── Header / Ollama bar ── */
  .status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
  }

  .ollama-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 0.5px solid var(--border);
    background: var(--bg);
  }

  .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .dot-ok {
    background: #1D9E75;
  }

  .dot-err {
    background: #E24B4A;
  }

  .dot-wait {
    background: #EF9F27;
    animation: pulse 1s infinite;
  }

  @keyframes pulse {

    0%,
    100% {
      opacity: 1
    }

    50% {
      opacity: 0.4
    }
  }

  .model-input {
    font-size: 12px;
    font-family: monospace;
    padding: 5px 10px;
    border: 0.5px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    width: 160px;
  }

  .btn-sm {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 0.5px solid var(--border2);
    background: none;
    cursor: pointer;
    color: var(--text);
    transition: background 0.15s;
  }

  .btn-sm:hover {
    background: var(--bg2);
  }

  /* ── Tabs ── */
  .tabs {
    display: flex;
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
  }

  .tab {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text2);
    border-bottom: 2px solid transparent;
    margin-bottom: -0.5px;
    transition: color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tab.active {
    color: var(--text);
    border-bottom-color: var(--text);
    font-weight: 500;
  }

  .tab-panel {
    display: none;
  }

  .tab-panel.active {
    display: block;
  }

  /* ── Banner / stats ── */
  .banner {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
  }

  .stat .n {
    font-size: 24px;
    font-weight: 600;
  }

  .stat .l {
    font-size: 11px;
    color: var(--text2);
    margin-top: 2px;
  }

  /* ── Add row / inputs ── */
  .add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
  }

  .add-input {
    flex: 1;
    min-width: 140px;
    font-size: 13px;
    padding: 9px 14px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
  }

  .add-input:focus {
    outline: none;
    border-color: var(--border2);
  }

  select.add-input {
    cursor: pointer;
    max-width: 200px;
  }

  .btn-add {
    padding: 9px 18px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.15s;
    white-space: nowrap;
  }

  .btn-add:hover {
    opacity: 0.85;
  }

  /* ── Grid / cards ── */
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
  }

  .card {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
  }

  .card:hover {
    border-color: var(--border2);
    transform: translateY(-1px);
  }

  .card.selected {
    border: 1.5px solid var(--gym);
  }

  .card.drag-over {
    border-color: var(--gym);
    opacity: 0.7;
    transform: scale(0.97);
  }

  .card.has-task {
    border-left: 3px solid var(--task-green);
  }

  .card.status-activo {
    border-left: 3px solid var(--status-active);
  }

  .card.status-pausado {
    border-left: 3px solid var(--status-paused);
  }

  .card.status-terminado {
    border-left: 3px solid var(--status-done);
    opacity: 0.75;
  }

  .card.status-prospecto {
    border-left: 3px solid var(--status-prospect);
  }

  .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
  }

  .av-tow {
    background: var(--tow-bg);
    color: var(--tow);
  }

  .av-gym {
    background: var(--gym-bg);
    color: var(--gym);
  }

  .av-dev {
    background: var(--amber-bg);
    color: var(--amber);
  }

  .card-name {
    font-size: 14px;
    font-weight: 500;
  }

  .card-meta {
    font-size: 12px;
    color: var(--text2);
    margin-top: 2px;
  }

  .badges {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
  }

  .b-task {
    background: var(--tow-bg);
    color: var(--tow);
  }

  .b-notask {
    background: var(--bg2);
    color: var(--text2);
  }

  .b-note {
    background: var(--amber-bg);
    color: var(--amber);
  }

  .b-activo {
    background: var(--tow-bg);
    color: var(--tow);
  }

  .b-pausado {
    background: var(--status-paused-bg);
    color: var(--status-paused);
  }

  .b-terminado {
    background: var(--bg2);
    color: var(--text3);
  }

  .b-prospecto {
    background: var(--status-prospect-bg);
    color: var(--status-prospect);
  }

  .b-externo {
    background: var(--bg2);
    color: var(--text2);
  }

  .b-interno {
    background: var(--gym-bg);
    color: var(--gym);
  }

  .b-borrador {
    background: var(--bg2);
    color: var(--text2);
  }

  .b-publicada {
    background: var(--tow-bg);
    color: var(--tow);
  }

  .b-revision {
    background: var(--amber-bg);
    color: var(--amber);
  }

  .b-completado {
    background: var(--gym-bg);
    color: var(--gym);
  }

  /* ── Detail panel ── */
  .detail {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
  }

  .dh {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 1.25rem;
  }

  .dname {
    font-size: 18px;
    font-weight: 600;
  }

  .dsub {
    font-size: 12px;
    color: var(--text2);
    margin-top: 3px;
  }

  .slabel {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
    margin-top: 1.25rem;
  }

  .divider {
    height: 0.5px;
    background: var(--border);
    margin: 1rem 0;
  }

  .section-header {
    font-size: 15px;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    padding-bottom: 8px;
    border-bottom: 0.5px solid var(--border);
  }

  /* ── Form elements ── */
  .task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
  }

  .toggle {
    width: 38px;
    height: 22px;
    border-radius: 11px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
  }

  .toggle.on {
    background: var(--task-green);
  }

  .toggle.off {
    background: var(--border2);
  }

  .toggle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 3px;
    transition: left 0.2s;
  }

  .toggle.on::after {
    left: 19px;
  }

  .toggle.off::after {
    left: 3px;
  }

  .toggle-label {
    font-size: 13px;
  }

  textarea.note {
    width: 100%;
    min-height: 300px;
    resize: vertical;
    font-size: 13px;
    font-family: inherit;
    padding: 10px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg2);
    color: var(--text);
    line-height: 1.6;
  }

  textarea.note:focus {
    outline: none;
    border-color: var(--border2);
  }

  input.task-desc {
    width: 100%;
    font-size: 13px;
    font-family: inherit;
    padding: 9px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg2);
    color: var(--text);
  }

  input.task-desc:focus {
    outline: none;
    border-color: var(--border2);
  }

  input.field-in {
    width: 100%;
    font-size: 13px;
    font-family: inherit;
    padding: 9px 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg2);
    color: var(--text);
  }

  input.field-in:focus {
    outline: none;
    border-color: var(--border2);
  }

  select.field-in {
    cursor: pointer;
  }

  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  @media (max-width: 600px) {
    .form-row {
      grid-template-columns: 1fr;
    }
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .form-group label {
    font-size: 11px;
    color: var(--text2);
    font-weight: 500;
  }

  /* ── Student schedules ── */
  .schedule-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
  }

  .schedule-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text);
  }

  .schedule-chip .chip-del {
    cursor: pointer;
    color: var(--text3);
    font-size: 13px;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
  }

  .schedule-chip .chip-del:hover {
    color: var(--danger, #e05);
  }

  .quick-schedule-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }

  .btn-quick-sched {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
  }

  .btn-quick-sched:hover {
    background: var(--tow-bg, #e8f0ff);
    color: var(--tow, #3366cc);
  }

  .add-schedule-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
  }

  @keyframes highlight-flash {

    0%,
    100% {
      background: transparent;
    }

    30% {
      background: rgba(255, 200, 60, 0.3);
    }
  }

  .highlight-field {
    animation: highlight-flash 1.5s ease;
    border-radius: var(--radius-sm);
  }

  /* ── Buttons ── */
  .actions {
    display: flex;
    gap: 8px;
    margin-top: 1.25rem;
    flex-wrap: wrap;
  }

  .btn {
    padding: 8px 18px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--border2);
    background: none;
    cursor: pointer;
    color: var(--text);
    transition: background 0.15s;
  }

  .btn:hover {
    background: var(--bg2);
  }

  .btn-primary {
    background: var(--text);
    color: var(--bg);
    border-color: transparent;
    font-weight: 500;
  }

  .btn-primary:hover {
    opacity: 0.85;
    background: var(--text);
  }

  .btn-ai {
    border-color: var(--task-green);
    color: var(--tow);
  }

  .btn-ai:hover {
    background: var(--tow-bg);
  }

  .btn-ai:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  .btn-del {
    color: var(--text2);
    font-size: 12px;
    margin-left: auto;
  }

  .btn-danger {
    color: #E24B4A;
    border-color: #E24B4A;
  }

  .btn-danger:hover {
    background: rgba(226, 75, 74, 0.1);
  }

  /* ── AI box ── */
  .ai-box {
    margin-top: 1rem;
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 13px;
    line-height: 1.75;
    white-space: pre-wrap;
  }

  .ai-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--tow);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .ai-model-tag {
    font-weight: 400;
    color: var(--text3);
    font-size: 10px;
  }

  .ai-placeholder {
    color: var(--text2);
    font-style: italic;
  }

  /* ── History entries ── */
  .hist-entry {
    font-size: 12px;
    color: var(--text2);
    padding: 6px 0;
    border-bottom: 0.5px solid var(--border);
  }

  .hist-date {
    color: var(--text3);
    font-size: 11px;
    margin-right: 6px;
  }

  /* ── Misc ── */
  .empty {
    text-align: center;
    padding: 3rem;
    color: var(--text2);
    font-size: 14px;
    grid-column: 1/-1;
  }

  code {
    font-family: monospace;
    background: var(--bg2);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
  }

  /* ── Filter bar ── */
  .filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
  }

  .filter-bar select {
    font-size: 12px;
    padding: 6px 10px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
  }

  /* ── Client list ── */
  .client-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1.5rem;
  }

  .client-row {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
  }

  .client-row:hover {
    border-color: var(--border2);
  }

  .client-row.expanded {
    border-color: var(--gym);
  }

  .client-row-header {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .client-row-name {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
  }

  .client-row-contact {
    font-size: 12px;
    color: var(--text2);
  }

  .client-expand {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .client-expand label {
    font-size: 11px;
    color: var(--text2);
    margin-bottom: 2px;
    display: block;
  }

  /* ── Week list ── */
  .week-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
  }

  .week-item {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  .week-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
  }

  .week-header:hover {
    background: var(--bg2);
  }

  .week-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    width: 28px;
  }

  .week-title-text {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
  }

  .week-body {
    padding: 12px 14px;
    border-top: 0.5px solid var(--border);
    background: var(--bg2);
    display: none;
    flex-direction: column;
    gap: 10px;
  }

  .week-body.open {
    display: flex;
  }

  /* ── Enrollment cards ── */
  .enroll-card {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
    margin-bottom: 8px;
  }

  .enroll-card:hover {
    border-color: var(--border2);
  }

  .enroll-card.expanded {
    border-color: var(--gym);
  }

  .enroll-header {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .enroll-body {
    margin-top: 12px;
    flex-direction: column;
    gap: 8px;
    display: none;
  }

  .enroll-body.open {
    display: flex;
  }

  /* ── Links section ── */
  .links-section {
    margin-top: 1rem;
  }

  .link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 0.5px solid var(--border);
    font-size: 13px;
  }

  .link-row a {
    color: var(--gym);
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .link-row a:hover {
    text-decoration: underline;
  }

  .link-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
  }

  .link-del:hover {
    color: #E24B4A;
  }

  .link-add-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  .link-add-row input {
    font-size: 12px;
    padding: 6px 10px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg2);
    color: var(--text);
    flex: 1;
    min-width: 100px;
  }

  .link-add-row input:focus {
    outline: none;
    border-color: var(--border2);
  }

  .link-none {
    color: var(--text2);
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
  }

  /* ── Esta semana ── */
  .esem-day-group {
    margin-bottom: 1.25rem;
  }

  .esem-day-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
  }

  .esem-class-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    flex-wrap: wrap;
  }

  .esem-done {
    opacity: 0.6;
  }

  .esem-class-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    min-width: 44px;
    flex-shrink: 0;
  }

  .esem-class-info {
    flex: 1;
    font-size: 13px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    min-width: 100px;
  }

  .esem-class-student {
    font-weight: 500;
  }

  .esem-class-topic {
    color: var(--text2);
    font-size: 12px;
  }

  .esem-notask-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 0.5px solid var(--border);
  }

  /* ── Student classes / project meetings ── */
  .class-row {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 4px;
  }

  .class-row-done {
    opacity: 0.65;
  }

  .class-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .class-row-date {
    font-size: 12px;
    color: var(--text2);
    flex-shrink: 0;
  }

  .class-row-topic {
    flex: 1;
    font-size: 13px;
    min-width: 80px;
  }

  .class-notes-after {
    font-size: 12px;
    color: var(--text2);
    margin-top: 6px;
    padding: 6px 8px;
    background: var(--bg);
    border-radius: 4px;
    border-left: 2px solid var(--border2);
  }

  /* ── Calendar shared ── */
  .cal-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
  }

  .cal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
  }

  .cal-nav-label {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
  }

  .cal-view-toggle {
    display: flex;
    gap: 4px;
  }

  /* ── Calendar week view ── */
  .cal-grid {
    display: grid;
    grid-template-columns: 52px repeat(7, 1fr);
    min-width: 620px;
  }

  .cal-corner {
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border);
  }

  .cal-day-head {
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border);
    padding: 8px 4px;
    font-size: 11px;
    text-align: center;
    color: var(--text2);
    font-weight: 600;
  }

  .cal-day-num {
    font-size: 16px;
    font-weight: 700;
    display: block;
    color: var(--text);
  }

  .cal-time {
    font-size: 11px;
    color: var(--text3);
    padding: 4px 6px;
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
    background: var(--bg2);
    text-align: right;
    min-height: 48px;
    display: flex;
    align-items: flex-start;
    padding-top: 6px;
    white-space: nowrap;
  }

  .cal-cell {
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
    min-height: 48px;
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg);
  }

  .cal-ev {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.6;
  }

  .cal-ev-class {
    background: var(--tow-bg);
    color: var(--tow);
  }

  .cal-ev-class:hover {
    opacity: 0.75;
  }

  .cal-ev-meet {
    background: var(--gym-bg);
    color: var(--gym);
  }

  .cal-ev-meet:hover {
    opacity: 0.75;
  }

  /* ── Calendar month view ── */
  .cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-width: 560px;
  }

  .cal-month-head {
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border);
    padding: 6px 8px;
    font-size: 11px;
    text-align: center;
    color: var(--text2);
    font-weight: 600;
  }

  .cal-month-cell {
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
    min-height: 84px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg);
  }

  .cal-month-cell.cal-month-out {
    background: var(--bg2);
    opacity: 0.45;
  }

  .cal-month-cell.cal-month-today {
    background: var(--gym-bg);
  }

  .cal-month-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    line-height: 1;
    margin-bottom: 2px;
  }

  .cal-today-num {
    background: var(--gym);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
  }

  /* ── Libro de clases ── */
  .libro-section-header {
    font-size: 15px;
    font-weight: 600;
    margin: 1.5rem 0 0;
    padding-bottom: 8px;
    border-bottom: 0.5px solid var(--border);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .libro-body {
    display: none;
    padding-top: 1rem;
  }

  .libro-body.open {
    display: block;
  }

  .libro-table-wrap {
    overflow-x: auto;
    margin-top: 8px;
  }

  .libro-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .libro-table th,
  .libro-table td {
    padding: 6px 10px;
    border: 0.5px solid var(--border);
    text-align: left;
  }

  .libro-table th {
    background: var(--bg2);
    font-weight: 600;
    font-size: 11px;
    color: var(--text2);
  }

  .libro-table tr:hover td {
    background: var(--bg2);
  }

  /* Libro — view toggle & active state */
  .libro-view-toggle {
    display: flex;
    gap: 4px;
  }

  .btn-sm-active {
    background: var(--gym);
    color: #fff;
    border-color: var(--gym);
  }

  .btn-sm-active:hover {
    background: var(--gym);
  }

  /* Class log fields (post-class pedagogical fields) */
  .class-log-fields {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg2);
    border-radius: 6px;
    border-left: 2px solid var(--gym);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .class-log-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 2px;
  }

  .class-log-ta {
    min-height: 54px;
    font-size: 12px;
  }

  /* History modal */
  .hist-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hist-modal {
    background: var(--bg);
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    position: relative;
  }

  .hist-modal-date {
    font-size: 13px;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 14px;
  }

  .hist-modal-content {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
  }

  .hist-modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text3);
    padding: 2px 6px;
    border-radius: 4px;
  }

  .hist-modal-close:hover {
    background: var(--bg2);
    color: var(--text);
  }

  .hist-ver-mas {
    background: none;
    border: none;
    color: var(--gym);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
  }

  .hist-ver-mas:hover {
    text-decoration: underline;
  }

  /* Mini calendar (classes / meetings) */
  .mini-cal {
    margin: 8px 0 10px;
    border: 0.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
  }

  .mini-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
  }

  .mini-cal-nav-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }

  .mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
  }

  .mini-cal-head {
    font-size: 10px;
    font-weight: 700;
    color: var(--text3);
    text-align: center;
    padding: 4px 2px;
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
  }

  .mini-cal-day {
    min-height: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 12px;
    color: var(--text2);
    padding: 3px 1px;
    border-right: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
    cursor: default;
  }

  .mini-cal-day:nth-child(7n) {
    border-right: none;
  }

  .mini-cal-day.mini-out {
    opacity: 0.3;
  }

  .mini-cal-day.mini-today {
    font-weight: 700;
    color: var(--gym);
  }

  .mini-cal-day.mini-has-event {
    cursor: pointer;
    color: var(--text);
  }

  .mini-cal-day.mini-has-event:hover {
    background: var(--bg2);
  }

  .mini-cal-day.mini-selected {
    background: var(--gym-bg);
  }

  .mini-cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .mini-cal-dot-class {
    background: var(--gym);
  }

  .mini-cal-dot-meeting {
    background: var(--tow);
  }

  /* Inline name editing */
  .editable-name {
    cursor: pointer;
    border-bottom: 1.5px dotted var(--border2);
    transition: border-color 0.15s;
  }

  .editable-name:hover {
    border-bottom-color: var(--gym);
  }

  .editable-name-input {
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    color: inherit;
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--gym);
    outline: none;
    width: 100%;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  /* General notes scratchpad */
  .gn-scratchpad {
    margin-bottom: 1rem;
    padding: 12px 14px;
    background: var(--bg2);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--border);
  }

  .gn-clean-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .gn-active-note {
    font-size: 16px;
    line-height: 1.6;
    padding: 14px 16px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text1);
    white-space: pre-wrap;
    min-height: 56px;
  }

  .gn-active-note--empty {
    color: var(--text3);
    font-style: italic;
  }

  .gn-active-textarea {
    width: 100%;
    min-height: 96px;
    font-size: 15px;
    line-height: 1.6;
    padding: 12px 14px;
    box-sizing: border-box;
    resize: vertical;
  }

  /* Vista oficial checkbox column */
  .libro-row-check {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--gym);
  }

  /* ── General notes — Markdown rendering ── */
  .gn-active-note--md {
    font-size: 15px;
    line-height: 1.7;
  }

  .gn-active-note--md h1,
  .gn-active-note--md h2,
  .gn-active-note--md h3 {
    color: var(--text);
    font-weight: 600;
    margin: 0.75em 0 0.35em;
    line-height: 1.3;
  }

  .gn-active-note--md h1 {
    font-size: 1.25em;
  }

  .gn-active-note--md h2 {
    font-size: 1.1em;
  }

  .gn-active-note--md h3 {
    font-size: 1em;
  }

  .gn-active-note--md p {
    color: var(--text);
    margin: 0.45em 0;
  }

  .gn-active-note--md ul,
  .gn-active-note--md ol {
    color: var(--text);
    padding-left: 1.4em;
    margin: 0.45em 0;
  }

  .gn-active-note--md li {
    margin: 0.2em 0;
  }

  .gn-active-note--md code {
    font-family: monospace;
    background: var(--bg2);
    color: var(--text);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
  }

  .gn-active-note--md pre {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    overflow-x: auto;
    margin: 0.6em 0;
  }

  .gn-active-note--md pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.88em;
  }

  .gn-active-note--md strong {
    color: var(--text);
    font-weight: 600;
  }

  .gn-active-note--md em {
    color: var(--text2);
    font-style: italic;
  }

  .gn-active-note--md a {
    color: var(--gym);
    text-decoration: none;
  }

  .gn-active-note--md a:hover {
    text-decoration: underline;
  }

  .gn-active-note--md blockquote {
    margin: 0.5em 0;
    padding: 6px 12px;
    border-left: 3px solid var(--border2);
    color: var(--text2);
    font-style: italic;
  }

  /* ── Whiteboard modal ── */
  #wb-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
  }

  #wb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
  }

  #wb-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw;
    height: 92vh;
    background: var(--card, var(--bg));
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
  }

  #wb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
  }

  #wb-header span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }

  #wb-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text2);
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
  }

  #wb-header button:hover {
    background: var(--bg2);
    color: var(--text);
  }

  #wb-iframe {
    flex: 1;
    width: 100%;
    border: none;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  /* ── Teacher color coding in Esta semana ── */
  .esem-mine {
    border-left: 4px solid #4caf7d;
    background: rgba(76, 175, 100, 0.06);
  }

  .esem-ale {
    border-left: 4px solid #5b9bd5;
    background: rgba(91, 155, 213, 0.06);
  }

  .esem-done.esem-mine {
    border-left: 4px solid #4caf7d;
  }

  .esem-done.esem-ale {
    border-left: 4px solid #5b9bd5;
  }

  /* ── Esta semana legend ── */
  .esem-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 8px;
    flex-wrap: wrap;
  }

  .esem-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
  }

  .esem-legend-mine {
    background: #4caf7d;
  }

  .esem-legend-ale {
    background: #5b9bd5;
  }

  /* ── Full-history modal (stacks above snapshot detail modals) ── */
  #hist-full-modal {
    z-index: 1050;
  }

  /* ── Docs panel ── */
  .docs-layout {
    display: flex;
    gap: 16px;
    min-height: 500px;
    width: 100%;
  }

  .docs-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-right: 0.5px solid var(--border);
    padding-right: 12px;
  }

  .docs-editor {
    flex: 1;
    min-width: 0;
  }

  .docs-list-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    min-width: 0;
  }

  .docs-list-item:hover {
    background: var(--bg2);
  }

  .docs-list-item.selected {
    background: var(--bg2);
    font-weight: 500;
    color: var(--text);
    border-left: 2px solid var(--gym);
  }

  .docs-list-item.child {
    padding-left: 26px;
    color: var(--text2);
  }

  .docs-title-input {
    width: 100%;
    font-size: 20px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 4px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    outline: none;
  }

  .docs-title-input:focus {
    border-bottom-color: var(--gym);
  }

  .docs-content-ta {
    width: 100%;
    min-height: 380px;
    font-size: 13px;
    font-family: monospace;
    padding: 12px;
    box-sizing: border-box;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
  }

  .docs-preview {
    min-height: 380px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    padding: 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
  }

  .docs-preview img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

  .docs-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
    flex-wrap: wrap;
  }

  .docs-delete {
    margin-left: auto;
    font-size: 12px;
    color: var(--text3);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    border-radius: 4px;
  }

  .docs-delete:hover {
    color: #E24B4A;
    background: rgba(226, 75, 74, 0.08);
  }

  .docs-preview table,
  .gn-active-note--md table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 13px;
  }

  .docs-preview th,
  .docs-preview td,
  .gn-active-note--md th,
  .gn-active-note--md td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
  }

  .docs-preview th,
  .gn-active-note--md th {
    background: var(--bg2);
    font-weight: 600;
    color: var(--text);
  }

  .docs-preview tr:nth-child(even),
  .gn-active-note--md tr:nth-child(even) {
    background: var(--bg2);
  }

/* ── Accordion ── */
.acc-section {
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.acc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  background: var(--bg2);
  user-select: none;
}

.acc-header:hover {
  background: var(--border);
}

.acc-chev {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

.acc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.acc-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-left: auto;
}

.acc-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 0.5px solid var(--border2);
  color: var(--text2);
}

.acc-body {
  padding: 14px;
  border-top: 0.5px solid var(--border);
}

/* ── Markdown textarea toggle ── */
.md-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  margin-top: 12px;
}

.md-label-row .slabel {
  margin-top: 0;
  margin-bottom: 0;
}

.md-toggle-btn {
  font-size: 12px;
  padding: 1px 7px;
  opacity: 0.6;
  flex-shrink: 0;
}

.md-toggle-btn:hover {
  opacity: 1;
}

.md-preview-clickable {
  cursor: text;
}

.md-preview-clickable:hover {
  border-color: var(--border2);
}

/* ── Context file image thumbnail ── */
.cf-img-preview {
  max-width: 100%;
  border-radius: 6px;
  margin-top: 8px;
}

/* ── Docs chat floating panel ── */
.docs-chat-float {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  border: 0.5px solid var(--border);
  border-radius: 10px 10px 0 0;
  background: var(--bg);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  overflow: hidden;
  z-index: 10;
}

.docs-chat-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--bg2);
  user-select: none;
}

.docs-chat-float-header:hover {
  background: var(--border);
}

.docs-chat-float-body {
  padding: 12px 14px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docs-chat-float--open .docs-chat-float-header {
  border-bottom: 0.5px solid var(--border);
}

.docs-chat-section {
  display: flex;
  flex-direction: column;
}

/* ── Docs toolbar ── */
.docs-toolbar {
  display: flex;
  gap: 6px;
  padding: 4px 0;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.docs-toolbar-btn {
  font-size: 12px;
  padding: 2px 10px;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  cursor: pointer;
}

.docs-toolbar-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Highlight mark ── */
mark {
  background: rgba(255, 214, 0, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

/* ── OpenRouter mode badge ── */
.or-mode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  color: #fff;
  letter-spacing: 0.02em;
}

.or-mode-badge--preset {
  background: #bd1212;
}

.or-mode-badge--custom {
  background: #b8900a;
}

/* ── Context file drag & drop ── */
.cf-drag-handle {
  cursor: grab;
  font-size: 14px;
  color: var(--text3);
  padding: 0 4px;
  flex-shrink: 0;
  user-select: none;
}
.cf-drag-handle:active {
  cursor: grabbing;
}
.cf-dragging {
  opacity: 0.4 !important;
}
.cf-drag-over {
  outline: 1.5px dashed var(--gym);
  border-radius: var(--radius-sm);
}

/* ── Docs drag handle in sidebar ── */
.docs-drag-handle {
  font-size: 12px;
  margin-right: 4px;
}

/* ── Docs collapse toggle ── */
.docs-collapse-btn {
  font-size: 10px;
  color: var(--text3);
  cursor: pointer;
  padding: 0 4px;
  user-select: none;
  flex-shrink: 0;
}
.docs-collapse-btn:hover {
  color: var(--text);
}

/* ── Markdown preview: inline code, code blocks, blockquotes ── */
.docs-preview code,
.gn-active-note--md code {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 0.88em;
  color: var(--text);
}

.docs-preview pre code,
.gn-active-note--md pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.docs-preview pre,
.gn-active-note--md pre {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text2);
}

.docs-preview blockquote,
.gn-active-note--md blockquote {
  border-left: 3px solid var(--border2);
  padding: 4px 0 4px 14px;
  margin: 10px 0;
  color: var(--text2);
  font-style: italic;
}

/* ── Docs sidebar title — wraps long titles ── */
.docs-sidebar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  word-break: break-word;
}

/* ── Add child page button ── */
.docs-add-child-btn {
  flex-shrink: 0;
  opacity: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text3);
  padding: 0 3px;
  border-radius: 3px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.1s, color 0.1s;
}

.docs-list-item:hover .docs-add-child-btn {
  opacity: 1;
}

.docs-add-child-btn:hover {
  color: var(--text);
  background: var(--border);
}

/* ── Docs responsive ── */
.docs-sidebar-toggle {
  display: none;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  font-size: 13px;
}

@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }

  .docs-layout {
    flex-direction: column;
    gap: 0;
  }

  .docs-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 0.5px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .docs-sidebar-toggle {
    display: block;
  }

  .docs-sidebar-pages {
    display: none;
    margin-top: 8px;
  }

  .docs-sidebar-pages.open {
    display: block;
  }

  .docs-editor {
    min-width: 0;
    width: 100%;
  }

  .docs-content-ta {
    min-height: 260px;
    font-size: 13px;
  }

  .docs-preview {
    min-height: 200px;
  }

  .docs-chat-float-body {
    max-height: 260px;
  }
}

@media (max-width: 480px) {
  .docs-title-input {
    font-size: 16px;
  }

  .docs-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .docs-toolbar {
    flex-wrap: wrap;
  }
}

/* ── Esta semana — Próximos pasos cards ── */
.esem-proximos-card {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg);
}

.esem-proximos-card:last-child {
  margin-bottom: 0;
}

.esem-proximos-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.esem-proximos-md {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text2);
}

.esem-proximos-md ul,
.esem-proximos-md ol {
  padding-left: 18px;
  margin: 4px 0;
}

.esem-proximos-md p {
  margin: 4px 0;
}

.esem-proximos-md code {
  background: var(--bg2);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
}

/* ── Security tab ── */
.tab[data-tab="security"].active {
  border-bottom-color: var(--security);
  color: var(--security);
}

.sec-checks-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.sec-checks-ts {
  font-size: 12px;
  color: var(--text3);
  flex: 1;
}

.sec-checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.sec-check-card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.12s;
}

.sec-check-card:hover {
  background: var(--bg2);
}

.sec-check-card.expanded .sec-check-detail {
  display: block;
}

.sec-check-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sec-check-dot {
  font-size: 14px;
  flex-shrink: 0;
}

.sec-check-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.sec-check-value {
  font-size: 12px;
  color: var(--text2);
  margin-top: 3px;
}

.sec-check-detail {
  display: none;
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 0.5px solid var(--border);
  word-break: break-word;
}

.sec-event-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sec-event-row {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.sec-event-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sec-event-dot {
  font-size: 12px;
  flex-shrink: 0;
}

.sec-event-title {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.sec-event-meta {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  gap: 6px;
  align-items: center;
}

.sec-event-chip {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  color: var(--text2);
}

.sec-event-detail {
  font-size: 12px;
  color: var(--text2);
  margin-top: 5px;
  padding-top: 5px;
  border-top: 0.5px solid var(--border);
}

.sec-event-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: flex-start;
}

.sec-event-form select,
.sec-event-form input {
  font-size: 13px;
  padding: 6px 10px;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

.sec-event-form textarea {
  font-size: 13px;
  padding: 6px 10px;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  width: 100%;
  min-height: 60px;
}

.sec-event-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  align-items: flex-end;
}

.sec-placeholder {
  font-size: 13px;
  color: var(--text3);
  padding: 20px 0;
  text-align: center;
}

/* ── Doc links bar ── */
.sec-doclinks-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
}

.sec-doclinks-empty {
  font-size: 12px;
  color: var(--text3);
  flex: 1;
}

.sec-doclink-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: 20px;
  padding: 3px 10px 3px 12px;
  font-size: 12px;
}

.sec-doclink-pill-label {
  cursor: pointer;
  color: var(--security);
  font-weight: 500;
}

.sec-doclink-pill-label:hover {
  text-decoration: underline;
}

.sec-doclink-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
}

.sec-doclink-pill-remove:hover {
  color: #bd1212;
}

/* ── Credential list ── */
.sec-cred-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.sec-cred-archived-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}

.sec-cred-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sec-cred-row {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sec-cred-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sec-cred-location {
  font-size: 11px;
  color: var(--text3);
  margin-left: 4px;
}

.sec-cred-meta {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 10px;
}

.sec-cred-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Quota bar ── */
.quota-bar-wrap {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.quota-bar-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.quota-bar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.quota-bar-info {
  font-size: 13px;
  color: var(--text3);
  cursor: help;
}

.quota-bar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.quota-bar-track {
  background: var(--bg3);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}

.quota-bar-subtitle {
  font-size: 11px;
  color: var(--text3);
}

.quota-bar-reset-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.quota-bar-reset-btn:hover {
  opacity: 1;
}

/* ── Health indicator ── */
.health-indicator {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.health-indicator[data-band="ok"]   { border-left-color: var(--security); }
.health-indicator[data-band="warn"] { border-left-color: #b8900a; }
.health-indicator[data-band="crit"] { border-left-color: #bd1212; }

.health-header-row {
  margin-bottom: 8px;
}

.health-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.health-score {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.health-indicator[data-band="ok"]   .health-score { color: var(--security); }
.health-indicator[data-band="warn"] .health-score { color: #b8900a; }
.health-indicator[data-band="crit"] .health-score { color: #bd1212; }

.health-score-label {
  font-size: 13px;
  color: var(--text3);
}

.health-band-label {
  font-size: 13px;
  font-weight: 600;
  margin-left: 2px;
}

.health-indicator[data-band="ok"]   .health-band-label { color: var(--security); }
.health-indicator[data-band="warn"] .health-band-label { color: #b8900a; }
.health-indicator[data-band="crit"] .health-band-label { color: #bd1212; }

.health-bar-track {
  background: var(--bg3);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.health-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.health-indicator[data-band="ok"]   .health-bar-fill { background: var(--security); }
.health-indicator[data-band="warn"] .health-bar-fill { background: #b8900a; }
.health-indicator[data-band="crit"] .health-bar-fill { background: #bd1212; }

.health-footer-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.health-subtitle {
  font-size: 11px;
  color: var(--text3);
  flex: 1;
}

.health-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--text3);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.health-expand-btn:hover {
  color: var(--text);
  background: var(--bg3);
}

.health-alerts-full {
  margin-top: 8px;
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.health-alert-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 3px;
}

.health-alert-row:hover {
  background: var(--bg3);
}

.health-alert-dot[data-sev="crit"] { color: #bd1212; }
.health-alert-dot[data-sev="warn"] { color: #b8900a; }

.health-alert-msg {
  flex: 1;
  color: var(--text);
}

.health-alert-jump {
  font-size: 11px;
  color: var(--text3);
}

/* ── Discreet run counter ── */
.sec-run-counter {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 10px;
  padding: 2px 0;
}

/* ── Routine list ── */
.sec-routine-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sec-routine-card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sec-routine-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sec-routine-meta {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sec-routine-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.sec-routine-findings {
  font-size: 13px;
  line-height: 1.6;
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.sec-routine-runs {
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sec-routine-run-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.muted-help {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

/* ── Docs metadata bar ── */
.docs-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: flex-start;
}

.docs-meta-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.docs-meta-field label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.docs-meta-field select {
  font-size: 13px;
  padding: 4px 6px;
  border: 0.5px solid var(--border2);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.docs-meta-tags {
  flex: 1;
  min-width: 240px;
}

.docs-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}

.docs-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 0.5px solid var(--border2);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text2);
}

.docs-tag-chip-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.docs-tag-chip-x:hover { color: #bd1212; }

.docs-tag-input-wrap {
  position: relative;
  margin-top: 4px;
}

.docs-tag-input-wrap input {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  border: 0.5px solid var(--border2);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.docs-tag-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 0.5px solid var(--border2);
  border-radius: 4px;
  margin-top: 2px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.docs-tag-suggest-item {
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.docs-tag-suggest-item:hover { background: var(--bg2); }

/* ── Docs filters ── */
.docs-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 6px 0;
}

.docs-filters select {
  font-size: 12px;
  padding: 4px 8px;
  border: 0.5px solid var(--border2);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.docs-filter-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  border: 0.5px solid var(--gym);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
}

/* ── Sidebar type icon and status dot ── */
.docs-type-icon {
  font-size: 12px;
  margin-right: 4px;
  flex-shrink: 0;
}

.docs-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 4px;
  flex-shrink: 0;
}

.docs-list-item--ancestor-only {
  opacity: 0.55;
}

/* ── Study log modal ── */
.study-log-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}

.study-log-modal {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 92%;
  max-width: 720px;
  max-height: 86vh;
  overflow-y: auto;
}

.study-log-stale-banner {
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-left: 3px solid #e89000;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
}

.study-log-entry {
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg2);
}

.study-log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.study-log-entry-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.study-log-entry-meta {
  font-size: 11px;
  color: var(--text3);
}

.study-log-entry-summary {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
}

.study-log-entry-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.study-log-page-chip {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text2);
}

.study-log-page-chip:hover { color: var(--text); border-color: var(--gym); }

.study-log-reflection {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
  border: 0.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 50px;
  box-sizing: border-box;
}
