/* ===== CSS Variables ===== */
:root {
  --bg: #f5f7fb;
  --bg-card: #fff;
  --bg-hover: #f0f2f5;
  --bg-input: #fff;
  --text: #1a1a2e;
  --text2: #4b5563;
  --text3: #9ca3af;
  --border: #e5e7eb;
  --accent: #6366f1;
  --accent-rgb: 99,102,241;
  --accent-light: rgba(99,102,241,0.07);
  --accent-hover: #4f46e5;
  --accent2: #8b5cf6;
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 20px rgba(var(--accent-rgb),0.15);
  --tr: 0.2s ease;
  --font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif SC', Georgia, 'Times New Roman', serif;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --bg-input: #0f172a;
  --text: #f1f5f9;
  --text2: #cbd5e1;
  --text3: #64748b;
  --border: #334155;
  --accent: #818cf8;
  --accent-rgb: 129,140,248;
  --accent-light: rgba(129,140,248,0.1);
  --accent-hover: #6366f1;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--tr), color var(--tr);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

/* ===== Header ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
[data-theme="dark"] .header { background: rgba(15,23,42,0.9); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1400px; margin: 0 auto;
  padding: 0 2rem; height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo-img { width: 38px; height: 38px; border-radius: 12px; transition: transform 0.3s; }
.logo:hover .logo-img { transform: rotate(-8deg) scale(1.05); }
.logo-text { font-size: 1.25rem; font-weight: 900; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 18px; border: none; border-radius: 12px;
  background: transparent; color: var(--text2);
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all var(--tr); font-family: var(--font);
  position: relative;
}
.nav-tab:hover { background: var(--accent-light); color: var(--accent); }
.nav-tab.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(var(--accent-rgb),0.3); }
.nav-icon { font-size: 1rem; }
.icon-btn {
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: var(--bg-hover); cursor: pointer; font-size: 1.1rem;
  transition: all var(--tr); display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--accent-light); transform: rotate(15deg); }

/* ===== Main ===== */
.main { max-width: 1400px; margin: 0 auto; padding: 2rem; min-height: calc(100vh - 64px); }
.page { display: none; animation: fadeIn 0.4s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Hero ===== */
.hero { text-align: center; padding: 4rem 0 3rem; position: relative; }
.hero-bg {
  position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.08) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.hero-logo { height: 72px; margin-bottom: 1.2rem; position: relative; z-index: 1; filter: drop-shadow(0 8px 24px rgba(var(--accent-rgb),0.2)); }
.hero-title {
  font-size: 2.8rem; font-weight: 900; margin-bottom: 0.6rem;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; position: relative; z-index: 1;
}
.hero-desc { font-size: 1.15rem; color: var(--text2); margin-bottom: 2.5rem; position: relative; z-index: 1; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; position: relative; z-index: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 26px; border: none; border-radius: 12px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.25s ease; font-family: var(--font);
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,0.15), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.btn:hover::after { opacity: 1; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(var(--accent-rgb),0.25); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--accent-rgb),0.35); }
.btn-accent { background: var(--gradient); color: #fff; box-shadow: 0 2px 12px rgba(var(--accent-rgb),0.3); }
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(var(--accent-rgb),0.4); }
.btn-outline { background: var(--bg-card); border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); transform: translateY(-2px); }
.btn-lg { padding: 15px 34px; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { padding: 7px 16px; font-size: 0.82rem; border-radius: 8px; background: var(--bg-hover); color: var(--text2); border: 1px solid var(--border); }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-group { display: flex; gap: 10px; }
.btn-group .btn { flex: 1; justify-content: center; }
.glow-btn { box-shadow: 0 0 0 0 rgba(var(--accent-rgb),0.4); animation: glow 2s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 2px 8px rgba(var(--accent-rgb),0.25); } to { box-shadow: 0 4px 20px rgba(var(--accent-rgb),0.4); } }

/* ===== Features ===== */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 2rem 0; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden;
}
.feature-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient); opacity: 0; transition: opacity 0.3s;
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.feature-card:hover::before { opacity: 1; }
.feature-icon-wrap { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-light); display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.feature-icon { font-size: 1.6rem; }
.feature-card h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.feature-card p { font-size: 0.9rem; color: var(--text2); line-height: 1.7; margin-bottom: 0.8rem; }
.feature-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ftag { padding: 3px 10px; border-radius: 6px; font-size: 0.72rem; background: var(--accent-light); color: var(--accent); font-weight: 500; }

/* ===== Stats ===== */
.stats-bar {
  display: flex; justify-content: center; align-items: center; gap: 2.5rem;
  padding: 1.8rem 2rem; background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); margin: 2rem 0;
}
.stat { text-align: center; }
.stat-num { display: block; font-size: 2.2rem; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.85rem; color: var(--text3); }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

/* ===== How it works ===== */
.how-it-works { margin: 2.5rem 0; }
.section-title { text-align: center; font-size: 1.3rem; font-weight: 800; margin-bottom: 2rem; }
.steps { display: flex; align-items: center; justify-content: center; gap: 1.5rem; }
.step {
  text-align: center; padding: 1.5rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); flex: 1; max-width: 260px;
}
.step-num {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gradient); color: #fff;
  font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.8rem;
}
.step h4 { font-size: 1rem; margin-bottom: 0.3rem; }
.step p { font-size: 0.85rem; color: var(--text2); }
.step-arrow { font-size: 1.5rem; color: var(--text3); font-weight: 300; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.required { color: var(--danger); }
.input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg-input); color: var(--text);
  font-size: 0.95rem; font-family: var(--font);
  transition: all var(--tr); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.08); }
.textarea { resize: vertical; min-height: 80px; }
.textarea-lg { min-height: 280px; font-family: var(--font); line-height: 1.8; }
select.input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%239ca3af'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Write Layout ===== */
.write-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }
.write-sidebar {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: sticky; top: 84px; height: fit-content;
  box-shadow: var(--shadow);
}
.sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sidebar-header h2 { font-size: 1.05rem; }
.write-editor { display: flex; flex-direction: column; }

/* ===== Editor ===== */
.editor-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.toolbar-group { display: flex; gap: 2px; }
.toolbar-btn {
  width: 34px; height: 34px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 0.85rem;
  transition: all var(--tr); display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-family: var(--font);
}
.toolbar-btn:hover { background: var(--accent-light); color: var(--accent); }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.word-count { margin-left: auto; font-size: 0.78rem; color: var(--text3); font-variant-numeric: tabular-nums; }
.editor {
  flex: 1; min-height: 520px; padding: 24px;
  border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg-card); color: var(--text);
  font-size: 1rem; line-height: 1.9; outline: none;
  overflow-y: auto; font-family: var(--font-serif);
  box-shadow: var(--shadow);
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text3); font-family: var(--font); }
.editor:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb),0.1); }
.editor h2 { font-size: 1.3rem; margin: 1.5rem 0 0.6rem; color: var(--accent); font-family: var(--font); }
.editor h3 { font-size: 1.1rem; margin: 1rem 0 0.4rem; font-family: var(--font); }
.editor strong { color: var(--accent); }
.editor-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; font-size: 0.75rem; color: var(--text3);
}
.status-indicator { display: flex; align-items: center; gap: 4px; }
.status-indicator.active::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== Summary & Check ===== */
.summary-layout, .check-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.summary-input, .summary-output, .check-input, .check-output {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.output-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-desc { font-size: 0.9rem; color: var(--text2); margin-bottom: 16px; }
.result-box {
  min-height: 320px; padding: 20px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); font-size: 0.95rem; line-height: 1.85;
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-serif);
}
.result-placeholder { color: var(--text3); text-align: center; padding: 4rem 1rem; }
.placeholder-icon { font-size: 3rem; margin-bottom: 0.8rem; opacity: 0.5; }
.result-actions { display: flex; gap: 8px; }

/* ===== Check Meter ===== */
.check-meter { display: flex; align-items: center; gap: 16px; margin: 20px 0 8px; }
.meter-bar { flex: 1; height: 20px; background: var(--border); border-radius: 10px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 10px; transition: width 1.5s cubic-bezier(0.4,0,0.2,1); background: var(--gradient); width: 0; }
.meter-label { font-size: 2rem; font-weight: 900; min-width: 70px; text-align: right; }
.meter-desc { font-size: 0.85rem; color: var(--text2); margin-bottom: 16px; }
.check-details { margin-top: 12px; }
.check-item { padding: 12px 16px; margin-bottom: 8px; border-radius: 10px; border: 1px solid rgba(var(--accent-rgb),0.2); background: rgba(var(--accent-rgb),0.03); font-size: 0.9rem; line-height: 1.7; }
.check-item .dup-label { color: var(--danger); font-weight: 700; font-size: 0.78rem; margin-bottom: 4px; }

/* ===== Loading ===== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
}
.loading-overlay.show { display: flex; }
.loading-card {
  background: var(--bg-card); border-radius: 20px; padding: 2.5rem 3rem;
  text-align: center; box-shadow: var(--shadow-lg); min-width: 280px;
}
.loading-anim { display: flex; gap: 8px; justify-content: center; margin-bottom: 1.2rem; }
.loading-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.4s ease-in-out infinite both;
}
.loading-dot:nth-child(2) { animation-delay: 0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }
.loading-card p { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.loading-progress { margin-top: 1rem; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.loading-bar { height: 100%; background: var(--gradient); border-radius: 2px; width: 0; transition: width 0.3s; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 20px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: 0.9rem;
  animation: slideIn 0.35s ease; pointer-events: auto;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1001;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card); border-radius: var(--radius); padding: 0;
  width: 440px; max-width: 90vw; max-height: 70vh;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: fadeIn 0.25s ease;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; }
.modal-close { border: none; background: none; font-size: 1.2rem; cursor: pointer; color: var(--text3); padding: 4px; }
.modal-body { padding: 16px 20px; max-height: 400px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); text-align: right; }
.draft-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; transition: all var(--tr);
}
.draft-item:hover { border-color: var(--accent); background: var(--accent-light); }
.draft-title { font-size: 0.9rem; font-weight: 600; }
.draft-meta { font-size: 0.75rem; color: var(--text3); }

/* ===== Rewrite ===== */
.rewrite-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.rewrite-input, .rewrite-output { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.rewrite-tips { margin-top: 1rem; text-align: left; }
.tip-item { padding: 6px 0; font-size: 0.82rem; color: var(--text2); border-bottom: 1px solid var(--border); }
.tip-item:last-child { border-bottom: none; }
.tip-item strong { color: var(--accent); }

/* ===== Footer ===== */
.footer { text-align: center; padding: 2rem; font-size: 0.82rem; color: var(--text3); border-top: 1px solid var(--border); margin-top: 2rem; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .write-layout { grid-template-columns: 1fr; }
  .write-sidebar { position: static; }
  .summary-layout, .check-layout, .rewrite-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .header-inner { padding: 0 1rem; height: 56px; }
  .nav-tab { padding: 6px 12px; font-size: 0.82rem; }
  .nav-label { display: none; }
  .nav-icon { font-size: 1.1rem; }
  .main { padding: 1rem; }
  .hero-title { font-size: 2rem; }
  .hero-desc { font-size: 1rem; }
  .features { grid-template-columns: 1fr; }
  .stats-bar { gap: 1.2rem; padding: 1.2rem; }
  .stat-num { font-size: 1.6rem; }
  .steps { flex-direction: column; }
  .step-arrow { transform: rotate(90deg); }
  .editor { min-height: 350px; }
  .form-row-2 { grid-template-columns: 1fr; }
}
