/* YouTypeFree — Modern minimal UI system */

/* Design tokens */
:root {
  --bg: #ffffff;
  --text: #0f172a;           /* slate-900 */
  --muted: #64748b;          /* slate-500 */
  --surface: #f8fafc;        /* slate-50 */
  --border: #e2e8f0;         /* slate-200 */

  --primary: #6366f1;        /* indigo-500 */
  --primary-600: #4f46e5;    /* indigo-600 */
  --primary-700: #4338ca;    /* indigo-700 */
  --accent: linear-gradient(90deg, #6366f1, #8b5cf6);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius: 12px;
  --shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.06);
  --shadow-md: 0 8px 24px rgba(2, 6, 23, 0.08);
  --shadow-lg: 0 18px 40px rgba(2, 6, 23, 0.12);
}

[data-theme="dark"] {
  --bg: #0b1020;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --surface: #0f172a;
  --border: #1f2937;

  --primary: #818cf8;
  --primary-600: #7c3aed;
  --primary-700: #6d28d9;
  --accent: linear-gradient(90deg, #7c3aed, #22d3ee);

  --shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.35);
  --shadow-md: 0 8px 24px rgba(2, 6, 23, 0.45);
  --shadow-lg: 0 18px 40px rgba(2, 6, 23, 0.55);
}

/* Reset & base */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; border-style: none; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(6px);
}

.header .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
}

.logo i {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  border-radius: 10px;
  padding: 10px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Auth */
.auth-btn, .user-button, .btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: all .2s ease;
}

.auth-btn:hover, .user-button:hover, .btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.auth-btn.login-btn { background: transparent; }

.auth-btn.register-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.auth-btn.register-btn:hover {
  background: var(--primary-600);
  border-color: var(--primary-600);
}

/* User dropdown */
.user-menu { position: relative; }
.user-button { display: inline-flex; align-items: center; gap: 8px; }
.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: none;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.user-dropdown a:hover { background: var(--bg); }
/* NEW: 支持点击展开 */
.user-dropdown.show { display: block; }

/* Theme toggle */
.theme-toggle {
  border: none;
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  border-radius: 12px;
}

.theme-toggle:hover { background: var(--surface); color: var(--text); }

/* Hero */
.hero {
  padding: 64px 0 24px;
  text-align: left;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
}

.hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.gradient-text {
  background: var(--accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Primary action buttons */
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  transition: all .2s ease;
}

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

.hero-btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.hero-btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* TTS Section */
.tts-section { padding: 28px 0 8px; }

.tts-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.tts-row {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.tts-row label { font-weight: 600; color: var(--text); }
.tts-row .char-count { color: var(--muted); font-size: 13px; }
/* 超限时高亮为红色，便于用户及时发现 */
.tts-row .char-count.over { color: #ef4444; }

.tts-row textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.tts-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.grid-3 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 860px) {
  .grid-3 { grid-template-columns: 1fr; }
}

.tts-row select, .profile-form select,
.tts-row input[type="text"], .profile-form input[type="text"],
.profile-form input[type="email"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.tts-row select:focus, .profile-form select:focus,
.profile-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

/* Upload */
.file-upload {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-btn {
  appearance: none;
  border: 1px dashed var(--primary);
  background: rgba(99, 102, 241, .08);
  color: var(--primary-700);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all .2s ease;
}

.upload-btn:hover {
  background: rgba(99, 102, 241, .15);
  box-shadow: var(--shadow-sm);
}

.file-name { color: var(--muted); font-size: 14px; }

/* Results */
.results { margin-top: 10px; }

.audio-player {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.results-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.download-btn, .new-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  transition: all .2s ease;
}

.download-btn:hover, .new-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.notice { color: var(--warning); }

/* Pricing */
.pricing { padding: 28px 0; }

.section-header h2 { margin: 0 0 6px; font-size: 24px; }
.section-header p { margin: 0; color: var(--muted); }

.pricing-grid {
  margin-top: 14px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .pricing-grid { grid-template-columns: 1fr; }
}

.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.pricing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.pricing-card.popular {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.pricing-card h3 { margin: 0 0 6px; font-size: 18px; }
.pricing-card .price { margin: 0 0 8px; font-weight: 800; font-size: 26px; }
.pricing-card ul { margin: 8px 0 12px; padding-left: 18px; color: var(--muted); }

.plan-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  transition: all .2s ease;
}

.plan-button:hover { background: var(--primary-600); border-color: var(--primary-600); }

/* Policies */
.plan-table { margin-top: 16px; }
.plan-table table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.plan-table th, .plan-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.plan-table thead th { background: var(--bg); font-weight: 700; }
.plan-table .yes i { color: #10b981; }
.plan-table .no i { color: #ef4444; }

.policies { padding: 20px 0; }
.policies { margin-top: 24px; }

.policy-container { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 14px; }
.policy-title { font-weight: 700; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.policy-grid { display: grid; gap: 8px 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.policy-col { display: flex; flex-direction: column; gap: 6px; }
.policy-link { display: flex; align-items: center; gap: 10px; padding: 6px 2px; color: var(--text); text-decoration: none; border-radius: 8px; }
.policy-link i { color: var(--muted); }
.policy-link:hover { color: var(--primary-600); background: var(--bg); }

@media (max-width: 980px) { .policy-grid { grid-template-columns: 1fr; } }

/* Footer */
.footer {
  margin-top: 30px;
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--muted);
}

/* Modal overlay（全局生效） */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55); /* 略微加深，提高对比 */
  display: none;            /* 由 JS 切换为 flex */
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  backdrop-filter: saturate(140%) blur(6px);
}

/* 弹窗容器：卡片风格，非透明 */
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(680px, 100%);
  max-height: 80vh;
  overflow: auto;
  background-clip: padding-box;
}
.modal.auth-modal { width: min(520px, 100%); }
.modal.dashboard-modal { width: min(920px, 100%); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.modal-body { padding: 16px; }

/* 关闭按钮风格 */
.modal-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s ease;
}
.modal-close:hover {
  border-color: var(--primary);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Dashboard 内卡片与列表/网格与全站一致 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px; /* 为弹窗内卡片补充内边距 */
}

/* 弹窗内表单输入与全站一致（补齐 password） */
.profile-form .form-group label { font-weight: 600; }
.profile-form input[type="email"],
.profile-form input[type="text"],
.profile-form input[type="password"],
.profile-form select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.profile-form input:focus,
.profile-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

/* 列表与网格（Dashboard） */
.list .list-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list .list-row { display: flex; justify-content: space-between; gap: 12px; }
.list .label { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.recording-card .recording-title { font-weight: 600; }
.recording-card .recording-meta { color: var(--muted, #6b7280); display: flex; gap: 10px; flex-wrap: wrap; }
.profile-form .form-group label { font-weight: 600; }



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

  .btn.secondary {
    background: transparent;
    color: var(--text);
  }

  /* Utilities */
  .hidden { display: none !important; }
  .center { display: flex; align-items: center; justify-content: center; }

  /* Animations */
  @keyframes pulseSoft {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, .35); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
  }

  /* Focus visible for accessibility */
  :focus-visible {
    outline: 3px solid rgba(99, 102, 241, .35);
    outline-offset: 2px;
  }

/* Checkout page helpers */
.search-select {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.search-select:focus { outline: none; box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); border-color: var(--primary); }
.search-select .selected-label { pointer-events: none; }
.search-select .caret { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--muted); }

.search-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  display: none;
  padding: 8px;
}
.search-select.open .search-select-menu { display: block; }

.search-select .search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.search-select .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }

.search-select .options {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
}
.search-select .options .option {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.search-select .options .option:hover,
.search-select .options .option.active {
  background: var(--bg);
  color: var(--text);
}
