:root {
  --bg: #f3f5f8; --card: #fff; --fg: #162033; --mut: #667085; --line: #e3e7ee; --soft: #eef1f6;
  --acc: #2058d6; --acc-fg: #fff; --cool: #2f7fe8; --heat: #e8742f; --ok: #1d8a52; --bad: #c63b2f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --card: #161b22; --fg: #e6e9ee; --mut: #9aa4b2; --line: #2a313c; --soft: #1f2630;
    --acc: #5b8cff; --acc-fg: #0d1117; --cool: #5aa2ff; --heat: #ff9a5c; --ok: #4fca88; --bad: #ff7a6e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
.bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  max-width: 520px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; background: var(--bg);
}
.bar h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
main { max-width: 520px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }
.mut { color: var(--mut); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 32px 0; }
.link { background: none; border: 0; color: var(--acc); padding: 6px 4px; font-weight: 600; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; margin: 12px 0 16px; box-shadow: var(--shadow);
}
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.head h2 { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.status { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--mut); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }

/* Termostat */
.thermo { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; margin: 18px 0 6px; }
.round {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--soft);
  font-size: 28px; line-height: 1; display: grid; place-items: center; justify-self: center;
}
.round:active:not(:disabled) { transform: scale(.96); }
.temp { text-align: center; font-size: 64px; font-weight: 300; letter-spacing: -.03em; line-height: 1; }
.temp sup { font-size: 26px; vertical-align: 28px; margin-left: 2px; }
.temp.off { color: var(--mut); }
.temp.cool { color: var(--cool); }
.temp.heat { color: var(--heat); }
.sub { text-align: center; color: var(--mut); font-size: 14px; min-height: 20px; }
.power {
  display: block; width: 100%; margin: 16px 0 4px; padding: 14px; border-radius: 14px; border: 0;
  background: var(--acc); color: var(--acc-fg); font-weight: 650; font-size: 17px;
}
.power.is-on { background: var(--soft); color: var(--fg); border: 1px solid var(--line); }
.label { font-size: 13px; color: var(--mut); margin: 14px 0 6px; font-weight: 600; letter-spacing: .02em; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 9px 2px; font-size: 14px; color: var(--mut); }
.seg button.sel { background: var(--card); color: var(--fg); font-weight: 650; box-shadow: var(--shadow); }
.foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--mut); }
.foot b { color: var(--fg); font-weight: 600; }

/* Tuşlar */
.keys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.key {
  border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 9px 14px; font-size: 15px;
  display: inline-flex; align-items: center; gap: 8px;
}
.key.add { background: none; border-style: dashed; color: var(--acc); font-weight: 600; }
.key .x { color: var(--bad); font-weight: 700; }
.panel { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--soft); }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row > * { flex: 1; }
input[type=text], input[type=password], select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 16px;
}
.btn { border: 0; border-radius: 10px; padding: 12px; background: var(--acc); color: var(--acc-fg); font-weight: 650; }
.btn.alt { background: var(--card); color: var(--fg); border: 1px solid var(--line); }
details { margin-top: 12px; }
summary { color: var(--acc); font-weight: 600; font-size: 14px; cursor: pointer; }

/* Giriş */
.login { max-width: 360px; margin: 48px auto 0; }
.login h2 { margin: 0 0 4px; font-size: 20px; }
.login label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.login .btn { width: 100%; margin-top: 18px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 10px; }

#bildirim {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
#bildirim.show { opacity: 1; transform: translate(-50%, 0); }
#bildirim.bad { background: var(--bad); color: #fff; }
