:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --text: #1c2230;
  --muted: #6b7385;
  --border: #e1e4ea;
  --primary: #3b5bdb;
  --primary-hover: #2f4bc0;
  --danger: #d6336c;
  --success-bg: #e6f6ec;
  --success-text: #1e7a43;
  --error-bg: #fdecef;
  --error-text: #b4234f;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
code { font-size: .9em; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.topbar nav a.active, .topbar nav a:hover { background: var(--bg); color: var(--text); }
.logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0 0 4px; }

label, .field { display: grid; gap: 6px; font-weight: 500; font-size: .9rem; }
input {
  font: inherit; padding: 9px 12px; width: 100%;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.has-error input { border-color: var(--danger); }
.field-error { color: var(--error-text); font-weight: 400; font-size: .85rem; }
.req { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 500; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; padding: 10px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.login-card .alert { margin: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.count { font-size: .9rem; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; vertical-align: middle; }

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { max-width: 460px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
.empty { text-align: center; color: var(--muted); }

.form { max-width: 760px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-actions { margin-top: 24px; display: flex; justify-content: flex-end; }

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; gap: 12px; }
  .who { display: none; }
  .container { padding: 20px 16px; }
}

.section-title { font-size: 1.05rem; margin: 28px 0 16px; padding-top: 20px; border-top: 1px solid var(--border); }
.span-2 { grid-column: 1 / -1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.hint { color: var(--muted); font-weight: 400; font-size: .8rem; }
.checkbox { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 400; }
.checkbox input { width: auto; }
.secret-status { font-weight: 400; font-size: .85rem; }
.token-saved { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.checkbox label { font-weight: 400; }

.section-title.plain { border-top: 0; padding-top: 0; margin-top: 8px; }
.badge { font-size: .75rem; font-weight: 500; background: var(--success-bg); color: var(--success-text); padding: 1px 8px; border-radius: 999px; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.description { margin-bottom: 24px; white-space: pre-wrap; }
.page-head p { margin: 0; }

.badge-danger { background: var(--error-bg); color: var(--error-text); text-decoration: none; margin-left: 6px; }
.pin-lock { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 760px; }
.pin-lock form { margin: 0; }

/* Materiały i projekty ucznia */
.lead { max-width: 760px; margin: 0 0 20px; }
.form + .form, .new-material { margin-bottom: 20px; }
.card.form { margin-bottom: 20px; }
.upload-zip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-input { display: none; }
.upload-progress { width: 220px; height: 10px; }
.file-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.access-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.access-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 16px; }
.access-list .checkbox { margin-top: 6px; }
.student-projects { margin-top: 20px; }
.storage-bar { width: 100%; height: 10px; margin-bottom: 14px; }
.details-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.details-head .section-title { margin: 0; }
.details-view { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 0; }
.details-view dt { color: var(--muted); font-size: .9rem; }
.details-view dd { margin: 0; white-space: pre-wrap; }
.details-form { display: none; margin-top: 14px; }
.details-box.is-editing .details-form { display: block; }
.details-box.is-editing .details-view, .details-box.is-editing .details-edit { display: none; }
.form-actions .btn + .btn { margin-left: 8px; }
.access-status { margin-left: 8px; }
.toasts { position: fixed; top: 72px; right: 20px; display: grid; gap: 8px; z-index: 1000; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--success-bg); color: var(--success-text); border: 1px solid #b7e4c7; border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.12); transition: opacity .5s, transform .5s; }
.toast-hide { opacity: 0; transform: translateY(-6px); }
.bulk-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
th.check, td.check { width: 36px; padding-right: 0; }
.check input { width: auto; }
.row-locked td { background: #fff7f9; }
.head-actions { display: flex; gap: 8px; }
.head-actions form { margin: 0; }
.prompts-title { margin-top: 28px; }
.prompt-list { display: grid; gap: 10px; }
.prompt { padding: 14px 18px; }
.prompt-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.prompt-text { white-space: pre-wrap; font-size: .95rem; }
.prompt-change { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: .9rem; }
.prompt-change code { white-space: nowrap; }
.rules-view { display: block; white-space: pre-wrap; font-family: inherit; font-size: .92rem; line-height: 1.5;
  background: var(--bg, #f7f7fb); padding: 14px 16px; border-radius: 8px; margin: 14px 0 0; }
.rules-edit { width: 100%; font-family: Consolas, monospace; font-size: .88rem; line-height: 1.45; }
.activity { margin-top: 18px; }
.activity-link { margin: 4px 0 0; }
.activity-project { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 12px; }
.activity-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.activity-name { font-size: 1.05rem; }
.activity-stats { display: flex; gap: 14px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.activity-stats strong { color: var(--text, inherit); }
.activity-desc { margin: 8px 0 6px; }
.activity details summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 12px 12px; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary, #5865f2); }
.tl-time { color: var(--muted); font-size: .8rem; }
.tl-prompt { white-space: pre-wrap; margin: 2px 0; }
.tl-done { font-size: .9rem; color: #1f7a4d; }
.tl-done.muted { color: var(--muted); }
.card.form.student-projects, .card.form.activity { max-width: none; }
.card.form.subtitles-box { max-width: none; }
.sub-table input:not([type=checkbox]), .sub-table select { width: 100%; }
.sub-table .sub-text { min-width: 280px; }
.sub-table .sub-hold { width: 64px; }
.sub-table td.sub-center { text-align: center; }
.subtitles-box .details-view { display: block; }
.sub-table td.actions { white-space: nowrap; }
.form-actions .sub-add { margin-right: auto; }
.sub-table select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: inherit; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.student-summary { margin: 4px 0 0; }
.nick { font-weight: 400; font-size: 1.1rem; }
.activity { margin-top: 0; }
.btn-icon { padding: 6px; line-height: 0; }
.btn-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tick { color: var(--success-text, #1f7a4d); font-weight: 700; font-size: 1.1rem; }
th.center-col, td.center-col { text-align: center; }
.student-name { color: inherit; text-decoration: none; }
.student-name:hover { text-decoration: underline; }
.student-group { padding: 0; margin-bottom: 14px; overflow: hidden; }
.student-group > summary { display: flex; align-items: baseline; gap: 14px; padding: 14px 18px; cursor: pointer; flex-wrap: wrap; }
.student-group[open] > summary { border-bottom: 1px solid var(--border); }
.group-name { font-weight: 600; font-size: 1.05rem; }
.group-link { margin-left: auto; font-size: .9rem; }
.student-group .bulk-bar { margin: 10px 16px; }
.student-group .table-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--border); }
.without { margin-top: 18px; }
.card.form.rules-box { max-width: none; }
.btn-icon.is-locked { color: var(--danger); border-color: var(--danger); }
.app-bar-wrap { overflow-x: auto; margin-top: 14px; border-radius: 8px; }
.app-bar { position: relative; width: 960px; height: 96px; background: linear-gradient(90deg, rgb(88,101,242), rgb(165,80,230));
  font-family: 'Segoe UI', system-ui, sans-serif; color: #fff; }
.app-bar-logo { position: absolute; left: 26px; top: 16px; width: 64px; height: 64px; }
.app-bar-title { position: absolute; left: 102px; top: 12px; font-size: 24px; font-weight: 700; white-space: nowrap; }
.app-bar-sub { position: absolute; left: 106px; top: 54px; width: 540px; height: 28px; line-height: 28px; font-size: 14.7px; white-space: nowrap; overflow: hidden; }
.app-bar-hint { margin: 6px 0 0; }
.edit-only { display: none; }
.is-editing .edit-only { display: inline; }
.sub-list { margin: 14px 0 0; padding-left: 22px; }
.sub-list li { margin-bottom: 6px; }
.sub-list-text { margin-right: 8px; }
