:root {
  --bg: #0a0e14;
  --bg2: #0f141c;
  --card: #151b25;
  --card2: #1c2431;
  --border: #2a3444;
  --txt: #e8ecf1;
  --muted: #8a94a6;
  --p: #3b82f6;
  --p2: #60a5fa;
  --ok: #10b981;
  --warn: #fbbf24;
  --err: #ef4444;
  --tr: cubic-bezier(.4, 0, .2, 1);
  --radius-lg: 18px;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed;
  color: var(--txt);
  min-height: 100vh;
  line-height: 1.45;
  padding: max(14px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--p2); outline-offset: 2px; }
.hidden { display: none !important; }

.app { width: 100%; max-width: 620px; margin: 0 auto; }

/* Üst bar */
header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 22px; }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--txt); text-decoration: none; letter-spacing: -.02em; }
.logo span { color: var(--p2); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: var(--card2); border: 1px solid var(--border); color: var(--muted);
}
.badge[data-state="ok"] { border-color: var(--ok); color: var(--ok); }
.badge[data-state="busy"] { border-color: var(--p2); color: var(--p2); }
.badge[data-state="warn"] { border-color: var(--warn); color: var(--warn); }
.badge[data-state="err"] { border-color: var(--err); color: var(--err); }
#lockBadge { border-color: var(--ok); color: var(--ok); }

/* Ana ekran */
.hero { margin: 8px 0 22px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.15; letter-spacing: -.02em; max-width: 18ch; }
.hero p { color: var(--muted); margin-top: 10px; max-width: 46ch; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 18px; cursor: pointer; transition: border-color .2s var(--tr), transform .2s var(--tr);
}
.choice:hover { border-color: var(--p2); transform: translateY(-2px); }
.choice b { font-size: 1.2rem; }
.choice small { color: var(--muted); }
.choice-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; background: var(--p); color: #fff;
}
.choice.recv .choice-icon { background: var(--ok); }

/* Kart */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 12px;
}

/* Durum satırı */
.status {
  display: flex; align-items: flex-start; gap: 10px; font-weight: 650; font-size: .95rem;
  padding: 12px 14px; border-radius: var(--radius); background: var(--card2);
}
.status i { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: .42em; background: var(--muted); }
.status[data-state="busy"] i { background: var(--p2); animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="ok"] i { background: var(--ok); }
.status[data-state="warn"] i { background: var(--warn); }
.status[data-state="err"] i { background: var(--err); }
.status[data-state="err"] { color: #fca5a5; }
@keyframes pulse { 50% { opacity: .3; } }

/* Oda kodu: sayfanın en belirgin öğesi */
.room { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card > .room, .card > .field, .card > .inline-form { margin-top: 16px; }
.room-label { color: var(--muted); font-size: .85rem; }
.room-code {
  font-size: clamp(2.4rem, 11vw, 3.4rem); font-weight: 900; letter-spacing: .14em; color: var(--p2);
  font-variant-numeric: tabular-nums; line-height: 1.1; margin: 2px 0 10px;
}
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qr { background: #fff; padding: 8px; border-radius: var(--radius); line-height: 0; }
.qr:empty { display: none; }
.qr img, .qr canvas { width: 148px; height: 148px; }

/* Alanlar */
.field { display: grid; gap: 6px; }
.field span { font-size: .85rem; font-weight: 650; }
.field small { color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="password"] {
  width: 100%; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg2); outline: none; transition: border-color .2s var(--tr);
}
input:focus { border-color: var(--p2); }
input:disabled { opacity: .55; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.code-input { font-size: 1.3rem; font-weight: 800; letter-spacing: .25em; text-transform: uppercase; text-align: center; }

/* Butonlar */
.btn {
  border: 1px solid transparent; border-radius: var(--radius); padding: 11px 18px; font-size: .9rem; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .2s var(--tr), border-color .2s var(--tr), opacity .2s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-p { background: var(--p); color: #fff; }
.btn-p:hover:not(:disabled) { background: #2f6fdb; }
.btn-ghost { background: var(--card2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--p2); }
.btn-sm { padding: 7px 12px; font-size: .8rem; }
.btn-quiet { background: none; color: var(--muted); width: 100%; }
.btn-quiet:hover { color: var(--err); }

/* Bırakma alanı */
.drop {
  display: grid; justify-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 26px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  transition: border-color .2s var(--tr), background .2s var(--tr);
}
.drop:hover, .drop.over { border-color: var(--p2); background: rgba(96, 165, 250, .06); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop:focus-within { border-color: var(--p2); }
.drop small { color: var(--muted); }

/* Dosya listesi */
.files { list-style: none; display: grid; gap: 10px; }
.files:not(:empty) { margin-top: 14px; }
#rFiles:not(:empty) { margin-top: 0; }
.files li { background: var(--card2); border-radius: var(--radius); padding: 11px 13px; }
.f-top, .f-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.f-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.f-meta { color: var(--muted); font-size: .8rem; flex: none; font-variant-numeric: tabular-nums; }
.f-status { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.f-action:empty { display: none; }
.bar { height: 6px; border-radius: 99px; background: var(--bg2); overflow: hidden; margin: 8px 0 6px; }
.bar > div { height: 100%; width: 0; background: var(--p2); border-radius: inherit; transition: width .2s linear; }
.files li[data-state="done"] .bar > div { background: var(--ok); }
.files li[data-state="done"] .f-status { color: var(--ok); }
.files li[data-state="error"] .bar > div { background: var(--err); }
.files li[data-state="error"] .f-status { color: #fca5a5; }

/* Bildirim */
.toast {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 999;
  transform: translateX(-50%) translateY(120px); opacity: 0; max-width: calc(100% - 28px);
  background: var(--card2); border: 1px solid var(--border); padding: 11px 18px; border-radius: var(--radius);
  font-size: .88rem; font-weight: 700; transition: transform .3s var(--tr), opacity .3s var(--tr);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--ok); }
.toast.warn { border-color: var(--warn); }
.toast.err { border-color: var(--err); }

@media (max-width: 420px) {
  .choice { padding: 18px 14px; }
  .room { justify-content: center; text-align: center; }
  .room-actions { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
