/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-body: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;

  /* Liquid Glass Palette — white/grey, premium feel */
  --bg: #f0f0f3;
  --bg-pattern: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.8) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(200,200,210,0.3) 0%, transparent 50%);

  --glass-bg: rgba(255, 255, 255, 0.45);
  --glass-bg-hover: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --glass-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.05);
  --glass-blur: blur(20px) saturate(1.2);

  --text-primary: #1a1a2e;
  --text-secondary: #6b6b80;
  --text-tertiary: #9e9eb0;

  --accent: #2d2d3a;
  --accent-hover: #1a1a2e;
  --accent-light: rgba(45, 45, 58, 0.08);

  --danger: #c44b4b;
  --danger-hover: #a33a3a;
  --success: #3a8a5c;

  --border: rgba(0, 0, 0, 0.06);
  --border-input: rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-attachment: fixed;
  line-height: 1.6;
}

/* ===== GLASS CARD ===== */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.glass-card:hover {
  box-shadow: var(--glass-shadow-lg);
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  text-align: center;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.auth-card h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.error-text {
  font-size: var(--text-sm);
  color: var(--danger);
  margin-top: 12px;
}

/* ===== HEADER ===== */
.glass-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(240, 240, 243, 0.7);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.header-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-input);
}

.btn-ghost:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

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

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

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

/* ===== INPUTS ===== */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input,
.input-group textarea,
.input-group select,
.template-row select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: all var(--transition);
  outline: none;
  resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus,
.template-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 45, 58, 0.08);
  background: rgba(255, 255, 255, 0.8);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
  color: var(--text-tertiary);
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 40px;
}

.toggle-pw {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== STATS ===== */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== FORM CARD ===== */
.form-card {
  padding: 28px;
}

.form-card h2, .list-card h2, .dns-card h2, .domain-card h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.flex-1 { flex: 1; }

.at-symbol {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-tertiary);
  padding-bottom: 26px;
}

/* ===== DOMAIN CARD ===== */
.domain-card {
  padding: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-header h2 {
  margin-bottom: 0;
}

.domain-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.domain-form .btn {
  margin-bottom: 16px;
}

.provider-group {
  width: 150px;
  flex-shrink: 0;
}

.template-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: -4px 0 16px;
}

.template-row select {
  max-width: 260px;
  font-size: var(--text-sm);
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.domain-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.34);
}

.domain-name {
  font-size: var(--text-sm);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domain-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  margin-top: 3px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  background: rgba(158, 158, 176, 0.14);
  color: var(--text-secondary);
}

.status-pill.ok {
  color: var(--success);
  background: rgba(58, 138, 92, 0.1);
}

.status-pill.warn {
  color: #9a6a1f;
  background: rgba(154, 106, 31, 0.12);
}

.domain-actions,
.list-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.selected-count {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===== DNS CARD ===== */
.dns-card {
  padding: 28px;
}

.dns-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: -12px;
  margin-bottom: 20px;
}

.dns-record {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.dns-record-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dns-type-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.dns-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.dns-content {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  word-break: break-all;
  line-height: 1.5;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: rgba(0,0,0,0.03);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.dns-content:hover {
  background: rgba(0,0,0,0.06);
}

.dns-content:active::after {
  content: ' ✓ 已复制';
  color: var(--success);
  font-weight: 500;
}

/* ===== EMAIL LIST ===== */
.list-card {
  padding: 28px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.list-header h2 {
  margin-bottom: 0;
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: all var(--transition);
  color: var(--text-tertiary);
}

.search-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 45, 58, 0.08);
  background: rgba(255, 255, 255, 0.8);
}

.search-wrapper input {
  border: none;
  background: none;
  padding: 8px 0;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  width: 160px;
}

.search-wrapper input::placeholder {
  color: var(--text-tertiary);
}

.email-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.email-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.email-item:hover {
  background: rgba(255, 255, 255, 0.4);
}

.email-select {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.email-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.email-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  text-transform: uppercase;
}

.email-detail {
  min-width: 0;
}

.email-address {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-domain {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.email-note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.pin-mark {
  color: #9a6a1f;
  font-size: var(--text-xs);
  font-weight: 700;
  margin-right: 4px;
}

.email-actions {
  display: flex;
  gap: 2px;
  opacity: 1;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.empty-state svg {
  margin: 0 auto 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: var(--text-sm);
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 200ms ease;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  animation: slideUp 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-email {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-card p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== LOADING ===== */
.btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

/* ===== SKELETON ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-row {
  padding: 14px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-body);
  color: #fff;
  background: var(--accent);
  box-shadow: var(--glass-shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 20px;
}

.app-footer a {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color var(--transition);
}

.app-footer a:hover {
  color: var(--text-secondary);
}

/* ===== ADD RESULT ===== */
#add-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

#add-result.success {
  background: rgba(58, 138, 92, 0.08);
  color: var(--success);
  border: 1px solid rgba(58, 138, 92, 0.15);
}

#add-result.error {
  background: rgba(196, 75, 75, 0.08);
  color: var(--danger);
  border: 1px solid rgba(196, 75, 75, 0.15);
}

/* ===== FORWARD MODAL ===== */
.forward-desc {
  font-size: 13px;
  color: var(--text-secondary, #6b6b6b);
  margin: 0 0 12px;
}
.forward-list {
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
}
.forward-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  margin-bottom: 6px;
}
.forward-target-text {
  font-size: 14px;
  word-break: break-all;
}
.forward-empty {
  text-align: center;
  color: var(--text-secondary, #888);
  font-size: 13px;
  padding: 16px 0;
  margin: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .main-content { padding: 16px 16px 80px; }
  .form-card, .list-card, .dns-card, .domain-card { padding: 20px; }
  .form-row, .domain-form, .template-row { flex-direction: column; align-items: stretch; }
  .domain-form .btn { margin-bottom: 0; justify-content: center; }
  .domain-item { grid-template-columns: 1fr; }
  .domain-actions, .list-tools { width: 100%; flex-wrap: wrap; }
  .at-symbol { display: none; }
  .stats-row { grid-template-columns: 1fr; }
  .email-actions { opacity: 1; }
  .list-header { flex-direction: column; align-items: stretch; }
  .search-wrapper input { width: 100%; }
  .header-inner { padding: 12px 16px; }
}

/* ===== additions: saved password & options ===== */
.pwd-options { align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2, #444); cursor: pointer; user-select: none; }
.checkbox-row input { accent-color: #0d0d0d; }
.pw-label-input { flex: 1; min-width: 160px; padding: 8px 12px; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; background: rgba(255,255,255,.7); font: inherit; }
.saved-pw-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.saved-pw-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.5); border: 1px solid rgba(0,0,0,.06); }
.saved-pw-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.saved-pw-label { font-weight: 500; font-size: 14px; }
.saved-pw-secret { display: flex; align-items: center; gap: 6px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; color: var(--ink2, #444); }
.saved-pw-mask { user-select: all; }
.hint-text { font-size: 12px; color: var(--ink3, #888); margin-top: 6px; }
#saved-pw-select, #modal-saved-pw-select { padding: 8px 12px; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; background: rgba(255,255,255,.7); font: inherit; flex: 1; min-width: 200px; }
#saved-pw-select:disabled { opacity: .5; }
