:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --page: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--page); min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.btn {
  border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; color: #fff; background: #334155;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn.primary { background: var(--brand); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: #e2e8f0; color: var(--text); }
.btn.dark { background: rgba(255,255,255,.12); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.active { background: var(--amber); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 14px; }
.field input { padding: 10px 12px; border: 2px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--text); }
.field input:focus { outline: none; border-color: var(--brand); }
.error { color: var(--red); font-weight: 700; min-height: 1.3em; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 700; max-width: calc(100% - 32px);
}

/* =================================================================== İzleyici */

body.viewer { background: var(--bg); color: #fff; }

.join {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 16px; text-align: center;
}
.join h1 { margin: 0; font-size: clamp(28px, 6vw, 44px); }
.join p { margin: 0; color: #cbd5e1; }
.join form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; }
.code-input {
  width: 100%; padding: 14px; border-radius: 10px; border: 0; text-align: center;
  font-size: 34px; font-weight: 800; letter-spacing: .3em; color: var(--text); background: #fff;
}
.code-input:focus { outline: 4px solid #60a5fa; }
.join .btn { justify-content: center; font-size: 20px; padding: 14px; }
.join .error { color: #fca5a5; }

.stage {
  position: fixed; inset: 0; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stage img {
  max-width: 100vw; max-height: 100vh; width: auto; height: auto; object-fit: contain;
  user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none;
}
.stage .blackout { position: absolute; inset: 0; background: #000; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 24px; color: #475569; font-size: 14px; }
.stage .overlay-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75); color: #fff; text-align: center; padding: 16px;
}
.viewer-bar {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: linear-gradient(rgba(0,0,0,.7), rgba(0,0,0,0)); color: #fff; z-index: 5;
  transition: opacity .4s; font-size: 14px;
}
.viewer-bar.faded { opacity: 0; pointer-events: none; }
.viewer-bar .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .actions { display: flex; gap: 6px; flex: none; }
.spinner { width: 44px; height: 44px; border: 5px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =================================================================== Öğretmen */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--bg); color: #fff;
}
.topbar strong { font-size: 18px; }
.layout { max-width: 1200px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel h2 { margin: 0 0 12px; font-size: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.login-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-wrap form { width: 100%; max-width: 380px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.deck-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: contain; background: #e2e8f0; border-radius: 4px; display: block; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge.live { background: var(--red); color: #fff; }
.badge.warn { background: #fef3c7; color: #92400e; }

.dropzone { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 18px; text-align: center; }
.dropzone.dragging { border-color: var(--brand); background: #eff6ff; }
.progress { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.live-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 2px solid #fecaca; border-radius: 8px; background: #fef2f2; flex-wrap: wrap; }
.live-card + .live-card { margin-top: 8px; }
.code-big { font-size: 26px; font-weight: 900; letter-spacing: .08em; font-variant-numeric: tabular-nums; }

/* --- Sunucu (presenter) görünümü --- */
body.presenting { background: #0b1120; color: #fff; }
body.presenting .topbar { background: #020617; }
.presenter { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding: 16px; max-width: 1600px; margin: 0 auto; }
.p-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.p-stage {
  position: relative; background: #000; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; width: 100%;
}
.p-stage img { width: 100%; height: 100%; object-fit: contain; }
.p-stage .black-note { position: absolute; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: #fbbf24; }
.p-stage:fullscreen { border-radius: 0; aspect-ratio: auto; }
.p-stage:fullscreen .black-note { background: #000; color: transparent; }
.p-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.p-controls .counter { font-size: 20px; font-weight: 800; min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.p-controls .btn { font-size: 18px; padding: 12px 22px; }
.p-side { display: flex; flex-direction: column; gap: 12px; }
.p-box { background: #111827; border-radius: 8px; padding: 12px; }
.p-box h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; }
.p-next { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 4px; display: block; }
.p-code { font-size: 40px; font-weight: 900; letter-spacing: .08em; text-align: center; font-variant-numeric: tabular-nums; }
.p-url { text-align: center; color: #cbd5e1; word-break: break-all; }
.p-qr { width: 100%; max-width: 180px; display: block; margin: 8px auto 0; background: #fff; border-radius: 6px; padding: 6px; }
.p-viewers { font-size: 28px; font-weight: 900; }
.p-help { font-size: 12px; color: #94a3b8; line-height: 1.6; }
.p-help kbd { background: #1f2937; border: 1px solid #374151; border-radius: 4px; padding: 0 5px; font-family: inherit; color: #e5e7eb; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.thumbs button { flex: none; padding: 0; border: 3px solid transparent; border-radius: 6px; background: #000; position: relative; }
.thumbs button.current { border-color: #fbbf24; }
.thumbs button.seen::after { content: "✓"; position: absolute; top: 2px; right: 4px; font-size: 12px; color: #4ade80; font-weight: 900; text-shadow: 0 0 3px #000; }
.thumbs img { width: 120px; aspect-ratio: 16 / 9; object-fit: contain; display: block; border-radius: 3px; }
.thumbs span { position: absolute; left: 4px; bottom: 2px; font-size: 12px; font-weight: 800; text-shadow: 0 0 3px #000; }

/* Katılım ekranı (projeksiyona yansıtılır) */
.join-screen {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2vh; text-align: center; padding: 24px;
}
.join-screen .js-title { font-size: clamp(22px, 3.5vw, 42px); font-weight: 800; }
.join-screen .js-step { font-size: clamp(18px, 2.6vw, 30px); color: #cbd5e1; }
.join-screen .js-url { font-size: clamp(26px, 4.5vw, 56px); font-weight: 800; color: #93c5fd; }
.join-screen .js-code { font-size: clamp(64px, 13vw, 180px); font-weight: 900; letter-spacing: .08em; line-height: 1; font-variant-numeric: tabular-nums; }
.join-screen img { width: clamp(140px, 22vh, 260px); background: #fff; border-radius: 10px; padding: 8px; }
.join-screen .js-viewers { color: #94a3b8; font-size: 20px; }
.join-screen .btn { position: absolute; top: 16px; right: 16px; }

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