/* onlinegel — ortak stil */
:root {
  --paper: #f4f6fa;
  --card: #ffffff;
  --text: #1a2340;
  --muted: #5d6784;
  --line: #d9dfeb;
  --margin-red: #e8828a;
  --ink: #141c33;      /* oda arka planı: mürekkep mavisi */
  --ink-2: #1f2945;    /* kutucuk */
  --ink-3: #2c3757;    /* düğme */
  --ink-4: #3a4770;
  --on-ink: #eef1f8;
  --on-ink-muted: #a3acc6;
  --marker: #ffd43b;   /* fosforlu kalem: el kaldırma, konuşan kişi */
  --primary: #2f5bea;
  --primary-press: #2349c9;
  --danger: #e5484d;
  --ok: #2fae6b;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.room-body :focus-visible { outline-color: var(--marker); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Form öğeleri ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: 15px; }
.input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-s);
  background: #fff;
  font-size: 18px;
}
.input:focus { border-color: var(--primary); outline: none; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.error { color: var(--danger); font-size: 15px; margin: 0; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border: 0; border-radius: var(--radius-s);
  font-weight: 700; font-size: 17px;
  background: var(--primary); color: #fff;
  transition: background .15s;
}
.btn:hover { background: var(--primary-press); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { padding: 15px 26px; font-size: 19px; }
.btn.ghost { background: transparent; color: var(--primary); padding-inline: 8px; }
.btn.ghost:hover { background: rgba(47, 91, 234, .08); }
.btn.secondary { background: #e6ebf6; color: var(--text); }
.btn.secondary:hover { background: #d9e0f0; }
.btn svg { width: 20px; height: 20px; }

/* ---------- Ana sayfa ---------- */
.home {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px 48px;
}
.home-inner { width: 100%; max-width: 560px; }
.brand {
  font-weight: 700;
  font-size: clamp(44px, 9vw, 68px);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 10px;
}
.brand .dot { display: inline-block; width: .22em; height: .22em; border-radius: 50%; background: var(--marker); margin-left: .06em; box-shadow: 0 0 0 .05em var(--text); vertical-align: .08em; }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 28px; max-width: 34ch; }

/* Defter sayfası: kırmızı kenar çizgisi ve satır çizgileri */
.notebook {
  position: relative;
  background:
    linear-gradient(to right, transparent 46px, var(--margin-red) 46px, var(--margin-red) 48px, transparent 48px),
    var(--card);
  border-radius: var(--radius-m);
  padding: 28px 24px 28px 70px;
  box-shadow: 0 1px 0 var(--line), 0 12px 30px -18px rgba(20, 28, 51, .35);
}
.notebook h2 { margin: 0 0 14px; font-size: 22px; }
.join-row { display: flex; gap: 10px; flex-wrap: wrap; }
.join-row .input { flex: 1 1 200px; font-size: 22px; letter-spacing: .02em; }

.teacher-area { margin-top: 28px; padding: 0 4px; }
.teacher-area h2 { font-size: 19px; margin: 0 0 4px; }
.teacher-card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-m); padding: 20px; display: grid; gap: 14px; margin-top: 12px; }
.recent { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.recent a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--paper); color: var(--text); text-decoration: none; font-weight: 700; }
.recent a:hover { background: #e6ebf6; }
.recent small { color: var(--muted); font-weight: 400; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.slug-prefix { display: flex; align-items: center; border: 2px solid var(--line); border-radius: var(--radius-s); background: #fff; overflow: hidden; }
.slug-prefix span { padding: 0 2px 0 12px; color: var(--muted); white-space: nowrap; font-size: 16px; }
.slug-prefix .input { border: 0; padding-left: 2px; min-width: 0; }
.slug-prefix:focus-within { border-color: var(--primary); }

/* ---------- Ders odası ---------- */
.room-body { background: var(--ink); color: var(--on-ink); overflow: hidden; }
.room-body .input { background: var(--ink-2); border-color: var(--ink-4); color: var(--on-ink); }
.room-body .input:focus { border-color: var(--marker); }
.room-body .hint { color: var(--on-ink-muted); }

/* Ön izleme (derse girmeden önce) */
.prejoin {
  min-height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.prejoin-grid {
  width: 100%; max-width: 980px;
  display: grid; gap: 28px;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
}
.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink-2);
  border-radius: var(--radius-l);
  overflow: hidden;
  display: grid; place-items: center;
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .avatar { width: 96px; height: 96px; font-size: 38px; }
.preview-controls { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 10px; }
.meter { position: absolute; left: 14px; top: 14px; display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.meter i { width: 4px; background: var(--marker); border-radius: 2px; height: 4px; transition: height .08s; }
.prejoin-form { display: grid; gap: 18px; }
.prejoin-form h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.prejoin-form .code { color: var(--on-ink-muted); margin: 4px 0 0; }
.check { display: flex; gap: 10px; align-items: center; font-size: 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--marker); }

/* Oda yerleşimi */
.room { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.room.with-panel { grid-template-columns: 1fr 360px; }
.room.with-panel .topbar, .room.with-panel .controls { grid-column: 1 / -1; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 56px; }
.topbar .title { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .meta { color: var(--on-ink-muted); font-size: 15px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 0; background: var(--ink-3); color: var(--on-ink); font-weight: 700; font-size: 15px; }
.pill-btn:hover { background: var(--ink-4); }
.pill-btn svg { width: 18px; height: 18px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }

.stage { position: relative; min-height: 0; min-width: 0; padding: 4px 12px 8px; }
.grid {
  height: 100%;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 10px;
}
.grid .tile { width: var(--tile-w, 320px); }

.stage.sharing { display: grid; grid-template-columns: 1fr 220px; gap: 10px; }
.stage.sharing .main { min-height: 0; display: grid; }
.stage.sharing .main .tile { width: 100%; height: 100%; aspect-ratio: auto; }
.stage.sharing .grid { flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-content: stretch; overflow-y: auto; }
.stage.sharing .grid .tile { width: 100%; flex: 0 0 auto; }

.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink-2);
  border-radius: var(--radius-m);
  overflow: hidden;
  display: grid; place-items: center;
  outline: 3px solid transparent;
  outline-offset: -3px;
  transition: outline-color .15s;
}
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.local video { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; background: #0c1222; transform: none; }
.tile.speaking { outline-color: var(--marker); }
.avatar {
  width: 30%; max-width: 88px; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink-4); color: var(--on-ink);
  font-weight: 700; font-size: clamp(18px, 3vw, 32px);
}
.tile .label {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(14, 20, 38, .72); font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden;
}
.tile .label .name { overflow: hidden; text-overflow: ellipsis; }
.tile .label svg { width: 16px; height: 16px; flex: none; }
.badge-teacher { background: var(--on-ink); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.tile .hand {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  background: var(--marker); color: var(--ink);
  border-radius: 999px; padding: 4px 10px 4px 8px; font-weight: 700; font-size: 14px;
}
.tile .hand svg { width: 18px; height: 18px; }
.mic-off { color: #ff9a9d; }

/* Alt kontrol çubuğu */
.controls { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 12px 14px; flex-wrap: wrap; }
.ctl {
  position: relative;
  display: grid; justify-items: center; gap: 2px;
  min-width: 76px; padding: 8px 10px 6px;
  border: 0; border-radius: var(--radius-m);
  background: var(--ink-3); color: var(--on-ink);
  font-size: 13px; font-weight: 700;
}
.ctl:hover { background: var(--ink-4); }
.ctl svg { width: 24px; height: 24px; }
.ctl.off { background: #4a2430; color: #ffb3b5; }
.ctl.on-marker { background: var(--marker); color: var(--ink); }
.ctl.leave { background: var(--danger); color: #fff; }
.ctl.leave:hover { background: #c93a3f; }
.ctl .count { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--marker); color: var(--ink); font-size: 12px; line-height: 18px; }
.ctl-sep { width: 1px; height: 36px; background: var(--ink-4); margin: 0 4px; }

/* Yan panel */
.panel { grid-row: 2; grid-column: 2; display: flex; flex-direction: column; min-height: 0; background: var(--ink-2); border-radius: var(--radius-m); margin: 4px 12px 8px 0; overflow: hidden; }
.panel-tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--ink-3); }
.panel-tabs button { flex: 1; border: 0; background: transparent; color: var(--on-ink-muted); padding: 8px; border-radius: var(--radius-s); font-weight: 700; }
.panel-tabs button[aria-selected="true"] { background: var(--ink-3); color: var(--on-ink); }
.panel-close { flex: 0 0 auto !important; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.chat-log { display: grid; gap: 12px; align-content: start; }
.msg .who { font-weight: 700; font-size: 14px; color: var(--on-ink-muted); }
.msg.mine .who { color: var(--marker); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .time { font-weight: 400; font-size: 12px; margin-left: 6px; }
.empty { color: var(--on-ink-muted); text-align: center; margin-top: 30px; font-size: 15px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--ink-3); }
.chat-form .input { font-size: 16px; padding: 10px 12px; }
.chat-form .btn { padding: 10px 14px; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.people li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 6px; padding: 8px; border-radius: var(--radius-s); }
.people .p-actions { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn { border: 0; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700; background: var(--ink-3); color: var(--on-ink); }
.mini-btn:hover { background: var(--ink-4); }
.mini-btn.danger:hover, .mini-btn.armed { background: var(--danger); color: #fff; }
.people li:hover { background: var(--ink-3); }
.people .avatar { width: 34px; font-size: 14px; }
.people .pname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.people .pname small { display: block; font-weight: 400; color: var(--on-ink-muted); font-size: 13px; }
.people .icons { display: flex; gap: 4px; align-items: center; }
.people .icons svg { width: 18px; height: 18px; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-s); border: 0; background: transparent; color: var(--on-ink); }
.icon-btn:hover { background: var(--ink-4); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.danger:hover { background: var(--danger); }
.hand-chip { background: var(--marker); color: var(--ink); border-radius: 999px; padding: 0 8px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.hand-chip svg { width: 14px !important; height: 14px !important; }
.teacher-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.teacher-tools .pill-btn { font-size: 14px; }

/* Bildirimler */
.toasts { position: fixed; left: 50%; top: 66px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; background: var(--on-ink); color: var(--ink); padding: 10px 16px; border-radius: var(--radius-m); font-weight: 700; box-shadow: 0 10px 30px -12px rgba(0,0,0,.6); display: flex; gap: 10px; align-items: center; animation: toast-in .2s ease-out; }
.toast.marker { background: var(--marker); }
.toast svg { width: 20px; height: 20px; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* Ortadaki mesaj ekranları */
.center-screen { height: 100%; display: grid; place-items: center; padding: 24px 16px; text-align: center; }
.center-screen h1 { margin: 0 0 8px; font-size: 30px; }
.center-screen p { color: var(--on-ink-muted); margin: 0 0 22px; }
.center-screen .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.audio-unlock { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); z-index: 40; }

/* Bekleme odası — öğrenci tarafı */
.waiting { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: start; padding: 18px; border-radius: var(--radius-m); background: var(--ink-2); border: 2px solid var(--ink-4); }
.waiting .btn { grid-column: 1 / -1; justify-self: start; }
.waiting-title { margin: 0 0 2px; font-weight: 700; font-size: 19px; }
.waiting .hint { margin: 0; }
.waiting-dot { width: 14px; height: 14px; margin-top: 6px; border-radius: 50%; background: var(--marker); animation: wait-pulse 1.6s ease-in-out infinite; }
@keyframes wait-pulse { 50% { opacity: .35; transform: scale(.8); } }

/* Bekleme odası — öğretmen tarafı */
.lobby-section { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--ink-3); }
.lobby-section h3 { margin: 0; font-size: 17px; }
.lobby-section .hint { margin: 2px 0 8px; font-size: 14px; }
.lobby-section .people { margin-bottom: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--on-ink); font-weight: 700; font-size: 14px; padding: 4px; }
.switch-track { width: 38px; height: 22px; border-radius: 11px; background: var(--ink-4); position: relative; transition: background .15s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--on-ink); transition: transform .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--ok); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); }

.lobby-card {
  position: fixed; top: 64px; right: 16px; z-index: 45; width: min(360px, calc(100vw - 32px));
  background: var(--on-ink); color: var(--ink);
  border-radius: var(--radius-m); padding: 14px 14px 12px;
  border-left: 6px solid var(--marker);
  box-shadow: 0 18px 40px -16px rgba(0,0,0,.7);
  animation: toast-in .2s ease-out;
}
.lobby-card-title { margin: 0 0 8px; font-weight: 700; }
.lobby-card ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.lobby-card li { display: flex; align-items: center; gap: 8px; }
.lobby-card li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.lobby-card .mini-btn { background: #dfe4f0; color: var(--ink); }
.lobby-card .mini-btn:hover { background: #cdd5e6; }
.lobby-card .mini-btn.yes { background: var(--ok); color: #fff; }
.lobby-card .mini-btn.yes:hover { background: #26935a; }
.lobby-card-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-btn.yes { background: var(--ok); color: #fff; }

/* Öğretmenin "Ayrıl" menüsü */
.leave-menu {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60;
  width: min(360px, calc(100vw - 32px));
  display: grid; gap: 10px;
  background: var(--on-ink); color: var(--ink);
  border-radius: var(--radius-l); padding: 18px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8);
  animation: toast-in .15s ease-out;
}
.leave-menu-title { margin: 0 0 2px; font-weight: 700; font-size: 18px; }
.leave-menu .hint { color: var(--muted); margin: -2px 0 0; font-size: 14px; }
.leave-menu .btn { width: 100%; }
.leave-menu .btn.secondary { background: #dfe4f0; }
.leave-menu .btn.ghost { color: var(--ink); }
.btn.danger-btn { background: var(--danger); }
.btn.danger-btn:hover { background: #c93a3f; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .prejoin-grid { grid-template-columns: 1fr; gap: 20px; }
  .room.with-panel { grid-template-columns: 1fr; }
  .panel { position: fixed; inset: 0; margin: 0; border-radius: 0; z-index: 30; }
  .stage.sharing { grid-template-columns: 1fr; grid-template-rows: 1fr 110px; }
  .stage.sharing .grid { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .stage.sharing .grid .tile { width: 180px; height: 100%; }
  .ctl { min-width: 0; padding: 10px; }
  .ctl span.lbl { display: none; }
  .ctl-sep { display: none; }
  .topbar .meta.hide-sm { display: none; }
  .notebook { padding: 22px 18px 24px 56px; background:
    linear-gradient(to right, transparent 36px, var(--margin-red) 36px, var(--margin-red) 38px, transparent 38px), var(--card); }
  .pill-btn.copy span { display: none; }
  .pill-btn.copy { padding: 10px; }
}

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