:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --line: #e8e7e2;
  --line-strong: #d9d8d2;
  --text: #1d1d1b;
  --muted: #76756f;
  --primary: #1d1d1b;
  --primary-hover: #33332f;
  --accent: #3a7bf7;
  --accent-soft: #eaf1fe;
  --danger: #e5484d;
  --danger-hover: #d43b40;
  --danger-soft: #fdecec;
  --ok: #30a46c;
  --go: #22a55b;
  --go-hover: #1c9150;
  --video-bg: #ecebe6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 15, .04), 0 8px 24px rgba(20, 20, 15, .06);
  --shadow-pop: 0 4px 12px rgba(20, 20, 15, .08), 0 16px 40px rgba(20, 20, 15, .10);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }

/* ------------------------------------------------------------- iskelet */

.screen { min-height: 100vh; min-height: 100dvh; }
.screen-center { display: grid; place-items: center; padding: 32px 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
}
.auth-card { max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.profile-card { max-width: 560px; }
.card-head { margin-bottom: 8px; }
.card-head p { margin: 0; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; font-size: 17px; }
.brand-lg { font-size: 22px; justify-content: center; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--primary); position: relative; flex: none;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: 9px; width: 10px; height: 10px; border-radius: 50%;
}
.brand-mark::before { left: 5px; background: #fff; }
.brand-mark::after { left: 13px; border: 2px solid #fff; width: 10px; height: 10px; top: 9px; box-sizing: border-box; }
.brand-lg .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
.brand-lg .brand-mark::before, .brand-lg .brand-mark::after { top: 11px; width: 12px; height: 12px; }
.brand-lg .brand-mark::before { left: 6px; }
.brand-lg .brand-mark::after { left: 16px; }

/* ------------------------------------------------------------- form */

.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 500; color: #4a4a45; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 140px; gap: 14px; }

input[type=text], input[type=email], input[type=password], input[type=number] {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-error {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--danger-soft); color: #b42318; font-size: 13px;
}

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.sep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.google-btn { display: flex; justify-content: center; min-height: 44px; }

/* ------------------------------------------------------------- butonlar */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-lg { height: 52px; padding: 0 26px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary.btn-go { background: var(--go); }
.btn-primary.btn-go:hover:not(:disabled) { background: var(--go-hover); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }

.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn[aria-pressed="false"] { background: var(--danger-soft); border-color: #f6c9ca; color: var(--danger); }
.icon-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); width: 42px; height: 42px; }
.icon-btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.icon-btn-primary svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------- seçiciler */

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 4px; gap: 4px; border-radius: 14px; background: #f0efea;
}
.segmented button {
  height: 38px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 500; color: #55554f;
}
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; color: var(--text); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }

.picker { position: relative; }
.picker-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 44px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  cursor: text; transition: border-color .15s, box-shadow .15s;
}
.picker.open .picker-box, .picker-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.picker.disabled .picker-box { background: var(--surface-2); opacity: .6; pointer-events: none; }
.picker-box .picker-input {
  flex: 1; width: auto; min-width: 120px; height: 32px; border: 0; outline: 0; padding: 0 6px; background: transparent;
  font-size: 15px; font-weight: 400; box-shadow: none; border-radius: 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 6px 0 10px; border-radius: 99px;
  background: #f1f0eb; font-size: 14px; font-weight: 500; color: var(--text);
}
.chip img { width: 18px; height: 13.5px; border-radius: 2px; object-fit: cover; }
.chip button {
  width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; padding: 0;
  display: grid; place-items: center; color: var(--muted);
}
.chip button:hover { background: #e2e1db; color: var(--text); }
.chip button svg { width: 12px; height: 12px; }
.picker.single .chip { background: transparent; padding-left: 6px; font-size: 15px; }
.picker-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 260px; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop);
}
.picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left;
  font-size: 14px; font-weight: 400;
}
.picker-item img { width: 22px; height: 16.5px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.picker-item.active, .picker-item:hover { background: #f3f2ee; }
.picker-empty { padding: 10px; color: var(--muted); font-size: 14px; }

.flag { width: 22px; height: 16.5px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.08); vertical-align: middle; }

/* ------------------------------------------------------------- sohbet ekranı */

.chat-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; flex: none;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.online-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.online-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px #e3f4ea; }

.menu { position: relative; }
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  padding: 0; overflow: hidden; display: grid; place-items: center; font-weight: 600;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop);
  padding: 6px; display: flex; flex-direction: column;
}
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-pop button { text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; font-size: 14px; }
.menu-pop button:hover { background: #f3f2ee; }

.stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: 0 24px 24px;
}
.video-col { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; }

/* Görüntü kutuları her cihazda sabit 3:4 orandadır ve video kutuyu her zaman tamamen doldurur
   (cover): kamera hangi oranda gönderirse göndersin boşluk kalmaz, taşan kısım ortadan kırpılır.
   Kendi önizlemen de aynı oranda kırpıldığı için karşı taraf seni tam orada gördüğün gibi görür. */
.tiles {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  container-type: size;
}
.tile {
  position: relative; flex: none;
  width: 40%; height: 100%; /* container birimlerini desteklemeyen tarayıcılar için */
  width: min(calc(50cqw - 8px), calc(100cqh * 3 / 4));
  height: min(calc((50cqw - 8px) * 4 / 3), 100cqh);
  background: var(--video-bg); border-radius: 24px; overflow: hidden;
  border: 1px solid var(--line);
  isolation: isolate; -webkit-transform: translateZ(0); transform: translateZ(0);
}
.tile > video {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; background: var(--video-bg);
}
.tile-local > video { transform: scaleX(-1); }
.solo-status { display: none; }
/* Video üzerindeki yazılar arka plansız, beyaz; gölge her ışıkta okunur kılar. */
.tile-label, .peer-chip {
  position: absolute; left: 16px; top: 14px; z-index: 3;
  color: #fff; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.55), 0 0 12px rgba(0,0,0,.35);
  max-width: calc(100% - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.local-off { position: absolute; inset: 0; background: #dcdbd5; display: grid; place-items: center; color: var(--muted); }
.local-off svg { width: 26px; height: 26px; }

.tap-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 20px; border: 0; border-radius: 99px;
  background: rgba(29, 29, 27, .86); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.tap-play svg { width: 18px; height: 18px; }

.overlay {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 24px;
  background: var(--video-bg); text-align: center; transition: opacity .25s;
}
.overlay.clear { opacity: 0; pointer-events: none; }
.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 380px; }
.overlay-title { margin: 8px 0 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.overlay-sub { margin: 0; color: var(--muted); }


.controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex: none; flex-wrap: wrap; }
.controls-sep { width: 1px; height: 28px; background: var(--line-strong); margin: 0 4px; }
#btn-main { min-width: 150px; }


/* ------------------------------------------------------------- diğer */

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #dad9d3; border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px;
  box-shadow: var(--shadow-pop); max-width: calc(100% - 32px); text-align: center;
}

@media (max-width: 900px) {
  /* Mobilde ekran üst/alt ikiye bölünür: üstte karşı taraf, altta sen. İki kutu eşit boyuttadır;
     kontrol düğmeleri alttaki kutunun üzerinde yüzer, böylece videolara en fazla alan kalır. */
  .stage { padding: 0 6px calc(6px + env(safe-area-inset-bottom)); }
  .chat-screen.in-call .topbar { display: none; }
  .chat-screen.in-call .stage { padding-top: calc(6px + env(safe-area-inset-top)); }
  .topbar { padding: 10px 12px; }
  .video-col { position: relative; gap: 0; }
  .tiles {
    flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px;
    width: 100%; height: auto; margin: 0; container-type: normal;
  }
  .tile {
    flex: 1 1 0; min-height: 0; width: 100%; height: auto; border-radius: 18px;
  }
  .tile-label, .peer-chip { left: 14px; top: 10px; }
  .tiles.solo .tile-remote { display: none; }
  .tiles.solo .solo-status:not([hidden]) {
    display: flex; align-items: center; gap: 12px;
    position: absolute; left: 10px; right: 10px; top: 52px; z-index: 4;
    padding: 14px 16px; border-radius: 16px;
    background: rgba(255,255,255,.94); box-shadow: 0 4px 20px rgba(0,0,0,.12);
  }
  .solo-status .spinner { flex: none; width: 24px; height: 24px; }
  .solo-title { margin: 0; font-size: 15px; font-weight: 600; }
  .solo-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
  .solo-sub:empty { display: none; }
  .controls {
    position: absolute; left: 0; right: 0; bottom: 12px; z-index: 10;
    padding: 0 12px; flex-wrap: nowrap;
  }
  .controls .icon-btn { background: rgba(255,255,255,.92); }
  .controls .icon-btn[aria-pressed="false"] { background: #fdecec; }
  .toast { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }
}

@media (max-width: 520px) {
  .card { padding: 24px 18px; border-radius: 20px; }
  .grid-2 { grid-template-columns: 1fr 110px; }
  .btn-lg { height: 48px; padding: 0 18px; }
  #btn-main { min-width: 0; flex: 1; }
  #btn-stop { flex: 1; }
  .controls-sep { display: none; }
  .icon-btn { width: 46px; height: 46px; }
  .online-pill { height: 30px; padding: 0 10px; }
}
