:root {
  --bg: #0f1220;
  --bg-soft: #171a2b;
  --panel: #1e2136;
  --panel-2: #262a44;
  --border: #313655;
  --text: #e8eaf6;
  --muted: #9aa0c3;
  --accent: #6c8cff;
  --active: #3ecf8e;      /* Aktív osztályok */
  --active-2: #2aa574;
  --grad: #ffb454;        /* végzett osztályok */
  --grad-2: #e08c2b;
  --archive: #b288ff;
  --archive-2: #7d5ac9;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --lane-h: 34px;
  --lane-gap: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute always wins over display rules below
   (e.g. .modal-overlay { display:flex }). Without this the blur overlay
   and empty modal stay visible on top of the timeline. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px 24px;
  padding: 14px 22px;
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
}
.brand .subtitle {
  color: var(--muted);
  font-size: 12.5px;
}

/* Desktop: the accordion is a plain wrapper (kept open via inline script);
   the summary toggle is hidden. Mobile rules below turn it into a panel. */
.filters-accordion { display: block; }
.filters-summary { display: none; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select {
  min-width: 190px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}

.btn-ghost {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.toolbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.zoom { display: flex; gap: 6px; }
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.btn-icon:hover { border-color: var(--accent); }

/* ---------- Timeline ---------- */
.timeline-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

.timeline {
  position: relative;
  min-width: 100%;
}

.axis {
  position: sticky;
  top: 0;
  height: 34px;
  z-index: 20;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.tick {
  position: absolute;
  top: 0;
  height: 34px;
  border-left: 1px solid var(--border);
  padding-left: 5px;
  font-size: 11px;
  color: var(--muted);
  line-height: 34px;
  white-space: nowrap;
}
.tick.major { border-left-color: #3d4470; }
.tick.major span { color: var(--text); }

.gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.035);
}
.gridline.major { border-left-color: rgba(255, 255, 255, 0.08); }

.lanes {
  position: relative;
  padding: 12px 0 40px;
}

.bar {
  position: absolute;
  height: var(--lane-h);
  border-radius: 8px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: #0d1020;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: 1px solid rgba(0, 0, 0, 0.25);
  transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.bar .bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar.active {
  background: linear-gradient(180deg, var(--active), var(--active-2));
}
.bar.grad {
  background: linear-gradient(180deg, var(--grad), var(--grad-2));
}
.bar.archive {
  background: linear-gradient(180deg, var(--archive), var(--archive-2));
}
.bar.other {
  background: linear-gradient(180deg, #8b93c9, #6870a8);
  color: #0d1020;
}
.bar:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  filter: brightness(1.08);
  z-index: 5;
}
.bar.dim { opacity: 0.18; filter: grayscale(0.5); }

/* ---------- Hover bubble ---------- */
.bubble {
  position: fixed;
  z-index: 60;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  pointer-events: none;
  font-size: 12.5px;
}
.bubble h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}
.bubble .row { color: var(--muted); margin: 2px 0; }
.bubble .row b { color: var(--text); font-weight: 600; }
.bubble .pill {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill.active { background: rgba(62, 207, 142, 0.18); color: var(--active); }
.pill.grad { background: rgba(255, 180, 84, 0.18); color: var(--grad); }
.pill.archive { background: rgba(178, 136, 255, 0.18); color: var(--archive); }
.pill.other { background: rgba(139, 147, 201, 0.2); color: #b9c0ee; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 18, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  position: relative;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { border-color: var(--accent); }

.modal-hero {
  display: flex;
  gap: 18px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-hero .thumb {
  width: 132px;
  height: 132px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--panel-2);
  flex: none;
}
.modal-hero .noimg {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; text-align: center; padding: 6px;
}
.modal-hero h2 { margin: 4px 0 8px; font-size: 20px; }
.modal-hero .meta { color: var(--muted); font-size: 13px; margin: 3px 0; }
.modal-hero .meta a { color: var(--accent); text-decoration: none; }
.modal-hero .meta a:hover { text-decoration: underline; }

.modal-section { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-section:last-child { border-bottom: none; }
.modal-section h4 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.person img, .person .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex: none; background: #33385c;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--text);
}
.person .p-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .p-role { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person a { color: inherit; text-decoration: none; }
.person a:hover .p-name { color: var(--accent); }

.modal-title-row, .editor-section-head, .editor-header, .editor-actions {
  display: flex;
  align-items: center;
}
.modal-title-row { gap: 12px; }
.modal-title-row h2 { flex: 1; }
.btn-edit, .btn-primary {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-edit:hover, .btn-primary:hover { filter: brightness(1.1); }
.class-editor { padding-bottom: 8px; }
.editor-header {
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.editor-header h2 { margin: 0 0 6px; font-size: 20px; }
.editor-header p { margin: 0; color: var(--muted); font-size: 12px; }
.editor-actions { gap: 8px; flex: none; }
.editor-section { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.editor-section:last-child { border-bottom: none; }
.editor-section-head { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.editor-section-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.edit-people { display: grid; gap: 10px; }
.edit-person {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.75fr) 32px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.edit-person[data-person-type="student"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1.75fr) 32px; }
.edit-person label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.edit-person input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.edit-person input:focus { outline: none; border-color: var(--accent); }
.btn-remove {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.btn-remove:hover { color: #ff839f; border-color: #ff839f; }

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

/* Scrollbars */
.timeline-wrap::-webkit-scrollbar, .modal::-webkit-scrollbar { height: 12px; width: 12px; }
.timeline-wrap::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb {
  background: #333a5e; border-radius: 8px; border: 3px solid var(--bg);
}

@media (max-width: 620px) {
  .modal-overlay { padding: 10px; }
  .modal-hero, .editor-header { padding: 18px; }
  .modal-hero { gap: 12px; }
  .modal-hero .thumb { width: 88px; height: 88px; }
  .editor-header { align-items: flex-start; flex-direction: column; }
  .editor-section { padding: 14px 18px; }
  .edit-person, .edit-person[data-person-type="student"] { grid-template-columns: 1fr 32px; }
  .edit-person label { grid-column: 1; }
  .btn-remove { grid-column: 2; grid-row: 1; }
}

/* Development disclaimer pinned to the bottom center */
.disclaimer {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(500px, calc(100vw - 32px));
  padding: 10px 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: #ffe6b0;
  background: rgba(46, 33, 12, 0.92);
  border: 1px solid var(--grad);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

@media (max-width: 620px) {
  .disclaimer { font-size: 12px; padding: 9px 14px; bottom: 10px; }
}

/* ---------- Mobile: filters collapse into an accordion ---------- */
@media (max-width: 620px) {
  .filters-accordion {
    display: block;
    width: 100%;
    order: 3;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }
  .filters-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    user-select: none;
  }
  .filters-summary::-webkit-details-marker { display: none; }
  .filters-summary::after {
    content: "\25BE";
    color: var(--muted);
    transition: transform 0.2s ease;
  }
  .filters-accordion[open] .filters-summary::after { transform: rotate(180deg); }
  .filters-accordion[open] .filters-summary { border-bottom: 1px solid var(--border); }

  .filters-accordion .filters {
    padding: 12px 14px;
    gap: 10px;
  }
  .filters-accordion .field { width: 100%; }
  .field input,
  .field select { width: 100%; min-width: 0; }
  .filters-accordion .btn-ghost { align-self: flex-start; }
}
