/* =========================================================
   CONNEX @ LBS1 Salzburg — main stylesheet
   Desktop: classic website layout
   Mobile (≤ 768px): app shell with app bar + bottom tab bar
   ========================================================= */

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

:root {
  --blue: #8f0c2e;            /* brand (kept name for compatibility) */
  --blue-hover: #b5143f;
  --brand: var(--blue);
  --brand-hover: var(--blue-hover);
  --brand-soft: #f9e8ec;
  --text: #252525;
  --muted: #737373;
  --border: #e5e5e5;
  --bg: #f7f7f7;
  --white: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f3;
  --success: #1f7a5a;
  --danger: #c62828;
  --warning: #b26a00;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .05);
  --tabbar-h: 62px;
  --appbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --glass-tint: rgba(255, 255, 255, .55);
  --glass-tint-2: rgba(255, 255, 255, .32);
  --glass-edge: rgba(255, 255, 255, .75);
  --glass-shade: rgba(0, 0, 0, .06);
  --glass-drop: rgba(143, 12, 46, .12);
  color-scheme: light;
}

[data-theme="dark"] {
  --brand-soft: #3a1520;
  --text: #ececec;
  --muted: #a3a3a3;
  --border: #2c2c2e;
  --bg: #0f0f10;
  --white: #1a1a1c;
  --surface: #1a1a1c;
  --surface-2: #242427;
  --blue: #e0466c;
  --blue-hover: #f06a8b;
  --shadow: none;
  --glass-tint: rgba(40, 40, 44, .55);
  --glass-tint-2: rgba(28, 28, 30, .38);
  --glass-edge: rgba(255, 255, 255, .16);
  --glass-shade: rgba(0, 0, 0, .35);
  --glass-drop: rgba(224, 70, 108, .22);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --brand-soft: #3a1520;
    --text: #ececec;
    --muted: #a3a3a3;
    --border: #2c2c2e;
    --bg: #0f0f10;
    --white: #1a1a1c;
    --surface: #1a1a1c;
    --surface-2: #242427;
    --blue: #e0466c;
    --blue-hover: #f06a8b;
    --shadow: none;
    --glass-tint: rgba(40, 40, 44, .55);
    --glass-tint-2: rgba(28, 28, 30, .38);
    --glass-edge: rgba(255, 255, 255, .16);
    --glass-shade: rgba(0, 0, 0, .35);
    --glass-drop: rgba(224, 70, 108, .22);
    color-scheme: dark;
  }
}

/* Smooth page-to-page transitions (Chrome/Edge/Safari 18+) */
@view-transition {
  navigation: auto;
}

/* The old page sinks back, the new one rises in; tab bar and app bar stay put. */
::view-transition-old(root) {
  animation: vt-out .18s ease-in both;
}

::view-transition-new(root) {
  animation: vt-in .36s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes vt-out {
  to { opacity: 0; transform: scale(.98); filter: blur(2px); }
}

@keyframes vt-in {
  from { opacity: 0; transform: translateY(14px) scale(1.01); }
}

.tabbar { view-transition-name: tabbar; }
.appbar { view-transition-name: appbar; }

/* Content of a freshly opened page floats up, block by block */
html.enter main > * {
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) backwards;
}

html.enter main > *:nth-child(2) { animation-delay: .04s; }
html.enter main > *:nth-child(3) { animation-delay: .08s; }
html.enter main > *:nth-child(4) { animation-delay: .12s; }
html.enter main > *:nth-child(5) { animation-delay: .16s; }
html.enter main > *:nth-child(n+6) { animation-delay: .2s; }
html.enter body.chat-page main > * { animation: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 100;
}

.skip-link:focus {
  left: 8px;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Header (desktop) ---------- */
header.topbar,
body > header:not(.appbar) {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header {
  max-width: 1100px;
  margin: auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--brand);
  line-height: 1.1;
}

.logo small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 2px;
}

nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

nav a {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

nav a:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

nav a.active {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-soft);
}

.count {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
}

.login {
  color: #fff;
  background: var(--brand);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.login:hover {
  background: var(--brand-hover);
}

.me-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
}

.me-link:hover {
  background: var(--surface-2);
}

/* Mobile app bar — hidden on desktop */
.appbar,
.tabbar {
  display: none;
}

/* ---------- Main ---------- */
main {
  width: 100%;
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px;
  flex: 1;
}

main.narrow {
  max-width: 640px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 700;
}

.page-head p {
  color: var(--muted);
}

.welcome {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.welcome.hero {
  background: linear-gradient(135deg, #8f0c2e 0%, #5c0820 100%);
  color: #fff;
  border: 0;
}

.welcome.hero small,
.welcome.hero p {
  color: rgba(255, 255, 255, .85);
}

.welcome.hero .button {
  background: #fff;
  color: #8f0c2e;
}

.welcome.hero .button.ghost {
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.welcome small {
  color: var(--brand);
  font-weight: 600;
}

.welcome h1 {
  font-size: 30px;
  margin: 8px 0;
  font-weight: 700;
  line-height: 1.2;
}

.welcome p {
  color: var(--muted);
  line-height: 1.6;
  max-width: 650px;
}

.welcome .button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  margin-right: 8px;
  background: var(--brand);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
}

.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 17px;
  margin-bottom: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title a {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
}

/* ---------- Cards / tiles ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .15s, transform .15s;
}

a.card:hover {
  border-color: var(--brand);
}

a.card:active {
  transform: scale(.98);
}

.card h3 {
  font-size: 15px;
  margin-bottom: 6px;
}

.card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.card .link {
  color: var(--brand);
  font-size: 13px;
  margin-top: 12px;
  display: block;
  font-weight: 600;
}

.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 12px;
}

.tile-icon .icon {
  width: 22px;
  height: 22px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

.panel > p + p {
  margin-top: 10px;
}

/* News (legacy) */
.news {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.news-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.news-item:first-child {
  padding-top: 0;
}

.news-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-item strong {
  display: block;
  margin-bottom: 4px;
}

.news-item p {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Lists ---------- */
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.list-item:last-child {
  border-bottom: 0;
}

a.list-item:hover {
  background: var(--surface-2);
}

a.list-item:active {
  background: var(--surface-2);
}

.list-item .grow {
  flex: 1;
  min-width: 0;
}

.list-item .title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .sub {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  flex: none;
}

.list-item .chev {
  color: var(--muted);
}

.list-item .actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.list-item .unread {
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.list-head {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* ---------- Avatars & badges ---------- */
.avatar {
  --avatar: #8f0c2e;
  background: var(--avatar);
  color: #fff;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  flex: none;
  position: relative;
  user-select: none;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 92px; height: 92px; font-size: 32px; }

.online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28%;
  height: 28%;
  min-width: 9px;
  min-height: 9px;
  background: #22c55e;
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge-admin { background: var(--brand-soft); color: var(--brand); }
.badge-teacher { background: #e3f0ea; color: #1f7a5a; }
[data-theme="dark"] .badge-teacher { background: #173328; color: #6fd3a7; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

/* Chips that wrap onto a second line instead of scrolling (choices in forms) */
.chips.wrap {
  flex-wrap: wrap;
  overflow: visible;
  margin-bottom: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  min-height: 42px;
  white-space: nowrap;
  transition: background .15s, transform .1s;
}

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

.btn:active {
  transform: scale(.97);
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--brand);
}

.btn-ghost:hover {
  background: var(--brand-soft);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover {
  background: rgba(198, 40, 40, .08);
}

.btn-sm {
  padding: 6px 12px;
  min-height: 34px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.inline-form {
  display: inline;
}

/* ---------- Forms ---------- */
.form {
  display: grid;
  gap: 14px;
}

/* Grid children may shrink: a wide row (e.g. chips) must never push the form wider than the screen. */
.form > *,
.field {
  min-width: 0;
}

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

.field label,
.label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.field .hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="time"],
input[type="datetime-local"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
}

.check input {
  margin-top: 4px;
  accent-color: var(--brand);
  width: 18px;
  height: 18px;
  flex: none;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  border-radius: 999px;
  padding-left: 16px;
}

.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-picker label {
  cursor: pointer;
}

.color-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-picker span {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 2px var(--surface);
}

.color-picker input:checked + span {
  border-color: var(--text);
}

.color-picker input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

/* Auth screens */
.auth {
  max-width: 420px;
  margin: 20px auto;
}

.auth .panel {
  padding: 28px;
}

.auth-head {
  text-align: center;
  margin-bottom: 22px;
}

.auth-head .app-icon {
  margin: 0 auto 14px;
}

.auth-head h1 {
  font-size: 24px;
}

.auth-head p {
  color: var(--muted);
}

.auth-foot {
  text-align: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.auth-foot a,
.text-link {
  color: var(--brand);
  font-weight: 600;
}

.app-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #a8133a, #6d0922);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(143, 12, 46, .3);
}

/* ---------- Alerts / toasts ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.alert-error {
  background: rgba(198, 40, 40, .08);
  border-color: rgba(198, 40, 40, .3);
  color: var(--danger);
}

.alert-success {
  background: rgba(31, 122, 90, .1);
  border-color: rgba(31, 122, 90, .3);
  color: var(--success);
}

.alert ul {
  margin-left: 18px;
}

.alert code,
code.copy {
  word-break: break-all;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(76px + var(--safe-top));
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  background: #222;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toast-in .45s cubic-bezier(.2, .8, .2, 1), toast-out .3s ease-in 4s forwards;
}

.toast-error {
  background: var(--danger);
}

.toast-success {
  background: #1f7a5a;
}

@keyframes toast-in {
  0% { opacity: 0; transform: translateY(-18px) scale(.9); }
  60% { opacity: 1; transform: translateY(3px) scale(1.02); }
  100% { transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-14px) scale(.96); filter: blur(3px); }
}

.announcement {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.announcement a {
  text-decoration: underline;
}

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty .empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--brand);
  opacity: .7;
}

.empty h2,
.empty h3 {
  color: var(--text);
  margin-bottom: 6px;
}

.empty .btn {
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ---------- Feed ---------- */
.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.sidebar-sticky {
  position: sticky;
  top: 90px;
}

.composer {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.composer form {
  flex: 1;
  display: grid;
  gap: 10px;
}

.composer textarea {
  min-height: 70px;
  border-radius: 12px;
}

.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.post-head .who {
  flex: 1;
  min-width: 0;
}

.post-head .name {
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.post-head .when {
  font-size: 12px;
  color: var(--muted);
}

.post-body {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.post-body a,
.bubble a {
  color: var(--brand);
  text-decoration: underline;
}

.post-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.post-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.post-action:hover {
  background: var(--surface-2);
}

.post-action.liked {
  color: var(--brand);
}

.post-action.liked .icon {
  fill: currentColor;
}

.post-action.liked .icon,
.like-pop {
  animation: pop .5s cubic-bezier(.2, .8, .2, 1);
}

@keyframes pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.45) rotate(-12deg); }
  55% { transform: scale(.88) rotate(5deg); }
  75% { transform: scale(1.08) rotate(-2deg); }
  100% { transform: scale(1); }
}

.comments {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.comment-bubble {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.comment-bubble strong {
  font-size: 13px;
  margin-right: 4px;
}

.comment-bubble .when {
  font-size: 11px;
  color: var(--muted);
  display: block;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.comment-form input {
  border-radius: 999px;
  min-height: 38px;
  padding: 8px 14px;
}

/* Profile */
.profile-card {
  text-align: center;
  padding: 28px 20px;
}

.profile-card .avatar {
  margin: 0 auto 12px;
}

.profile-card h1 {
  font-size: 22px;
}

.profile-card .handle {
  color: var(--muted);
}

.profile-card .bio {
  margin: 12px auto 0;
  max-width: 460px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 16px 0;
}

.profile-stats strong {
  display: block;
  font-size: 18px;
}

.profile-stats span {
  color: var(--muted);
  font-size: 12px;
}

.profile-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: calc(100vh - 170px);
  min-height: 420px;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-head .grow {
  flex: 1;
}

.chat-head .sub {
  font-size: 12px;
  color: var(--muted);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
}

.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--surface-2);
  align-self: flex-start;
  overflow-wrap: anywhere;
  font-size: 15px;
  border-bottom-left-radius: 6px;
}

.bubble.mine {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
}

.bubble.mine a {
  color: #fff;
}

.bubble time {
  display: block;
  font-size: 10px;
  opacity: .7;
  margin-top: 2px;
  text-align: right;
}

.day-sep {
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 10px 0 6px;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}

.chat-form textarea {
  min-height: 42px;
  max-height: 140px;
  resize: none;
  border-radius: 21px;
  padding: 10px 16px;
}

.chat-form .btn {
  width: 42px;
  height: 42px;
  padding: 0;
  flex: none;
}

/* ---------- Timetable ---------- */
.timetable {
  display: grid;
  grid-template-columns: repeat(var(--days, 5), minmax(0, 1fr));
  gap: 12px;
}

.day h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.day.today h3 {
  color: var(--brand);
}

.lesson {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
}

.lesson .time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lesson strong {
  display: block;
}

.lesson .where {
  font-size: 12px;
  color: var(--muted);
}

.lesson form {
  position: absolute;
  top: 4px;
  right: 4px;
}

.lesson .icon-btn {
  width: 28px;
  height: 28px;
}

.lesson .icon-btn .icon {
  width: 16px;
  height: 16px;
}

.lesson.now {
  background: var(--brand-soft);
}

/* ---------- Stats (admin) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat strong {
  font-size: 26px;
  display: block;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: 0;
}

td select {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 13px;
  width: auto;
}

/* ---------- Text pages ---------- */
.text-section {
  max-width: 900px;
  margin: 24px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.7;
}

.text-section h1 {
  font-size: 26px;
  margin-bottom: 16px;
}

.text-section h2 {
  margin: 24px 0 10px;
  font-size: 18px;
}

.text-section h2:first-child {
  margin-top: 0;
}

.text-section p,
.text-section ul {
  margin: 0 0 12px;
}

.text-section ul {
  padding-left: 22px;
}

.text-section p:last-child {
  margin-bottom: 0;
}

.text-section a {
  color: var(--brand);
  text-decoration: underline;
}

.placeholder {
  background: #fff3cd;
  color: #6b4e00;
  padding: 0 4px;
  border-radius: 3px;
}

/* ---------- Footer ---------- */
footer.site-footer,
body > footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 35px;
}

.footer {
  max-width: 1100px;
  margin: auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.footer a:hover {
  color: var(--brand);
}

/* Install banner (landing) */
.install-card {
  display: none;
  align-items: center;
  gap: 14px;
}

.install-card.show {
  display: flex;
}

.install-card .grow {
  flex: 1;
}

/* =========================================================
   Tablet
   ========================================================= */
@media (max-width: 960px) {
  .layout-2 {
    grid-template-columns: 1fr;
  }

  .layout-2 aside {
    display: none;
  }

  .grid,
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .timetable {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Mobile = app mode
   ========================================================= */
@media (max-width: 768px) {
  body {
    background: var(--bg);
    overscroll-behavior-y: none;
  }

  header.topbar,
  footer.site-footer {
    display: none;
  }

  .appbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 30;
    height: calc(var(--appbar-h) + var(--safe-top));
    padding: var(--safe-top) 8px 0;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--border);
  }

  .appbar-title {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .appbar-logo {
    width: 34px;
    height: 34px;
    margin: 0 4px 0 6px;
    border-radius: 10px;
    background: linear-gradient(135deg, #a8133a, #6d0922);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    display: grid;
    place-items: center;
  }

  .appbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .appbar-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--text);
    background: transparent;
    border: 0;
    cursor: pointer;
  }

  .appbar-btn:active {
    background: var(--surface-2);
  }

  .appbar-btn .icon {
    width: 24px;
    height: 24px;
  }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--border);
    user-select: none;
    -webkit-user-select: none;
  }

  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 0;
    border-radius: 0;
    background: none;
  }

  .tabbar a:hover {
    background: none;
    color: var(--muted);
  }

  .tabbar a.active {
    color: var(--brand);
    background: none;
    font-weight: 700;
  }

  .tab-icon {
    position: relative;
    width: 56px;
    height: 30px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    transition: background .2s;
  }

  .tabbar a.active .tab-icon {
    background: var(--brand-soft);
  }

  .tab-icon .icon {
    width: 23px;
    height: 23px;
  }

  .tabbar a:active .tab-icon {
    transform: scale(.88);
  }

  .tab-icon {
    transition: background .2s, transform .2s cubic-bezier(.2, .8, .2, 1);
  }

  html.enter .tabbar a.active .tab-icon .icon {
    animation: tab-hop .5s cubic-bezier(.2, .8, .2, 1);
  }

  @keyframes tab-hop {
    0% { transform: scale(.8); }
    50% { transform: scale(1.15) translateY(-2px); }
    100% { transform: none; }
  }

  .tab-glass {
    display: none;
  }

  /* ---------- Liquid Glass: a floating glass bar with a glass drop on the active tab ---------- */
  html[data-nav="glass"] {
    --tabbar-h: 72px;
  }

  html[data-nav="glass"] .tabbar {
    left: 12px;
    right: 12px;
    bottom: max(var(--safe-bottom), 10px);
    height: 64px;
    padding: 6px;
    border-radius: 32px;
    isolation: isolate;
    background: linear-gradient(180deg, var(--glass-tint), var(--glass-tint-2));
    -webkit-backdrop-filter: blur(20px) saturate(200%) brightness(1.04);
    backdrop-filter: blur(20px) saturate(200%) brightness(1.04);
    border: 1px solid var(--glass-edge);
    box-shadow:
      0 12px 32px rgba(0, 0, 0, .16),
      0 2px 8px rgba(0, 0, 0, .06),
      inset 0 1px 1px var(--glass-edge),
      inset 0 -2px 6px var(--glass-shade);
  }

  /* light falling on the glass from the top left */
  html[data-nav="glass"] .tabbar::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    background:
      radial-gradient(120% 90% at 15% -20%, rgba(255, 255, 255, .45), transparent 55%),
      radial-gradient(80% 60% at 100% 120%, rgba(255, 255, 255, .12), transparent 60%);
    mix-blend-mode: soft-light;
  }

  html[data-nav="glass"] .tabbar a {
    position: relative;
    z-index: 1;
    gap: 1px;
    border-radius: 26px;
  }

  html[data-nav="glass"] .tabbar a.active .tab-icon {
    background: none;
  }

  html[data-nav="glass"] .tab-icon {
    height: 28px;
  }

  html[data-nav="glass"] .tab-glass {
    display: block;
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px;
    width: calc((100% - 12px) / var(--tabs, 4));
    border-radius: 26px;
    pointer-events: none;
    transform: translateX(calc(var(--tab, 0) * 100%));
    transition: transform .55s cubic-bezier(.3, 1.4, .5, 1), opacity .2s;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, .05)),
      var(--glass-drop);
    border: 1px solid var(--glass-edge);
    box-shadow:
      inset 0 1px 1px rgba(255, 255, 255, .6),
      inset 0 -1px 3px var(--glass-shade),
      0 4px 12px rgba(0, 0, 0, .08);
    -webkit-backdrop-filter: saturate(160%) brightness(1.08);
    backdrop-filter: saturate(160%) brightness(1.08);
  }

  html[data-nav="glass"] .tabbar:not([data-tab]) .tab-glass {
    opacity: 0;
  }

  /* the drop stretches like liquid while it moves */
  html[data-nav="glass"] .tab-glass.moving {
    animation: drop-stretch .55s cubic-bezier(.3, .9, .4, 1);
  }

  @keyframes drop-stretch {
    0% { scale: 1 1; }
    35% { scale: 1.22 .86; }
    70% { scale: .96 1.04; }
    100% { scale: 1 1; }
  }

  html[data-nav="glass"] .tab-badge {
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(143, 12, 46, .35);
  }

  .tab-badge {
    position: absolute;
    top: -3px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: grid;
    place-items: center;
    border: 2px solid var(--surface);
  }

  .tab-badge[hidden] {
    display: none;
  }

  body.has-tabbar main {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  }

  main {
    margin: 0 auto;
    padding: 14px 12px 24px;
  }

  .page-head {
    margin-bottom: 12px;
  }

  .page-head h1 {
    display: none; /* title lives in the app bar */
  }

  .page-head.keep h1 {
    display: block;
    font-size: 22px;
  }

  .welcome {
    padding: 22px;
  }

  .welcome h1 {
    font-size: 24px;
  }

  .grid,
  .grid-3,
  .grid-2,
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card {
    padding: 14px;
  }

  .card .link {
    display: none;
  }

  .card p {
    font-size: 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .post {
    border-radius: 14px;
    padding: 14px;
  }

  .panel {
    padding: 16px;
  }

  .list-item {
    padding: 12px 14px;
  }

  .text-section {
    margin: 0;
    padding: 20px;
  }

  .auth {
    margin: 8px auto;
  }

  .auth .panel {
    padding: 22px 18px;
    border: 0;
    background: transparent;
  }

  /* Chat takes the full screen between app bar and keyboard */
  body.chat-page main {
    padding: 0;
    max-width: none;
  }

  body.chat-page .tabbar {
    display: none;
  }

  body.chat-page.has-tabbar main {
    padding-bottom: 0;
  }

  /* Chat fills exactly the space below the app bar (and the announcement banner,
     if there is one) — the message field always stays on screen. */
  body.chat-page {
    height: 100dvh;
    overflow: hidden;
  }

  body.chat-page main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  body.chat-page .chat {
    border: 0;
    border-radius: 0;
    flex: 1;
    height: auto;
    min-height: 0;
  }

  body.chat-page .chat-head {
    display: none;
  }

  body.chat-page .chat-form {
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .bubble {
    max-width: 82%;
  }

  .toasts {
    top: calc(var(--appbar-h) + var(--safe-top) + 10px);
  }

  .fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 20px rgba(143, 12, 46, .35);
    z-index: 35;
    border: 0;
  }

  .fab .icon {
    width: 26px;
    height: 26px;
  }

  .fab:active {
    transform: scale(.94);
  }

  .hide-mobile {
    display: none !important;
  }

  .announcement {
    font-size: 13px;
    padding: 8px 14px;
  }

  input, select, textarea {
    font-size: 16px !important; /* prevents iOS zoom on focus */
  }
}

@media (min-width: 769px) {
  .fab,
  .show-mobile {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .grid.grid-1-xs {
    grid-template-columns: 1fr;
  }

  .welcome h1 {
    font-size: 22px;
  }
}

/* Installed app (standalone) — hide website-only bits */
@media (display-mode: standalone) {
  .web-only {
    display: none !important;
  }

  body {
    user-select: none;
    -webkit-user-select: none;
  }

  input, textarea, .post-body, .bubble, .text-section, .comment-bubble {
    user-select: text;
    -webkit-user-select: text;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }

  @view-transition {
    navigation: none;
  }
}

/* =========================================================
   Images: avatars, photo picker, galleries, lightbox
   ========================================================= */
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.avatar-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 220px;
}

.avatar-editor-actions p {
  flex-basis: 100%;
}

.avatar-editor label.btn {
  cursor: pointer;
}

/* Hidden but still usable (file pickers opened via <label>). !important beats
   input[type=file] { width: 100% } — otherwise it widens the page on phones. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/* Safety net: nothing may make the page wider than the screen (phones would zoom
   out and push the bottom tab bar out of view). clip keeps position: sticky working. */
html,
body {
  overflow-x: clip;
}

label.icon-btn {
  cursor: pointer;
}

.photo-drop {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.photo-drop .icon {
  width: 28px;
  height: 28px;
  color: var(--brand);
}

.photo-drop:hover,
.photo-drop.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.photo-preview:empty {
  display: none;
}

.photo-preview figure {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.photo-preview button .icon {
  width: 14px;
  height: 14px;
}

.photo-preview .busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Material detail gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.gallery a {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.gallery.single {
  grid-template-columns: 1fr;
}

.gallery.single a {
  aspect-ratio: auto;
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s;
}

.gallery.single img {
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.gallery a:hover img {
  transform: scale(1.03);
}

/* Material list thumbnail */
.thumb {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  overflow: hidden;
  flex: none;
  background: var(--surface-2);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-count {
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  padding: 0 4px;
}

/* Feed post photos */
.post-photos {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
}

.post-photos a {
  display: block;
  background: var(--surface-2);
  overflow: hidden;
}

.post-photos img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-photos.n1 img {
  height: auto;
  max-height: 520px;
  object-fit: contain;
  background: var(--surface-2);
}

.post-photos.n2 {
  grid-template-columns: 1fr 1fr;
  aspect-ratio: 2 / 1.1;
}

.post-photos.n3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 3 / 2;
}

.post-photos.n3 a:first-child {
  grid-row: span 2;
}

.post-photos.n4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 1 / 1;
}

.composer .photo-preview {
  grid-template-columns: repeat(4, 1fr);
}

/* Full-screen image viewer */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(56px + var(--safe-top)) 0 calc(56px + var(--safe-bottom));
  touch-action: pan-y;
  animation: lb-in .22s ease;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox button {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.lightbox button:hover {
  background: rgba(255, 255, 255, .22);
}

.lightbox .lb-close {
  top: calc(10px + var(--safe-top));
  right: 12px;
}

.lightbox .lb-prev {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox .lb-next {
  right: 12px;
  top: 50%;
  transform: translateY(-50%) scaleX(-1);
}

.lightbox .lb-count {
  position: absolute;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
  font-weight: 600;
}

@keyframes lb-in {
  from { opacity: 0; }
}

.lightbox img {
  animation: lb-zoom .32s cubic-bezier(.2, .8, .2, 1);
}

@keyframes lb-zoom {
  from { opacity: 0; transform: scale(.9); }
}

@media (max-width: 768px) {
  .lightbox .lb-prev,
  .lightbox .lb-next {
    display: none; /* swipe instead */
  }

  .post-photos {
    margin-left: -14px;
    margin-right: -14px;
    border-radius: 0;
  }
}

/* =========================================================
   Schulbücher (digi4school)
   ========================================================= */
.d4s-panel {
  display: grid;
  gap: 12px;
}

.d4s-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.d4s-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #1d1d1f;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex: none;
  letter-spacing: -.5px;
}

.d4s-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bookshelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.book {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book h3 {
  font-size: 14px;
  line-height: 1.3;
}

.book-info {
  flex: 1;
}

.book-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.book-actions .btn {
  flex: 1;
}

.book-open {
  display: block;
  transition: transform .15s;
}

.book-open:hover {
  transform: translateY(-2px);
}

.book-cover {
  --cover: #8f0c2e;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 3 / 4;
  border-radius: 4px 10px 10px 4px;
  padding: 12px 12px 12px 18px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .25) 0 6px, rgba(255, 255, 255, .12) 6px 8px, transparent 8px),
    linear-gradient(160deg, color-mix(in srgb, var(--cover) 80%, #fff) 0%, var(--cover) 55%, color-mix(in srgb, var(--cover) 70%, #000) 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
  overflow: hidden;
}

.book-cover-subject {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .85;
}

.book-cover-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.book-cover.sm {
  width: 42px;
  padding: 5px 5px 5px 9px;
  flex: none;
  box-shadow: none;
}

.book-cover.sm .book-cover-subject,
.book-cover.sm .book-cover-title {
  display: none;
}

.book-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.book-ref span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-ref .icon {
  width: 16px;
  height: 16px;
}

.book-ref .ext {
  width: 13px;
  height: 13px;
  opacity: .7;
}

.book-ref:hover {
  background: var(--brand);
  color: #fff;
}

.chip .icon {
  width: 16px;
  height: 16px;
}

@media (max-width: 768px) {
  .bookshelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .book {
    padding: 10px;
  }

  .book-cover-title {
    font-size: 13px;
  }

  .d4s-actions .btn {
    flex: 1;
  }
}

/* =========================================================
   Beginner help: onboarding checklist, guides, how-to steps
   ========================================================= */
.onboarding h2 {
  font-size: 17px;
}

.onboarding-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.progress {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
  transition: width .4s;
}

.checklist {
  list-style: none;
  margin-bottom: 10px;
}

.checklist a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.checklist li:last-child a {
  border-bottom: 0;
}

.checklist .grow {
  flex: 1;
  font-weight: 600;
}

.checklist .chev {
  color: var(--muted);
}

.check-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  flex: none;
}

.checklist .done .check-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.check-dot .icon {
  width: 15px;
  height: 15px;
}

.checklist .done .grow {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 400;
}

/* Help page */
.guide summary {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 16px;
  min-height: 44px;
}

.guide summary::-webkit-details-marker {
  display: none;
}

.guide summary .tile-icon {
  margin: 0;
  width: 40px;
  height: 40px;
}

.guide summary > span:nth-child(2) {
  flex: 1;
}

.guide summary .chev {
  color: var(--muted);
  transition: transform .2s;
}

.guide[open] summary .chev {
  transform: rotate(90deg);
}

.steps {
  counter-reset: step;
  list-style: none;
  margin: 14px 0 0;
  display: grid;
  gap: 12px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  line-height: 1.55;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
}

.guide-tip {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
}

.help-index {
  flex-wrap: wrap;
}

/* How-to steps (Schulbücher) */
.how-steps {
  list-style: none;
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.how-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.how-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: none;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
  min-width: 0;
}

.hint.ok {
  color: var(--success);
  font-weight: 600;
}

.hint.bad {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 480px) {
  .input-with-button {
    flex-direction: column;
  }
}

/* =========================================================
   App installieren
   ========================================================= */
.install-card {
  display: none;
}

.install-card.show {
  display: flex;
}

.install-hero {
  display: flex;
  gap: 16px;
  align-items: center;
}

.install-hero img {
  border-radius: 18px;
  flex: none;
  box-shadow: 0 6px 18px rgba(143, 12, 46, .25);
}

.install-hero .grow {
  flex: 1;
}

.install-hero h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.install-tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-radius: 14px;
}

.install-tabs label {
  flex: 1 1 auto;
}

.install-tabs span {
  text-align: center;
  border-radius: 11px;
}

.faq {
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.text-section a,
.steps a {
  color: var(--brand);
  text-decoration: underline;
}

/* "Started from the home screen but running in the browser" hint */
.app-hint {
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.app-hint-actions {
  display: flex;
  gap: 8px;
}

/* Elements hidden by script stay hidden, even when a class sets display (e.g. .btn). */
[hidden] {
  display: none !important;
}

/* Install card on phones: icon + text use the full width, the button goes below. */
@media (max-width: 768px) {
  .install-card.show {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 14px;
  }

  .install-card .tile-icon {
    width: 40px;
    height: 40px;
  }

  .install-card .grow {
    flex: 1 1 0;
    min-width: 0;
  }

  .install-card .btn {
    flex: 1 1 100%;
  }
}

/* =========================================================
   Logo: the C-ring mark (icon.svg) everywhere
   ========================================================= */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: none;
  box-shadow: 0 4px 12px rgba(143, 12, 46, .22);
}

.logo-text {
  display: block;
  line-height: 1.05;
}

/* Mobile app bar: just the mark */
.appbar-logo {
  background: none;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(143, 12, 46, .25);
}

.appbar-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

/* Login / register header */
img.app-icon {
  display: block;
  background: none;
  object-fit: contain;
}

/* =========================================================
   WebUntis timetable
   ========================================================= */
.untis-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.untis-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.untis-badge {
  display: inline-block;
  background: #F26B1D;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 4px 10px;
  border-radius: 999px;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.week-nav .btn {
  min-width: 42px;
  padding: 6px 10px;
}

.lesson.cancelled {
  opacity: .6;
  border-left-color: var(--muted);
}

.lesson.cancelled strong {
  text-decoration: line-through;
}

.badge-cancel {
  display: inline-block;
  margin-top: 4px;
  background: rgba(198, 40, 40, .1);
  color: var(--danger);
}

@media (max-width: 768px) {
  .untis-actions {
    margin-left: 0;
    width: 100%;
  }

  .untis-actions .inline-form:first-child {
    flex: 1;
  }

  .untis-actions .btn {
    width: 100%;
  }
}

.untis-school {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.untis-school .btn {
  margin-left: auto;
}

.untis-schools {
  display: grid;
  gap: 8px;
  margin: 4px 0 14px;
}

.untis-school-pick {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.untis-school-pick:hover,
.untis-school-pick:focus-visible {
  border-color: #F26B1D;
}

/* =========================================================
   Live updates: new posts, comments, messages fade in
   ========================================================= */
.live-new {
  animation: live-in .45s cubic-bezier(.2, .8, .2, 1), live-glow 1.6s ease-out;
}

@keyframes live-in {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
}

@keyframes live-glow {
  from { box-shadow: 0 0 0 3px var(--brand-soft); background-color: var(--brand-soft); }
}

@media (prefers-reduced-motion: reduce) {
  .live-new { animation: none; }
}

/* =========================================================
   Push notifications
   ========================================================= */
.push-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-left: 4px solid var(--brand);
}

.push-cta .grow {
  flex: 1;
  min-width: 180px;
}

.push-cta-actions {
  display: flex;
  gap: 6px;
}

.push-status {
  margin-bottom: 12px;
}

.push-status.ok { color: var(--success, #2e7d32); font-weight: 600; }
.push-status.bad { color: var(--danger); }

.push-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.push-types {
  border: 0;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.typing {
  font-size: 13px;
  color: var(--muted);
  padding: 2px 16px 6px;
  min-height: 1.4em;
}

.typing:empty::before { content: '\00a0'; }

@media (max-width: 768px) {
  .push-cta-actions { width: 100%; }
  .push-cta-actions .btn { flex: 1; }
}

/* =========================================================
   Video calls (Lernhilfe) — assets/js/call.js
   ========================================================= */
.call-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.call-head h1 { font-size: 22px; margin: 0 0 2px; }

.call-lobby {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.call-lobby-text h2 { margin: 0 0 6px; }
.call-lobby-text .btn { margin-top: 14px; }

.call-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.call-grid[data-count="1"] { grid-template-columns: minmax(0, 720px); justify-content: center; }
.call-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.call-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1d1418;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.call-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .2s;
}

.call-tile.has-video video { opacity: 1; }
.call-tile.cam-off video { opacity: 0; }
.call-tile.self video { transform: scaleX(-1); }   /* mirror like a mirror */

.call-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 26px;
}

.call-name, .call-muted {
  position: absolute;
  bottom: 8px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.call-name { left: 8px; }
.call-muted { right: 8px; }

.call-tile.connecting::after {
  content: 'Verbinde …';
  position: absolute;
  top: 8px;
  left: 8px;
  color: #fff;
  font-size: 12px;
  background: rgba(0, 0, 0, .45);
  padding: 2px 8px;
  border-radius: 999px;
}

.call-status { text-align: center; margin: 10px 0 0; min-height: 1.4em; }

.call-controls {
  position: sticky;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  margin-inline: auto;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}

.call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
  padding: 8px 10px;
  border: 0;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.call-btn .icon { width: 22px; height: 22px; }
.call-btn .icon.off { display: none; }
.call-btn.off { background: #fde8e8; color: var(--danger); }
.call-btn.off .icon:not(.off) { display: none; }
.call-btn.off .icon.off { display: block; }
.call-btn[aria-pressed="true"][data-call-screen] { background: var(--brand-soft); color: var(--brand); }
.call-btn.danger { background: var(--danger); color: #fff; }

.call-note { text-align: center; margin-top: 16px; }

@media (max-width: 768px) {
  .call-lobby { grid-template-columns: 1fr; }
  .call-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .call-grid[data-count="1"] { grid-template-columns: 1fr; }
  .call-tile { aspect-ratio: 3 / 4; border-radius: 10px; }
  .call-grid[data-count="1"] .call-tile, .call-grid[data-count="2"] .call-tile { aspect-ratio: 4 / 5; }
  .call-controls { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .call-btn { min-width: 58px; }
}

/* Live calls in the feed sidebar + Lernhilfe */
.live-calls .live-call {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.live-calls .live-call:first-of-type { border-top: 0; }
.live-call .grow { min-width: 0; flex: 1; }
.live-call strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0245e;
  flex: none;
  box-shadow: 0 0 0 0 rgba(224, 36, 94, .6);
  animation: live-pulse 1.6s infinite;
}

.live-dot.soon { background: var(--muted); animation: none; box-shadow: none; }

@keyframes live-pulse {
  70% { box-shadow: 0 0 0 8px rgba(224, 36, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 36, 94, 0); }
}

@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

.badge-live { background: #e0245e; color: #fff; }

/* ---------------------------------------------------------
   Call on the phone: full screen, videos stacked like WhatsApp
   --------------------------------------------------------- */
@media (max-width: 768px) {
  body.call-page.in-call {
    overflow: hidden;
    background: #0b0b0d;
  }

  body.call-page.in-call .appbar,
  body.call-page.in-call .tabbar,
  body.call-page.in-call .site-footer,
  body.call-page.in-call #live-announcement,
  body.call-page.in-call .call-note,
  body.call-page.in-call .toasts:empty {
    display: none !important;
  }

  body.call-page.in-call .call-stage {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #0b0b0d;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) 0 0;
  }

  /* title + number of people as an overlay at the top */
  body.call-page.in-call .call-head {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    margin: 0;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 28px;
    background: linear-gradient(rgba(0, 0, 0, .55), transparent);
    color: #fff;
    pointer-events: none;
  }

  body.call-page.in-call .call-head h1 { font-size: 17px; color: #fff; }
  body.call-page.in-call .call-head .muted { color: rgba(255, 255, 255, .8); }

  body.call-page.in-call .call-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 4px;
    padding: 4px;
    grid-template-columns: 1fr;
    grid-auto-rows: 1fr;
  }

  /* 1 person: full screen · 2–3: stacked · 4: 2×2 · 5–6: 2 columns, 3 rows */
  body.call-page.in-call .call-grid[data-count="1"] { grid-template-rows: 1fr; }
  body.call-page.in-call .call-grid[data-count="2"] { grid-template-rows: 1fr 1fr; }
  body.call-page.in-call .call-grid[data-count="3"] { grid-template-rows: repeat(3, 1fr); }
  body.call-page.in-call .call-grid[data-count="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
  body.call-page.in-call .call-grid[data-count="5"],
  body.call-page.in-call .call-grid[data-count="6"] { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); }

  body.call-page.in-call .call-tile,
  body.call-page.in-call .call-grid[data-count="1"] .call-tile,
  body.call-page.in-call .call-grid[data-count="2"] .call-tile {
    aspect-ratio: auto;
    height: 100%;
    min-height: 0;
    border-radius: 14px;
  }

  /* you at the bottom, like WhatsApp */
  body.call-page.in-call .call-tile.self { order: 99; }

  body.call-page.in-call .call-status {
    position: fixed;
    left: 16px;
    right: 16px;
    top: calc(var(--safe-top) + 120px);
    z-index: 55;
    color: rgba(255, 255, 255, .85);
    text-align: center;
    pointer-events: none;
  }

  body.call-page.in-call .call-grid:not([data-count="1"]) ~ .call-status:not(.keep) { display: none; }

  body.call-page.in-call .call-status.keep {
    width: fit-content;
    max-width: calc(100% - 32px);
    margin-inline: auto;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(0, 0, 0, .6);
  }

  /* round buttons floating over the videos */
  body.call-page.in-call .call-controls {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom) + 18px);
    z-index: 60;
    margin: 0;
    gap: 14px;
    padding: 10px 16px;
    background: rgba(28, 28, 32, .82);
    border: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }

  body.call-page.in-call .call-btn {
    min-width: 0;
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    background: rgba(255, 255, 255, .16);
    color: #fff;
  }

  body.call-page.in-call .call-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  body.call-page.in-call .call-btn .icon { width: 24px; height: 24px; }
  body.call-page.in-call .call-btn.off { background: #fff; color: #111; }
  body.call-page.in-call .call-btn.danger { background: #e53935; color: #fff; }

  /* your own tile sits under the buttons → its name goes to the top */
  body.call-page.in-call .call-tile.self .call-name,
  body.call-page.in-call .call-tile.self .call-muted { top: 8px; bottom: auto; }
  body.call-page.in-call .call-grid[data-count="1"] .call-tile.self .call-name { top: auto; bottom: 96px; }
  /* 4+ people (two columns): tiles end above the buttons, so no name is hidden */
  body.call-page.in-call .call-grid[data-count="4"],
  body.call-page.in-call .call-grid[data-count="5"],
  body.call-page.in-call .call-grid[data-count="6"] { padding-bottom: calc(env(safe-area-inset-bottom) + 92px); }
  body.call-page.in-call .call-grid[data-count="4"] .call-tile.self .call-name,
  body.call-page.in-call .call-grid[data-count="5"] .call-tile.self .call-name,
  body.call-page.in-call .call-grid[data-count="6"] .call-tile.self .call-name { top: auto; bottom: 8px; }
}

/* =========================================================
   Termine
   ========================================================= */
.event-day {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 0 8px;
}

.event-emoji {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.event .grow {
  min-width: 0;
}

.event-desc {
  font-size: 13px;
  margin-top: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.event.done .title {
  text-decoration: line-through;
  color: var(--muted);
}

.event.done .event-emoji {
  opacity: .5;
}

.check-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  color: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}

.check-btn .icon {
  width: 18px;
  height: 18px;
}

.check-btn:active {
  transform: scale(.88);
}

.check-btn.on {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  animation: pop .45s cubic-bezier(.2, .8, .2, 1);
}

select.chip {
  width: auto;
  appearance: auto;
  -webkit-appearance: auto;
  cursor: pointer;
}

/* =========================================================
   Chat: groups, photos, voice messages, reactions, ticks
   ========================================================= */
.group-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}

.group-avatar.big {
  width: 84px;
  height: 84px;
  margin: 0 auto 10px;
}

.group-avatar.big .icon {
  width: 40px;
  height: 40px;
}

.chat-head a.grow {
  min-width: 0;
}

.bubble {
  position: relative;
}

.bubble-from {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

.bubble-photo {
  display: block;
  margin: -4px -8px 4px;
  border-radius: 14px;
  overflow: hidden;
}

.bubble-photo img {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  max-height: 360px;
  object-fit: cover;
  background: rgba(0, 0, 0, .08);
}

.bubble.kind-image {
  padding: 8px;
}

.bubble-deleted {
  font-size: 14px;
  opacity: .75;
}

.ticks {
  margin-left: 4px;
  letter-spacing: -3px;
  font-weight: 700;
}

.ticks.read {
  color: #7fd3ff;
  opacity: 1;
}

.bubble:not(.mine) .ticks.read {
  color: var(--blue);
}

.reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.reacts:empty {
  display: none;
}

.react {
  margin: 4px 0 -14px;
  padding: 1px 7px;
  font-size: 13px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  animation: pop .4s cubic-bezier(.2, .8, .2, 1);
}

.react.mine {
  border-color: var(--brand);
}

.bubble:has(.react) {
  margin-bottom: 14px;
}

.bubble.picked {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.react-menu {
  position: fixed;
  z-index: 90;
  display: flex;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  animation: toast-in .3s cubic-bezier(.2, .8, .2, 1);
}

.react-pick,
.react-del {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 22px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--danger);
  transition: transform .15s, background .15s;
}

.react-pick:hover,
.react-del:hover {
  background: var(--surface-2);
  transform: scale(1.15);
}

.day-sep.info {
  max-width: 85%;
  text-align: center;
}

/* voice message */
.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 2px 0;
}

.voice-play {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.bubble.mine .voice-play {
  background: #fff;
  color: var(--brand);
}

.voice-play .icon {
  width: 18px;
  height: 18px;
}

.voice-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: color-mix(in srgb, currentColor 22%, transparent);
  overflow: hidden;
  cursor: pointer;
}

.voice-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
  border-radius: inherit;
}

.voice-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

/* composer: photo, mic, recording bar */
.chat-form {
  position: relative;
}

.chat-attach {
  width: 42px;
  height: 42px;
  flex: none;
  cursor: pointer;
  color: var(--muted);
}

.chat-form [hidden] {
  display: none !important;
}

.chat-rec {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  animation: rise .25s ease;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: live-pulse 1.2s infinite;
}

.chat-rec [data-rec-time] {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.chat-rec .grow {
  flex: 1;
}

.pick-list .list-item {
  cursor: pointer;
}

.pick-list input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}


/* =========================================================
   Polls in posts
   ========================================================= */
.poll-editor .poll-fields {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.poll-fields input[data-more]:not(.shown):placeholder-shown {
  display: none;
}

.poll-multi {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

[data-poll-toggle].on {
  background: var(--brand-soft);
}

.poll {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.poll-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: border-color .15s, transform .1s;
}

.poll-opt:active {
  transform: scale(.98);
}

.poll-opt::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--surface-2);
  z-index: -1;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}

.poll.voted .poll-opt::before {
  width: var(--p);
}

.poll.voted .poll-opt.lead::before {
  background: var(--brand-soft);
}

.poll-label {
  flex: 1;
  font-weight: 600;
}

.poll-pct {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  visibility: hidden;
}

.poll.voted .poll-pct {
  visibility: visible;
}

.poll-check {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  color: transparent;
}

.poll-check .icon {
  width: 13px;
  height: 13px;
}

.poll-opt.mine {
  border-color: var(--brand);
}

.poll-opt.mine .poll-check {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.poll-meta {
  font-size: 12px;
  color: var(--muted);
}

/* =========================================================
   Schwarzes Brett
   ========================================================= */
.board-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.board-card h3 {
  margin: 0;
}

.board-card.done,
.board-detail.done {
  opacity: .6;
}

.board-thumb {
  width: calc(100% + 32px);
  margin: -16px -16px 4px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-2);
}

.board-emoji {
  display: grid;
  place-items: center;
  font-size: 46px;
}

.board-meta {
  font-size: 13px;
  color: var(--text);
  margin: 0;
}

.board-photo img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;
  margin: 10px 0;
  background: var(--surface-2);
}

/* =========================================================
   Speiseplan
   ========================================================= */
.week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 14px;
}

.week-nav .icon {
  width: 16px;
  height: 16px;
}

.menu-days {
  display: grid;
  gap: 12px;
}

.menu-day h2 {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.menu-day.today {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.menu-day.past {
  opacity: .55;
}

.menu-meal {
  padding: 8px 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
}

.menu-meal > .muted {
  grid-column: 1 / -1;
}

.menu-text {
  font-weight: 600;
}

.menu-price {
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
}

.poll.voted .poll-hint {
  display: none;
}


/* =========================================================
   Karteikarten
   ========================================================= */
.deck-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}

.deck-stats > div {
  display: flex;
  flex-direction: column;
}

.deck-stats strong {
  font-size: 22px;
}

.deck-stats .btn {
  grid-column: 1 / -1;
}

.card-row {
  display: block;
}

.card-row summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.card-row summary::-webkit-details-marker {
  display: none;
}

.card-row summary .grow {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.box-dots {
  display: flex;
  gap: 3px;
}

.box-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}

.box-dots i.on {
  background: var(--success);
}

.learn {
  display: grid;
  gap: 14px;
  padding-top: 8px;
}

.learn-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.learn-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .4s cubic-bezier(.2, .8, .2, 1);
}

.flashcard {
  border: 0;
  padding: 0;
  background: none;
  perspective: 1200px;
  cursor: pointer;
  width: 100%;
  min-height: 300px;
  font: inherit;
  color: inherit;
}

.flashcard-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: 300px;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.3, 1.3, .5, 1);
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .1);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--brand-soft);
  font-weight: 600;
}

.learn-grades {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.learn-grades .grade-again { background: var(--danger); }
.learn-grades .grade-hard { background: var(--warning); }
.learn-grades .grade-good { background: var(--success); }

/* =========================================================
   Notenrechner
   ========================================================= */
.grade-overall {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.grade-overall strong {
  font-size: 40px;
  line-height: 1.1;
}

.grade-overall.good strong, .grade-avg.good { color: var(--success); }
.grade-overall.mid strong, .grade-avg.mid { color: #2f7cc1; }
.grade-overall.warn strong, .grade-avg.warn { color: var(--warning); }
.grade-overall.bad strong, .grade-avg.bad { color: var(--danger); }

.grade-subject summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.grade-subject summary::-webkit-details-marker {
  display: none;
}

.grade-subject .grow {
  flex: 1;
}

.grade-avg {
  min-width: 52px;
  text-align: right;
  font-size: 20px;
  font-weight: 800;
}

.grade-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.grade-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.grade-chip b {
  font-size: 18px;
}

.grade-chip span {
  font-size: 10px;
  color: var(--muted);
}

.grade-chip.g1 b, .grade-chip.g2 b { color: var(--success); }
.grade-chip.g4 b { color: var(--warning); }
.grade-chip.g5 b { color: var(--danger); }

.grade-add,
.grade-new {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.grade-add select {
  width: auto;
}

.grade-add input,
.grade-new input {
  flex: 1;
  min-width: 120px;
}

.grade-del {
  margin-top: 8px;
  color: var(--danger);
}

/* =========================================================
   Lern-Timer
   ========================================================= */
.timer {
  display: grid;
  gap: 16px;
}

.timer-dial {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
}

.timer-dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 8;
}

.timer-ring {
  fill: none;
  stroke: var(--brand);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset .3s linear, stroke .3s;
}

.timer[data-phase="short"] .timer-ring,
.timer[data-phase="long"] .timer-ring {
  stroke: var(--success);
}

.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-time {
  font-size: clamp(44px, 14vw, 64px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.timer.running .timer-time {
  animation: none;
}

.timer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.timer .chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* shared timer inside a call */
.call-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 10px auto 0;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.call-timer-time {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  min-width: 58px;
  text-align: center;
}

.call-timer.running[data-phase="focus"] .call-timer-time {
  color: var(--brand);
}

.call-timer.running[data-phase="break"] .call-timer-time {
  color: var(--success);
}

@media (max-width: 768px) {
  body.call-page.in-call .call-timer {
    position: fixed;
    top: calc(var(--safe-top) + 70px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 58;
    margin: 0;
    background: rgba(28, 28, 32, .82);
    color: #fff;
    border: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  body.call-page.in-call .call-timer .btn-ghost,
  body.call-page.in-call .call-timer .icon-btn {
    color: #fff;
  }
}


/* =========================================================
   Arbeitsblätter
   ========================================================= */
.ws-sheet,
.ws-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.ws-sheet > *,
.ws-editor > *,
.ws-page-wrap {
  min-width: 0;
}

.ws-page {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .14);
  overflow: hidden;
  container-type: inline-size;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.ws-page > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.ws-page .ws-field {
  position: absolute;
  margin: 0;
  padding: 0 .4cqw;
  border: 1.5px solid rgba(36, 75, 117, .55);
  border-radius: 3px;
  background: rgba(219, 234, 254, .55);
  color: #0b2545;
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand", cursive, sans-serif;
  font-size: var(--fs, 1.9cqw);
  line-height: 1.25;
  min-height: 0;
  box-shadow: none;
  -webkit-text-fill-color: #0b2545;
  user-select: text;
  -webkit-user-select: text;
}

.ws-page textarea.ws-field {
  resize: none;
  padding: .3cqw .4cqw;
}

.ws-page .ws-field:focus {
  outline: 2px solid var(--brand);
  background: rgba(255, 255, 255, .92);
}

.ws-page .ws-field[readonly],
.ws-page .ws-field:disabled {
  opacity: 1;
  background: rgba(219, 234, 254, .35);
}

.ws-page .ws-field.k-check {
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.ws-field.k-check input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.ws-field.k-check span::after {
  content: "";
  font-size: var(--fs, 2.4cqw);
  font-weight: 800;
  color: #0b2545;
}

.ws-field.k-check input:checked + span::after {
  content: "✗";
}

.ws-page .ws-field.ok {
  border-color: #1f7a5a;
  background: rgba(209, 250, 229, .7);
}

.ws-page .ws-field.bad {
  border-color: #c62828;
  background: rgba(254, 226, 226, .75);
}

.ws-sol {
  position: absolute;
  z-index: 2;
  transform: translateY(2px);
  padding: 1px 6px;
  border-radius: 4px;
  background: #1f7a5a;
  color: #fff;
  font-size: max(10px, 1.4cqw);
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.ws-sol::before {
  content: "✓ ";
}

.ws-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.ws-actions .grow {
  flex: 1;
}

@media (min-width: 769px) {
  .ws-actions {
    bottom: 12px;
  }
}

/* editor */
.ws-editor .ws-page {
  cursor: crosshair;
  touch-action: none;
}

.ws-page-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ws-box {
  position: absolute;
  border: 2px dashed #2563eb;
  border-radius: 3px;
  background: rgba(37, 99, 235, .12);
  cursor: move;
  touch-action: none;
}

.ws-box.k-area {
  border-color: #7c3aed;
  background: rgba(124, 58, 237, .1);
}

.ws-box.k-check {
  border-color: #ea580c;
  background: rgba(234, 88, 12, .12);
}

.ws-box.has-sol {
  border-style: solid;
}

.ws-box.selected {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
  z-index: 3;
}

.ws-box-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 4px;
  overflow: hidden;
  white-space: nowrap;
  font-size: max(10px, 1.5cqw);
  color: #1e3a8a;
  font-weight: 700;
  pointer-events: none;
}

.ws-handle {
  position: absolute;
  right: -9px;
  bottom: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  cursor: nwse-resize;
  display: none;
}

.ws-box.selected .ws-handle {
  display: block;
}

.ws-panel {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  animation: rise .25s ease;
}

.ws-panel-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.ws-panel-row label {
  display: grid;
  gap: 2px;
}

.ws-panel-row .grow {
  flex: 1;
}

.ws-status {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  justify-self: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.ws-panel:not([hidden]) ~ .ws-status {
  display: none;
}

@media (min-width: 769px) {
  .ws-panel,
  .ws-status {
    bottom: 12px;
  }
}

.ws-help {
  max-width: 900px;
  margin: 0 auto 12px;
}


/* Arbeitsblätter: tables */
.ws-table {
  position: absolute;
  display: grid;
  grid-template-rows: repeat(var(--r), 1fr);
  grid-template-columns: repeat(var(--c), 1fr);
  border: 1.5px solid rgba(36, 75, 117, .55);
  border-radius: 3px;
  overflow: hidden;
}

.ws-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid rgba(36, 75, 117, .35);
  border-bottom: 1px solid rgba(36, 75, 117, .35);
}

.ws-cell.head {
  background: transparent;
}

.ws-page .ws-table .ws-field {
  position: static;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.ws-page .ws-table .ws-field.ok {
  background: rgba(209, 250, 229, .75);
}

.ws-page .ws-table .ws-field.bad {
  background: rgba(254, 226, 226, .8);
}

.ws-cell-sol {
  position: absolute;
  right: 2px;
  bottom: 1px;
  padding: 0 4px;
  border-radius: 3px;
  background: #1f7a5a;
  color: #fff;
  font-size: max(9px, 1.2cqw);
  font-weight: 700;
  pointer-events: none;
}

.ws-box-grid {
  display: grid;
  grid-template-rows: repeat(var(--r), 1fr);
  grid-template-columns: repeat(var(--c), 1fr);
  padding: 0;
}

.ws-box-grid span {
  border-right: 1px dashed rgba(13, 148, 136, .7);
  border-bottom: 1px dashed rgba(13, 148, 136, .7);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 3px;
  display: flex;
  align-items: center;
}

.ws-box-grid span.head {
  background: rgba(13, 148, 136, .14);
}

.ws-box.k-table {
  border-color: #0d9488;
  background: rgba(13, 148, 136, .06);
}

.ws-table-opts {
  display: grid;
  gap: 8px;
}

.ws-table-sol {
  display: grid;
  grid-template-columns: repeat(var(--c), minmax(60px, 1fr));
  gap: 4px;
  max-height: 32vh;
  overflow: auto;
}

.ws-table-sol input {
  padding: 6px 8px;
  font-size: 13px;
}

.ws-table-sol input:disabled {
  opacity: .45;
}

.ws-panel .segmented {
  flex-wrap: wrap;
}

.ws-panel-row label.poll-multi {
  display: flex;
}


/* table lines the teacher can drag onto the printed lines */
.ws-div {
  position: absolute;
  z-index: 4;
  touch-action: none;
}

.ws-div::after {
  content: "";
  position: absolute;
  background: var(--brand);
  border-radius: 2px;
}

.ws-div.col {
  top: 0;
  bottom: 0;
  width: 18px;
  margin-left: -9px;
  cursor: col-resize;
}

.ws-div.col::after {
  left: 7px;
  top: 0;
  bottom: 0;
  width: 4px;
}

.ws-div.row {
  left: 0;
  right: 0;
  height: 18px;
  margin-top: -9px;
  cursor: row-resize;
}

.ws-div.row::after {
  top: 7px;
  left: 0;
  right: 0;
  height: 4px;
}

.ws-cell-sol {
  font-size: max(10px, 1.5cqw);
}

.ws-cell-sol::before {
  content: "✓ ";
}

.ws-detect {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Termine: long titles wrap instead of being cut off */
.event .title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}


/* table cells take the size of their table */
.ws-page .ws-table .ws-field {
  font-size: inherit;
}

.ws-table {
  font-size: var(--fs, 1.6cqw);
  font-family: "Segoe Print", "Comic Sans MS", "Bradley Hand", cursive, sans-serif;
}

/* Zoom for small screens: the sheet gets wider and scrolls sideways */
.ws-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 900px;
  margin: 0 auto 8px;
}

.ws-zoom .chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.ws-scroll {
  display: grid;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.ws-scroll .ws-page {
  width: calc(var(--zoom, 1) * 100%);
}

@media (min-width: 900px) {
  .ws-zoom {
    display: none;
  }
}

/* Worksheet fields keep their own size on phones (the general 16 px rule is for normal forms) */
@media (max-width: 768px) {
  .ws-page .ws-field {
    font-size: var(--fs, 1.9cqw) !important;
  }

  .ws-page .ws-table .ws-field {
    font-size: inherit !important;
  }
}

.ws-actions {
  flex-wrap: wrap;
}

.ws-actions .grow {
  min-width: 110px;
}


/* Password field with eye button (show / hide) */
.pw-wrap {
  position: relative;
  display: block;
}

.pw-wrap input {
  padding-right: 52px;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pw-toggle:hover,
.pw-toggle[aria-pressed="true"] {
  color: var(--brand);
}

.pw-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.pw-toggle .icon {
  width: 22px;
  height: 22px;
}

/* Edge has its own eye; ours replaces it */
input::-ms-reveal,
input::-ms-clear {
  display: none;
}
