/* ===== 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 {
  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;
}

.input-group input: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 {
  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 {
  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;
}

.password-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.btn-gen {
  flex-shrink: 0;
  white-space: nowrap;
  height: auto;
  align-self: stretch;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== EXPORT CHECKBOX ===== */
.export-check {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.export-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.export-check .checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-input);
  border-radius: 5px;
  background: rgba(255,255,255,0.5);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-check input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.export-check input:checked + .checkmark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

.export-check:hover .checkmark {
  border-color: var(--accent);
}

.email-item.selected {
  background: rgba(45, 45, 58, 0.04);
}

.exportable-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--success);
  background: rgba(58, 138, 92, 0.08);
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* ===== 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-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-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.email-item:hover .email-actions {
  opacity: 1;
}

/* ===== 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);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .main-content { padding: 16px 16px 80px; }
  .form-card, .list-card, .dns-card { padding: 20px; }
  .form-row { flex-direction: column; }
  .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; }
}
