:root {
  --bg-base: #000000;
  --bg-surface: rgba(28, 28, 30, 0.75);
  --bg-surface-hover: rgba(44, 44, 46, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f5f5f7;
  --text-muted: #86868b;
  --primary: #0a84ff;
  --danger: #ff453a;
  --success: #30d158;
  --warning: #ff9f0a;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; font-family: var(--font); }

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.bg-blur {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 50% -20%, rgba(10, 132, 255, 0.12), transparent 60%);
}

.app {
  width: 100%; max-width: 580px; height: 100%;
  display: flex; flex-direction: column; position: relative; z-index: 1;
}

.app-header {
  flex-shrink: 0; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(28, 28, 30, 0.65);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  display: flex; justify-content: space-between; align-items: center;
}

.app-header h1 { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.2px; }

.content-area {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  scrollbar-width: none;
}
.content-area::-webkit-scrollbar { display: none; }

.ios-card {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.ios-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.ios-card-header h3 { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.2px; }
.ios-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.4; }

label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.35rem; font-weight: 500; }

input, select {
  width: 100%; padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 10px; color: var(--text-main);
  font-size: 0.9rem; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}
.ios-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 0.9rem center; background-size: 0.9rem;
}

.ios-btn {
  width: 100%; padding: 0.75rem; border: none; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.ios-btn:active { transform: scale(0.98); opacity: 0.85; }
.ios-btn.primary { background: var(--primary); color: #ffffff; box-shadow: 0 4px 15px rgba(10, 132, 255, 0.25); }
.ios-btn.secondary { background: var(--bg-surface-hover); color: var(--text-main); border: 1px solid var(--border-color); }
.ios-btn.danger { background: rgba(255, 69, 58, 0.12); color: var(--danger); border: 1px solid rgba(255, 69, 58, 0.2); }

.mt-2 { margin-top: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }

.ios-status { font-size: 0.75rem; margin-top: 0.5rem; color: var(--text-muted); text-align: center; min-height: 1em; }
.ios-status.err { color: var(--danger); }

.key-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 280px; overflow-y: auto; }
.key-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 10px; padding: 0.75rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.key-card-header {
  display: flex; justify-content: space-between; align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem; color: var(--primary); font-weight: 600;
}
.key-card-note { font-size: 0.8rem; color: var(--text-main); }
.key-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem;
}
.key-actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.key-actions button { padding: 0.3rem 0.5rem; font-size: 0.7rem; border-radius: 8px; width: auto; }

.ios-modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 1.25rem; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.ios-modal.active { opacity: 1; pointer-events: auto; }
.ios-modal-content {
  background: var(--bg-surface); border-radius: 16px; width: 100%; max-width: 340px;
  padding: 1.25rem; border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.ios-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.ios-modal-header h3 { font-size: 0.95rem; font-weight: 600; }
.ios-modal-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; }

.toast-container {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 0.4rem; width: 90%; max-width: 380px;
  pointer-events: none;
}
.toast {
  background: rgba(28, 28, 30, 0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color); color: var(--text-main);
  padding: 0.75rem 0.9rem; border-radius: 12px; font-size: 0.8rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); pointer-events: auto;
  animation: slideIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.toast.error { border-color: rgba(255, 69, 58, 0.3); color: var(--danger); }
.toast.success { border-color: rgba(48, 209, 88, 0.3); color: var(--success); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-15px); }
  to { opacity: 1; transform: translateY(0); }
}