:root {
  --bg: #0f1729;
  --bg-2: #16213a;
  --card: #1c2945;
  --line: #2c3b5e;
  --text: #f2f5fb;
  --muted: #9aa8c4;
  --accent: #4f8cff;
  --accent-2: #3a74e8;
  --ok: #2fbf71;
  --bad: #ff6b6b;
  --warn: #ffb547;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(1200px 600px at 50% -10%, #22345c 0%, var(--bg) 60%);
  background-attachment: fixed;
}

[hidden] { display: none !important; }

button, input { font-family: inherit; }

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
code { background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }

.screen { min-height: 100vh; padding: 24px 16px 40px; }
#setup { display: grid; place-items: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.narrow { width: 100%; max-width: 440px; text-align: center; }
.logo { width: 88px; height: 88px; border-radius: 22px; margin-bottom: 12px; }

label { display: block; text-align: left; margin: 14px 0 0; color: var(--muted); font-size: .9rem; }

input {
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-2);
}
.btn.primary { background: var(--accent); }
.btn.primary:active { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); padding: 8px 14px; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
#setupForm .btn { width: 100%; margin-top: 18px; }

.icon-btn {
  width: 52px; height: 52px;
  font-size: 1.5rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.msg { min-height: 1.3em; margin: 10px 0 0; font-weight: 600; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }
.msg.warn { color: var(--warn); }

/* Ana ekran */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto 28px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.clock { font-size: 3rem; font-weight: 700; letter-spacing: 1px; line-height: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  max-width: 1100px;
  margin: 24px auto 0;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.96); }
.tile-icon, .lock-icon {
  display: grid;
  place-items: center;
  width: 76px; height: 76px;
  border-radius: 20px;
  font-size: 2.4rem;
  position: relative;
}
.tile-icon::after {
  content: "🔒";
  position: absolute;
  right: -6px; bottom: -6px;
  font-size: 1rem;
  background: var(--bg);
  border-radius: 50%;
  padding: 3px;
}

/* Kilit ekranı */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 12, 24, .92);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}
.lock-panel { width: 100%; max-width: 460px; text-align: center; }
.lock-icon { width: 96px; height: 96px; font-size: 3rem; margin: 0 auto 14px; border-radius: 26px; }

.mic {
  width: 132px; height: 132px;
  margin: 26px auto 10px;
  display: grid;
  place-items: center;
  font-size: 3.4rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(79, 140, 255, .6);
}
.mic.listening { background: var(--bad); animation: pulse 1.3s infinite; }
.mic.success { background: var(--ok); animation: none; }
.mic:disabled { opacity: .4; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, .55); }
  70% { box-shadow: 0 0 0 28px rgba(255, 107, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}
.lock-panel.shake { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.heard { min-height: 1.5em; font-size: 1.15rem; margin: 6px 0 0; }

.typed { margin: 18px 0; color: var(--muted); }
.typed summary { cursor: pointer; padding: 6px; }
.typed form { display: flex; gap: 8px; margin-top: 8px; }
.typed input { margin: 0; }

/* Ayarlar */
.sheet {
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.gate { max-width: 360px; }
.gate .btn { margin-top: 10px; }
.block { padding: 18px 0; border-top: 1px solid var(--line); }

.row-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.row-form input { margin: 0; }
.voice-test { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.app-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.app-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
}
.app-list .name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.app-list .mini-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.4rem; flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font-size: .95rem;
  cursor: pointer;
}

.custom-form { display: grid; grid-template-columns: 70px 1fr; gap: 8px; }
.custom-form input { margin: 0; }
.custom-form #customLink { grid-column: 1 / -1; }
.custom-form .btn { grid-column: 1 / -1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  max-width: calc(100vw - 32px);
}

@media (max-width: 560px) {
  .clock { font-size: 2.3rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
  .row-form { grid-template-columns: 1fr; }
}
