/* ── Header ────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active,
.icon-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Layout Shell ───────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* ── Settings Panel ─────────────────────────── */
#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 80;
}

#backdrop.show {
  opacity: 1;
  visibility: visible;
}

#settings-panel {
  position: fixed;
  top: 0;
  right: -340px;
  width: 320px;
  height: 100%;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#settings-panel.open {
  right: 0;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.s-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.theme-row {
  display: flex;
  gap: 8px;
}

.theme-opt {
  flex: 1;
  padding: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}

.theme-opt.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(79, 110, 247, 0.08);
}

.s-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}

.s-select,
.s-range {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  margin-bottom: 12px;
  outline: none;
}

.s-select:focus {
  border-color: var(--primary);
}

.s-range {
  padding: 4px 0;
  border: none;
  background: none;
  accent-color: var(--primary);
}

.s-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-danger {
  width: 100%;
  padding: 10px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s;
}

.btn-danger:active {
  opacity: 0.8;
}

/* ── Mobile & Desktop Layout Tweaks ──────────────────────────── */
@media (max-width: 480px) {
  #settings-panel {
    width: 100%;
    right: -100%;
  }
}

@media (min-width: 700px) {
  .app-body {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  body {
    align-items: center;
  }

  .header {
    max-width: 720px;
    width: 100%;
  }
}