/* ── Top Header ─────────────────────────────────── */
.ksi-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.ksi-header__logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.ksi-header__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.ksi-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Bottom Nav ─────────────────────────────────── */
.ksi-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.ksi-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  position: relative;
  user-select: none;
}

.ksi-nav__item:active { transform: scale(0.82); }

.ksi-nav__item.active {
  color: var(--accent);
}

.ksi-nav__item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  animation: nav-indicator 0.2s ease forwards;
}

@keyframes nav-indicator {
  from { opacity: 0; transform: scaleX(0.4); }
  to   { opacity: 1; transform: scaleX(1); }
}

.ksi-nav__icon {
  font-size: 22px;
  line-height: 1;
}

/* ── Page Wrapper ───────────────────────────────── */
.ksi-page {
  padding-top: calc(var(--header-h) + 12px);
  padding-bottom: calc(var(--nav-h) + 12px);
  padding-left: 16px;
  padding-right: 16px;
  min-height: 100svh;
}

/* Full-height pages (e.g. AI chat) remove default padding */
.ksi-page.no-pad {
  padding: 0;
  overflow: hidden;
  height: calc(100svh - var(--header-h) - var(--nav-h));
  height: calc(100dvh - var(--header-h) - var(--nav-h)); /* dvh tracks keyboard on modern browsers */
  min-height: unset;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-sm {
  padding: 12px;
  border-radius: var(--radius-sm);
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-full { width: 100%; }

/* ── Inputs ─────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: rgba(74,222,128,0.15); color: var(--success); }
.badge-error   { background: rgba(248,113,113,0.15); color: var(--error); }
.badge-info    { background: rgba(96,165,250,0.15);  color: var(--info); }
.badge-accent  { background: var(--accent-dim);      color: var(--accent); }

/* ── Section title ──────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* ── Overflow menu (profile dropdown) ──────────── */
.ksi-menu {
  position: fixed;
  top: calc(var(--header-h) + 6px);
  right: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.96);
  transform-origin: top right;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.ksi-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ksi-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.ksi-menu__item:last-child { border-bottom: none; }
.ksi-menu__item:hover { background: var(--surface); }
.ksi-menu__item.danger { color: var(--error); }

/* ── Divider ────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* ── Empty state ────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty__icon { font-size: 40px; margin-bottom: 12px; }
