/* ─── CSS 变量 ─── */
:root {
  --bg: #0a0e1a;
  --bg2: #0f1629;
  --sf: #161d33;
  --sf2: #1e2844;
  --sf3: #283352;
  --bd: #2a3558;
  --tx: #e2e8f0;
  --tm: #7b8fad;
  --ac: #38bdf8;
  --ac2: #818cf8;
  --ok: #34d399;
  --wn: #fbbf24;
  --dg: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ─── 基础 ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--tx);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
::selection { background: var(--ac); color: var(--bg); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ac); }

/* ─── 顶部 ─── */
.header {
  background: linear-gradient(135deg, #0f1629 0%, #161d33 50%, #101830 100%);
  border-bottom: 1px solid var(--bd);
  padding: 14px 32px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(56,189,248,.06), transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(129,140,248,.04), transparent 50%);
  pointer-events: none;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 1.6rem; }
.logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--ac), var(--ac2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-accent { color: var(--ac2); }
.tagline {
  font-size: .88rem;
  color: var(--tm);
  border-left: 1px solid var(--bd);
  padding-left: 20px;
}

/* ─── 主体 ─── */
.main {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

/* ─── 面板通用 ─── */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg2);
}
.panel-input { border-right: 1px solid var(--bd); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--sf);
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}
.panel-tabs { display: flex; gap: 4px; }

/* ─── Tab 按钮 ─── */
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--tm);
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { color: var(--tx); background: var(--sf2); }
.tab.active {
  color: var(--ac);
  background: var(--sf2);
  border-color: var(--bd);
}
.tab-icon { font-size: 1rem; }

/* ─── 按钮 ─── */
.btn-clear {
  padding: 4px 12px;
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--tm);
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-clear:hover { color: var(--dg); border-color: var(--dg); }

.btn-convert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--ac), var(--ac2));
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(56,189,248,.2);
}
.btn-convert:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(56,189,248,.35);
}
.btn-convert:active:not(:disabled) { transform: translateY(0); }
.btn-convert:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: 1px solid var(--ok);
  border-radius: var(--radius-sm);
  background: rgba(52,211,153,.1);
  color: var(--ok);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-download:hover:not(:disabled) {
  background: rgba(52,211,153,.2);
  box-shadow: 0 2px 12px rgba(52,211,153,.2);
}
.btn-download:disabled { opacity: .3; cursor: not-allowed; }

.btn-group { display: flex; gap: 6px; }

.btn-word {
  border-color: var(--ac);
  background: rgba(56,189,248,.1);
  color: var(--ac);
}
.btn-word:hover:not(:disabled) {
  background: rgba(56,189,248,.2);
  box-shadow: 0 2px 12px rgba(56,189,248,.2);
}

.btn-remove {
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: rgba(248,113,113,.15);
  color: var(--dg);
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-remove:hover { background: rgba(248,113,113,.3); }

/* ─── Tab 内容 ─── */
.tab-content { display: none; flex: 1; min-height: 0; }
.tab-content.active { display: flex; flex-direction: column; }

/* ─── 编辑区 ─── */
#mdInput {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--bg2);
  color: var(--tx);
  padding: 20px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: .88rem;
  line-height: 1.7;
  resize: none;
  outline: none;
}
#mdInput::placeholder { color: var(--bd); }

/* ─── 拖拽区 ─── */
.dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 20px;
  border: 2px dashed var(--bd);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--ac);
  background: rgba(56,189,248,.04);
}
.dropzone.drag-over { border-style: solid; }
.dropzone-icon { font-size: 3rem; margin-bottom: 12px; opacity: .6; }
.dropzone-title { font-size: 1.1rem; color: var(--tx); margin-bottom: 4px; }
.dropzone-sub { font-size: .85rem; color: var(--tm); }

/* 文件信息 */
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 20px;
  padding: 12px 16px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}
.file-badge { font-size: 1.2rem; }
#fileName { color: var(--ac); font-weight: 600; flex: 1; }
#fileSize { color: var(--tm); font-size: .8rem; }

/* ─── 操作栏 ─── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--sf);
  border-top: 1px solid var(--bd);
  flex-shrink: 0;
}
.stats {
  font-size: .8rem;
  color: var(--tm);
}
.stats span { margin-right: 14px; }
.stats .stat-val { color: var(--ac); font-weight: 600; }

/* ─── 预览 ─── */
.preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.empty-icon { font-size: 4rem; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 1.3rem; color: var(--tm); margin-bottom: 8px; }
.empty-sub { font-size: .9rem; color: var(--bd); line-height: 1.6; }

#previewFrame {
  flex: 1;
  width: 100%;
  border: none;
  background: #0f172a;
}

#htmlSource {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--bg2);
  color: var(--ok);
  padding: 20px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: .8rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

/* ─── 底部 ─── */
.footer {
  padding: 10px 32px;
  text-align: center;
  color: var(--bd);
  font-size: .75rem;
  border-top: 1px solid rgba(42,53,88,.5);
  flex-shrink: 0;
  background: var(--bg);
}

/* ─── 转换中动画 ─── */
.converting .btn-convert {
  pointer-events: none;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ─── 成功提示 ─── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 28px;
  background: var(--ok);
  color: #0a0e1a;
  font-weight: 600;
  font-size: .9rem;
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(52,211,153,.3);
  transition: transform .4s cubic-bezier(.4,0,.2,1);
  z-index: 9999;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ─── 响应式 ─── */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .panel-input { border-right: none; border-bottom: 1px solid var(--bd); max-height: 50vh; }
  .header-inner { flex-direction: column; gap: 4px; text-align: center; }
  .tagline { border-left: none; padding-left: 0; }
}
