/* ═══════════════════════════════════════════════════════════════
   schreiben.thlab.ch · Design System
   Aesthetic: Editorial warmth · Ink on paper · Soft & motivating
   ═══════════════════════════════════════════════════════════════ */

:root {
  --ink:        #1a1830;
  --ink-light:  #4a4760;
  --ink-faint:  #8e8aac;
  --accent:     #6c63ff;
  --accent-2:   #ff6b6b;
  --accent-3:   #ffd93d;
  --surface:    #ffffff;
  --surface-2:  #f7f6ff;
  --surface-3:  #eeedfb;
  --border:     #e4e2f5;
  --shadow-sm:  0 2px 8px rgba(108,99,255,.08);
  --shadow-md:  0 8px 32px rgba(108,99,255,.12);
  --shadow-lg:  0 24px 64px rgba(108,99,255,.16);
  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --transition: 220ms cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  min-height: 100dvh;
}

/* ── Typography ───────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
p  { line-height: 1.65; color: var(--ink-light); }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────── */
#app { min-height: 100dvh; }

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.container--narrow {
  max-width: 560px;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
.card--hover {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card--hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(108,99,255,.3);
}
.btn--primary:hover:not(:disabled) {
  background: #5a52e0;
  box-shadow: 0 6px 24px rgba(108,99,255,.4);
  transform: translateY(-1px);
}

.btn--danger {
  background: #fff0f0;
  color: var(--accent-2);
  border: 1px solid #ffd5d5;
}
.btn--danger:hover:not(:disabled) { background: #ffe0e0; }

.btn--ghost {
  background: transparent;
  color: var(--ink-light);
  border: 1px solid var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); }

.btn--large {
  padding: 16px 40px;
  font-size: 17px;
  border-radius: var(--radius-lg);
}

.btn--icon {
  padding: 10px;
  border-radius: var(--radius-sm);
}

/* ── Form ─────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .4px;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

/* ── Nav ──────────────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.9);
}
.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav__logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.3px;
}
.nav__logo span { color: var(--accent); }
.nav__actions { display: flex; gap: 12px; align-items: center; }

/* ── Badge / Status ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.badge--waiting  { background: #fff7e0; color: #b07800; }
.badge--running  { background: #e0f9e8; color: #1a7a3c; }
.badge--finished { background: #f0f0f0; color: #666; }
.badge--dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge--running.badge--dot::before { animation: pulse 1.4s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}

/* ── Toast ────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  color: #fff;
  max-width: 320px;
  animation: slideIn .25s ease;
}
.toast--success { background: #2d9e5c; }
.toast--error   { background: var(--accent-2); }
.toast--info    { background: var(--accent); }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Page: Login ──────────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f7f6ff 0%, #eeedfb 50%, #fff5f5 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,99,255,.06) 0%, transparent 70%);
  top: -200px; right: -100px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,107,.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}
.login-header {
  text-align: center;
  margin-bottom: 40px;
}
.login-header__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.login-header__title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 8px;
}
.login-header__sub {
  color: var(--ink-faint);
  font-size: 15px;
}

/* ── Page: Dashboard ──────────────────────────────────────────── */
.dashboard-hero {
  padding: 48px 0 40px;
}
.dashboard-hero__greeting {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}
.session-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.session-card__topic {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}
.session-card__stats {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.session-card__stat {
  font-size: 13px;
  color: var(--ink-faint);
}
.session-card__stat strong {
  display: block;
  font-size: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

/* ── Dialog / Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,24,48,.5);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s cubic-bezier(.34,1.56,.64,1);
  max-height: 90dvh;
  overflow-y: auto;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal__header {
  margin-bottom: 32px;
}
.modal__step {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.modal__actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}

/* ── Drum Roller / Time Picker ────────────────────────────────── */
.drum-roller {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}
.drum-roller__unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.drum-roller__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.drum-roller__scroll {
  position: relative;
  width: 80px;
  height: 160px;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: ns-resize;
  user-select: none;
}
.drum-roller__scroll::before,
.drum-roller__scroll::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 52px;
  z-index: 2;
  pointer-events: none;
}
.drum-roller__scroll::before {
  top: 0;
  background: linear-gradient(to bottom, var(--surface-2), transparent);
}
.drum-roller__scroll::after {
  bottom: 0;
  background: linear-gradient(to top, var(--surface-2), transparent);
}
.drum-roller__track {
  display: flex;
  flex-direction: column;
  transition: transform .15s cubic-bezier(.4,0,.2,1);
}
.drum-roller__item {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink-faint);
  transition: color .15s, transform .15s;
  flex-shrink: 0;
}
.drum-roller__item--selected {
  color: var(--accent);
  font-size: 2rem;
}
.drum-roller__select-line {
  position: absolute;
  left: 8px; right: 8px;
  top: 50%;
  transform: translateY(-50%);
  height: 52px;
  border-radius: var(--radius-sm);
  background: rgba(108,99,255,.07);
  border: 1.5px solid rgba(108,99,255,.2);
  pointer-events: none;
  z-index: 1;
}

/* ── Email Tags Input ─────────────────────────────────────────── */
.tag-input {
  min-height: 120px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  cursor: text;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
}
.tag-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
.tag-input__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  animation: popIn .15s ease;
}
@keyframes popIn {
  from { transform: scale(.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.tag-input__tag-remove {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
  padding: 0;
}
.tag-input__tag-remove:hover { background: var(--border); color: var(--ink); }
.tag-input__field {
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  flex: 1;
  min-width: 200px;
  padding: 4px 0;
}
.tag-input__field::placeholder { color: var(--ink-faint); }

/* ── Page: Session Live (Lehrer) ──────────────────────────────── */
.live-page {
  min-height: 100dvh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.live-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.live-header__left { display: flex; align-items: center; gap: 20px; }
.live-header__topic {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
}
.live-header__notopic {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--ink-faint);
}
.live-timer {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -1px;
  line-height: 1;
  min-width: 120px;
  text-align: right;
}
.live-timer--warning { color: var(--accent-2); }

.participants-grid {
  flex: 1;
  padding: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  align-content: start;
}
.participant-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: all var(--transition);
}
.participant-card--typing {
  background: #f0eeff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,.1);
  transform: scale(1.02);
}
.participant-card__avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  transition: all var(--transition);
}
.participant-card--typing .participant-card__avatar {
  background: var(--accent);
  color: #fff;
}
.participant-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}
.participant-card__status {
  font-size: 12px;
  color: var(--ink-faint);
}
.participant-card--typing .participant-card__status {
  color: var(--accent);
  font-weight: 600;
}

/* Typing indicator dots */
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  height: 14px;
}
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce .9s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* Start button area */
.live-start-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 24px;
  padding: 48px;
}
.live-start-zone__count {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.live-start-zone__label {
  font-size: 16px;
  color: var(--ink-faint);
  margin-top: -16px;
}

/* ── Page: Write (Schüler) ────────────────────────────────────── */
.write-page {
  min-height: 100dvh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.write-header {
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.write-header__topic {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
}
.write-pause-bar {
  width: 200px;
  height: 6px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
}
.write-pause-bar__fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width .1s linear, background .3s;
}
.write-pause-bar__fill--danger {
  background: var(--accent-2);
}

.write-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 48px clamp(24px, 8vw, 120px);
}
.write-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  line-height: 1.7;
  color: var(--ink);
  background: transparent;
  width: 100%;
}
.write-textarea::placeholder {
  color: var(--border);
  font-style: italic;
}
.write-textarea:disabled {
  cursor: not-allowed;
}

/* Delete animation */
@keyframes textDelete {
  0%   { opacity: 1; transform: scale(1); filter: blur(0); }
  50%  { opacity: .4; transform: scale(.98); filter: blur(1px); }
  100% { opacity: 0; transform: scale(.96); filter: blur(3px); }
}
.write-textarea--deleting {
  animation: textDelete .7s ease forwards;
}

/* Waiting screen */
.write-waiting {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px;
}
.write-waiting__icon {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}
.write-waiting__title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ink);
}
.write-waiting__sub {
  color: var(--ink-faint);
  font-size: 15px;
}

/* Finished screen */
.write-finished {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px;
  text-align: center;
}
.write-finished__checkmark {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #e0f9e8;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}

/* ── Page: Join ───────────────────────────────────────────────── */
.join-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f7f6ff 0%, #eeedfb 60%, #fff5f5 100%);
}
.join-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.join-card__emoji {
  font-size: 3.5rem;
  margin-bottom: 16px;
}
.nickname-input {
  font-size: 1.3rem;
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-md);
  margin: 24px 0;
  font-family: var(--font-display);
  font-weight: 600;
}

/* ── Admin Panel ──────────────────────────────────────────────── */
.admin-section {
  margin-bottom: 40px;
}
.admin-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.teacher-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.teacher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.teacher-item__info { display: flex; flex-direction: column; gap: 2px; }
.teacher-item__name { font-weight: 600; color: var(--ink); }
.teacher-item__email { font-size: 13px; color: var(--ink-faint); }

/* ── Progress Steps ───────────────────────────────────────────── */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}
.step-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background var(--transition);
}
.step-dot--active  { background: var(--accent); }
.step-dot--done    { background: rgba(108,99,255,.35); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .card { padding: 24px; }
  .modal { padding: 28px; }
  .live-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .live-timer { font-size: 2rem; }
  .participants-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 20px; }
  .write-area { padding: 28px 20px; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.text-center { text-align: center; }
.text-muted  { color: var(--ink-faint); font-size: 14px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
