:root {
  --bg-0: #0b1120;
  --bg-1: #0f172a;
  --glass: rgba(30, 41, 59, 0.55);
  --glass-brd: rgba(148, 163, 184, 0.14);
  --glass-brd-strong: rgba(148, 163, 184, 0.25);
  --text: #f1f5f9;
  --muted: #8da2bd;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;

  --open-a: #16a34a;
  --open-b: #4ade80;
  --close-a: #ea580c;
  --close-b: #fbbf24;
  --clear-a: #b91c1c;
  --clear-b: #f87171;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #15233f 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
}

/* Arka plan ışık küreleri */
.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.35; }
.orb-1 { width: 320px; height: 320px; background: #0ea5e9; top: -80px; right: -60px; animation: float1 14s ease-in-out infinite; }
.orb-2 { width: 280px; height: 280px; background: #6366f1; bottom: 10%; left: -90px; animation: float2 17s ease-in-out infinite; }
.orb-3 { width: 220px; height: 220px; background: #22c55e; bottom: -60px; right: -40px; opacity: 0.18; animation: float1 20s ease-in-out infinite; }
@keyframes float1 { 50% { transform: translateY(40px) translateX(-20px); } }
@keyframes float2 { 50% { transform: translateY(-30px) translateX(25px); } }

/* Uygulama kabuğu */
.app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
}

/* ---------- Üst bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 22px;
  color: #03263a;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 6px 18px -4px rgba(14, 165, 233, 0.6);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-size: 17px; font-weight: 800; letter-spacing: -0.2px; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }

.icon-btn {
  display: grid; place-items: center;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  color: var(--text);
  width: 46px; height: 46px;
  border-radius: 14px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform .12s ease, background .2s ease;
}
.icon-btn:active { transform: scale(.92); background: rgba(56, 189, 248, .15); }
.icon-btn-sm { width: 38px; height: 38px; border-radius: 11px; }

/* ---------- Durum kartı ---------- */
.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  transition: border-color .3s ease, box-shadow .3s ease;
}
.status-card.is-connected { border-color: rgba(34, 197, 94, .35); }
.status-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-texts { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.status-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.status-value { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { position: relative; width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
.dot-off { background: #64748b; }
.dot-connecting { background: var(--close-b); animation: blink 1s ease-in-out infinite; }
.dot-connecting::after { box-shadow: 0 0 0 0 rgba(251, 191, 36, .5); animation: ring 1.4s ease-out infinite; }
.dot-on { background: var(--open-b); box-shadow: 0 0 12px var(--open-b); }
.dot-on::after { box-shadow: 0 0 0 0 rgba(74, 222, 128, .5); animation: ring 1.8s ease-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
@keyframes ring { to { box-shadow: 0 0 0 14px rgba(74, 222, 128, 0); } }

/* ---------- Genel buton ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
  transition: transform .1s ease, filter .15s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.96); }
.btn-connect {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #03263a;
  box-shadow: 0 8px 20px -6px rgba(14, 165, 233, .55);
}
.btn-save { width: 100%; padding: 16px; font-size: 16px; }

/* ---------- Kontroller ---------- */
.controls { display: flex; flex-direction: column; gap: 14px; flex: 1; justify-content: center; }
.ctrl {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  color: #fff;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  min-height: 92px;
  box-shadow: var(--shadow);
  transition: transform .08s ease, filter .15s ease, opacity .2s ease;
}
.ctrl:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(.4); }
.ctrl:not(:disabled):active { transform: scale(.975); }
.ctrl.holding { transform: scale(.975); filter: brightness(1.18); }
.ctrl.holding .ctrl-glow { opacity: 1; }

.ctrl-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: rgba(0, 0, 0, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
  flex: none;
}
.ctrl-text { display: flex; flex-direction: column; gap: 2px; }
.ctrl-label { font-size: 23px; font-weight: 800; letter-spacing: 1.2px; line-height: 1; }
.ctrl-hint { font-size: 13px; font-weight: 500; opacity: .9; }

.ctrl-glow {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity .15s ease;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55), inset 0 0 40px rgba(255, 255, 255, .25);
  pointer-events: none;
}

.ctrl-open  { background: linear-gradient(135deg, var(--open-a), var(--open-b)); box-shadow: 0 12px 28px -10px rgba(34, 197, 94, .6); }
.ctrl-close { background: linear-gradient(135deg, var(--close-a), var(--close-b)); box-shadow: 0 12px 28px -10px rgba(245, 158, 11, .55); }
.ctrl-clear { background: linear-gradient(135deg, var(--clear-a), var(--clear-b)); box-shadow: 0 12px 28px -10px rgba(239, 68, 68, .55); min-height: 78px; }
.ctrl-clear .ctrl-icon { width: 48px; height: 48px; }
.ctrl-clear .ctrl-label { font-size: 19px; }

/* ---------- Mod rozeti ---------- */
.mode-badge {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.mode-badge strong { color: var(--accent); font-weight: 700; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ---------- Log ---------- */
.log-card {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 12px 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.log-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.log-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.link-btn { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px; }
.log {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  max-height: 110px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.6;
  scrollbar-width: thin;
}
.log:empty::before { content: "Henüz işlem yok."; opacity: .5; }
.log .ok { color: var(--open-b); }
.log .err { color: var(--clear-b); }

/* ---------- Footer ---------- */
.footer { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding-top: 2px; }
.footer span { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #5b6b85; }
.footer strong { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Ayarlar paneli ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 6, 18, .65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: relative;
  background: linear-gradient(180deg, #16203a 0%, #0f172a 100%);
  border: 1px solid var(--glass-brd-strong);
  border-bottom: none;
  width: 100%;
  max-width: 460px;
  border-radius: 26px 26px 0 0;
  padding: 14px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 -20px 50px -10px rgba(0, 0, 0, .6);
  animation: slideUp .28s cubic-bezier(.16, 1, .3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: rgba(148, 163, 184, .35); margin: 0 auto 4px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 800; }

.setting { display: flex; flex-direction: column; gap: 9px; }
.setting-label { font-size: 14px; font-weight: 700; }
.setting-desc { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }

.seg {
  display: flex;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--glass-brd);
  border-radius: 13px;
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  flex: 1; border: none; background: transparent;
  color: var(--muted);
  font-family: inherit;
  padding: 11px; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .2s ease;
}
.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #03263a;
  box-shadow: 0 4px 12px -3px rgba(14, 165, 233, .5);
}

input, select {
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--glass-brd);
  color: var(--text);
  font-family: inherit;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  width: 100%;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .15); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238da2bd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.hidden { display: none; }

/* Küçük ekran ince ayar */
@media (max-height: 680px) {
  .ctrl { min-height: 78px; padding: 16px 20px; }
  .ctrl-icon { width: 48px; height: 48px; }
  .ctrl-label { font-size: 20px; }
  .log { max-height: 80px; }
}
