:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --ok: #059669;
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 4px 16px rgb(15 23 42 / .05);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --surface: #121826;
    --surface-2: #1a2233;
    --border: #232c3d;
    --text: #e8ecf3;
    --muted: #94a3b8;
    --faint: #64748b;
    --accent: #818cf8;
    --accent-ink: #0b0f19;
    --accent-soft: #1e2140;
    --danger: #f87171;
    --ok: #34d399;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ---------- giriş ---------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.brand img { width: 56px; height: 56px; border-radius: 16px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
  font-size: 16px; /* iOS zoom'u engeller */
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; min-height: 76px; padding: 10px 14px; resize: vertical; }
.btn {
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .06s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 12px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 16px; }
.linkish { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 4px; }

.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 4px; }
.otp input {
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
  padding: 0;
  min-width: 0;
}
.otp input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- ana ekran ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.top-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px 10px; }
.top-row { display: flex; align-items: center; gap: 10px; }
.top-row .logo { width: 30px; height: 30px; border-radius: 9px; }
.top-row h1 { font-size: 18px; margin: 0; letter-spacing: -.02em; flex: 1; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-grid;
  place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.search {
  margin-top: 10px;
  position: relative;
}
.search svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--faint); pointer-events: none; }
.search .input { padding-left: 38px; height: 42px; background: var(--surface); }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

main { max-width: 1120px; margin: 0 auto; padding: 8px 16px calc(32px + env(safe-area-inset-bottom)); }
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 22px 4px 10px;
  display: flex;
  justify-content: space-between;
}
.grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-row { display: flex; align-items: center; min-width: 0; }
.card-row .edit { flex: none; margin-right: 8px; }
.card-main { display: flex; gap: 12px; padding: 12px 10px 12px 12px; align-items: center; min-width: 0; flex: 1; }
.card-main:hover .card-title { color: var(--accent); }
.app-icon {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 13px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.app-icon.letter {
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px; color: #fff; border: 0;
}
.card-text { min-width: 0; flex: 1; }
.card-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .15s; }
.card-desc { color: var(--muted); font-size: 13px; line-height: 1.35; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-host { color: var(--faint); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-ic { flex: none; width: 18px; height: 18px; color: var(--faint); }

.creds {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  min-height: 44px;
}
.cred {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  flex: 0 1 auto;
}
.cred span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.cred svg { flex: none; width: 14px; height: 14px; color: var(--muted); }
.creds .spacer { flex: 1; }
.mini { width: 30px; height: 30px; border-radius: 9px; border: 1px solid transparent; background: none; display: inline-grid; place-items: center; color: var(--muted); }
.mini:hover { background: var(--surface); border-color: var(--border); }
.mini svg { width: 15px; height: 15px; }
.no-creds { color: var(--faint); font-size: 12.5px; padding-left: 4px; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- alt pencere ---------- */
.sheet-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(2 6 23 / .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 22px; }
}
.sheet h2 { margin: 0 0 16px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions .btn-primary { width: auto; flex: 1; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list .btn { justify-content: flex-start; width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td:first-child { color: var(--faint); white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); translate: -50% 20px;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; z-index: 80;
}
#toast.show { opacity: 1; translate: -50% 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.note-box { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; user-select: text; }
