:root {
  --brand: #3b6ef5;
  --brand-2: #5b8cff;
  --brand-soft: #e8eefe;
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f1;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --field: #f7f9fc;
  --field-line: #d3dce8;
  --glow-1: rgba(59, 110, 245, .16);
  --glow-2: rgba(124, 58, 237, .10);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --card: #131d31; --ink: #e8eef8; --muted: #97a6bd; --line: #22314f; --field: #0f192c;
    --field-line: #2b3b5c; --brand-soft: #1c2b4f; --glow-1: rgba(76, 125, 247, .18); --glow-2: rgba(124, 58, 237, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --card: #131d31; --ink: #e8eef8; --muted: #97a6bd; --line: #22314f; --field: #0f192c;
  --field-line: #2b3b5c; --brand-soft: #1c2b4f; --glow-1: rgba(76, 125, 247, .18); --glow-2: rgba(124, 58, 237, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 0% -10%, var(--glow-1), transparent 60%),
    radial-gradient(800px 520px at 100% 0%, var(--glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
code { font-family: Consolas, "SF Mono", Menlo, monospace; background: var(--field); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------------- ana ekran ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1080px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 20px; letter-spacing: -.2px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: url(icon.svg) center/cover; box-shadow: 0 6px 16px rgba(59, 110, 245, .35); }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.server-state {
  display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.server-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
.server-state.ok i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.server-state.bad i { background: var(--bad); }
@media (max-width: 480px) { .server-state span { display: none; } .server-state { padding: 9px; } .brand { font-size: 18px; } }
.ghost {
  background: var(--card); border: 1px solid var(--line); color: var(--ink); padding: 6px 12px; border-radius: 999px;
  max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px;
}
.ghost:hover { border-color: var(--brand-2); }
.ghost svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; color: var(--muted); }

.home-grid {
  max-width: 1080px; margin: 0 auto; padding: 18px 16px 40px;
  display: grid; gap: 18px; grid-template-columns: 1.15fr 1fr; grid-template-areas: "connect recent" "connect share";
}
.connect-card { grid-area: connect; }
.recent-card { grid-area: recent; }
.share-card { grid-area: share; }
@media (max-width: 820px) {
  .home-grid { grid-template-columns: 1fr; grid-template-areas: "connect" "recent" "share"; padding-top: 12px; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); min-width: 0; }
.card h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.4px; margin: 0 0 8px; }
.card h2 { font-size: 17px; letter-spacing: -.2px; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
@media (max-width: 480px) { .card { padding: 20px; } .card h1 { font-size: 22px; } }
.field { display: block; margin: 18px 0 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--field-line); background: var(--field);
  font-size: 20px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
#pid { font-size: 28px; font-weight: 650; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.field input:focus { border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.seg { display: flex; gap: 4px; margin-top: 18px; background: var(--field); border: 1px solid var(--field-line); border-radius: 12px; padding: 4px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s; }
.seg input:checked + span { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--brand-2); }
.primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; border: 0; border-radius: 12px; padding: 10px 16px;
  font-weight: 600; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent); transition: filter .15s, transform .05s, box-shadow .15s;
}
.primary:hover { filter: brightness(1.06); box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 45%, transparent); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: default; }
.primary.big { width: 100%; margin-top: 20px; padding: 15px; font-size: 17px; }
.msg { min-height: 22px; margin-top: 12px; font-size: 14px; }
.msg.err { color: var(--bad); }
.msg.info { color: var(--muted); }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-radius: 12px; }
.recent li:hover { background: var(--field); }
.recent .empty { color: var(--muted); font-size: 14px; padding: 4px 8px; }
.recent .empty:hover { background: none; }
.recent .av { position: relative; flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.recent .av i { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #9aa6b4; border: 2px solid var(--card); }
.recent .av i.on { background: var(--ok); }
.recent .who { flex: 1; min-width: 0; cursor: pointer; }
.recent .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.recent .who span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn { background: transparent; border: 0; width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.steps { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.steps small { display: block; margin-top: 2px; word-break: break-all; }
.downloads { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.dl-tile {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); border: 1px solid var(--line);
  background: var(--field); border-radius: 14px; padding: 12px 14px; transition: border-color .15s, transform .1s;
}
.dl-tile:hover { border-color: var(--brand-2); }
.dl-tile:active { transform: translateY(1px); }
.dl-ic { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.dl-ic svg { width: 20px; height: 20px; }
.dl-txt b { display: block; font-weight: 600; }
.dl-txt small { color: var(--muted); }
.note { margin: 0; }

/* ---------------- oturum ---------------- */
#session { position: fixed; inset: 0; background: #0b0f14; color: #e8edf3; overflow: hidden; touch-action: none; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#screen { position: absolute; left: 0; top: 0; transform-origin: 0 0; image-rendering: auto; outline: none; background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.05); }
#rcursor {
  position: absolute; left: 0; top: 0; width: 20px; height: 20px; pointer-events: none; z-index: 3;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M2 1l14 9-6 1.4 3.6 6.5-2.4 1.3-3.6-6.6L2 16z' fill='%23fff' stroke='%23000' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.5));
}
#waitMsg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: #9fb0c3; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--brand-2); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 4px; max-width: calc(100vw - 16px);
  background: rgba(22, 29, 39, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 5px 6px 5px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.tb-title { display: flex; flex-direction: column; line-height: 1.15; padding-right: 8px; margin-right: 2px; border-right: 1px solid rgba(255,255,255,.1); min-width: 0; }
.tb-title b { font-size: 13px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.stats { font-size: 11px; color: #9fb0c3; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-buttons { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; }
.tb-buttons::-webkit-scrollbar { display: none; }
.tb-fixed { display: flex; padding-left: 4px; margin-left: 2px; border-left: 1px solid rgba(255,255,255,.1); }
@media (max-width: 640px) {
  .toolbar { left: 8px; right: 8px; transform: none; max-width: none; padding-left: 6px; }
  .tb-title { display: none; }
  .tb-btn { width: 38px; }
}
.tb-btn {
  position: relative; flex: none; background: transparent; border: 0; color: #dbe3ec; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
}
.tb-btn:hover { background: rgba(255,255,255,.1); }
.tb-btn.on { background: rgba(61,143,232,.25); color: #8fc2ff; }
.tb-btn.danger { color: #ff8b8b; }
.tb-btn.danger:hover { background: rgba(210,63,63,.25); }
.tb-btn svg { width: 20px; height: 20px; }
.tb-btn .badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; font-weight: 700; }
.tb-btn[disabled] { opacity: .35; cursor: default; }
.tb-collapse, .tb-show { background: transparent; border: 0; color: #9fb0c3; width: 28px; height: 40px; display: grid; place-items: center; }
.tb-collapse svg, .tb-show svg { width: 18px; height: 18px; }
.tb-show {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 10; width: 56px; height: 22px;
  background: rgba(22, 29, 39, .85); border-radius: 0 0 10px 10px; border: 1px solid rgba(255,255,255,.1); border-top: 0;
}

.menu {
  position: absolute; z-index: 20; min-width: 230px; max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto;
  background: #19212c; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 0; color: #e8edf3; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
.menu .mi:hover { background: rgba(255,255,255,.08); }
.menu .mi .chk { width: 18px; color: #8fc2ff; text-align: center; flex: none; }
.menu .mi small { margin-left: auto; color: #8a99ab; font-size: 12px; }
.menu .sep { height: 1px; background: rgba(255,255,255,.08); margin: 5px 4px; }
.menu .hdr { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #8a99ab; padding: 8px 10px 4px; }

.keysbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; gap: 6px; overflow-x: auto; padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(22, 29, 39, .95); border-top: 1px solid rgba(255,255,255,.1); scrollbar-width: none;
}
.keysbar button { flex: none; min-width: 46px; height: 40px; padding: 0 10px; border-radius: 9px; border: 1px solid rgba(255,255,255,.12); background: #222c39; color: #e8edf3; font-size: 14px; }
.keysbar button.on { background: var(--brand); border-color: var(--brand-2); }
.keysbar button:active { background: #2d3a4b; }
#kbd { position: absolute; left: -1000px; top: 40%; width: 10px; height: 10px; opacity: 0; font-size: 16px; }

.panel {
  position: absolute; z-index: 15; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); display: flex; flex-direction: column;
  background: #141b24; border-left: 1px solid rgba(255,255,255,.1); box-shadow: -10px 0 40px rgba(0,0,0,.4);
  padding-top: env(safe-area-inset-top);
}
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.panel header h3 { margin: 0; font-size: 16px; }
.panel .icon-btn { color: #9fb0c3; }
.panel .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.panel-body { flex: 1; overflow: auto; display: flex; flex-direction: column; min-height: 0; }

.fm-bar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.fm-path { flex: 1; min-width: 0; font-size: 12px; color: #9fb0c3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.fm-list { flex: 1; overflow: auto; padding: 4px 6px; min-height: 120px; }
.fm-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.fm-row:hover { background: rgba(255,255,255,.06); }
.fm-row svg { width: 18px; height: 18px; flex: none; color: #8fc2ff; }
.fm-row.file svg { color: #9fb0c3; }
.fm-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-row .s { font-size: 12px; color: #8a99ab; white-space: nowrap; }
.fm-empty { color: #8a99ab; padding: 18px 10px; font-size: 14px; }
.fm-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); display: flex; gap: 8px; }
.fm-foot .primary { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: none; }
.fm-foot svg { width: 18px; height: 18px; }
.transfers { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.tr { background: #1b2430; border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.tr .row { display: flex; align-items: center; gap: 8px; }
.tr .row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr .bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); margin-top: 6px; overflow: hidden; }
.tr .bar i { display: block; height: 100%; background: var(--brand-2); width: 0; transition: width .2s; }
.tr.done .bar i { background: var(--ok); }
.tr.err .bar i { background: var(--bad); }
.tr .st { color: #8a99ab; font-size: 12px; margin-top: 4px; }

.chat-list { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 8px 11px; border-radius: 12px; background: #222c39; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--brand); }
.bubble small { display: block; font-size: 11px; color: rgba(255,255,255,.6); margin-bottom: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.chat-form input { flex: 1; min-width: 0; background: #0f151d; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 10px 12px; color: #fff; outline: none; font-size: 16px; }
.chat-form .primary { box-shadow: none; }

/* ---------------- ortak ---------------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: #1e2733; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.08); animation: tin .2s ease-out; text-align: center; }
.toast.err { background: #5b1f1f; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.dlg { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--card); color: var(--ink); width: min(440px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.dlg.dark { background: #19212c; color: #e8edf3; border-color: rgba(255,255,255,.12); }
.dlg::backdrop { background: rgba(5, 10, 18, .55); }
.dlg form { padding: 22px; margin: 0; }
.dlg h3 { margin: 0 0 10px; font-size: 18px; }
.dlg p { margin: 0 0 12px; }
.dlg textarea, .dlg input[type=text], .dlg input[type=password] { width: 100%; border: 1px solid var(--field-line); background: var(--field); border-radius: 10px; padding: 10px 12px; outline: none; font-size: 16px; }
.dlg.dark textarea, .dlg.dark input { background: #0f151d; border-color: rgba(255,255,255,.14); }
.dlg textarea { min-height: 120px; resize: vertical; }
.dlg .btns { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; margin-top: 16px; }
.dlg .btns button { border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line); background: transparent; }
.dlg.dark .btns button { border-color: rgba(255,255,255,.14); }
.dlg .btns .primary { border: 0; }
