/* ============================================
   MdConverted — 文档智能重排版工具
   Design: 继承 H2Ning 首页设计语言
   ============================================ */

/* CSS Variables */
:root {
  --bg: #0d0e10;
  --bg-card: rgba(20, 21, 24, 0.85);
  --bg-hover: rgba(28, 29, 34, 0.85);
  --bg-field: #0a0a0a;
  --border: #25262b;
  --border-soft: rgba(255,255,255,0.05);
  --border-hover: #35363c;
  --text: #e0e0e3;
  --text-muted: #82838b;
  --text-soft: #56575e;
  --accent-gradient: linear-gradient(135deg, rgb(124, 92, 252) 0%, rgb(62, 207, 142) 50%, rgb(255, 107, 74) 100%);
  --accent: rgb(62, 207, 142);
  --accent-green: rgb(62, 207, 142);
  --accent-orange: rgb(255, 107, 74);
  --accent-red: #ef4444;
  --accent-blue: #58a6ff;
  --accent-teal: rgb(62, 207, 142);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 100px;
  --font-sans: "Inter", "SF Pro Text", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-card: rgba(255, 255, 255, 0.78);
  --bg-hover: rgba(232, 232, 237, 0.65);
  --bg-field: rgba(245, 245, 247, 0.85);
  --border: #d2d2d7;
  --border-soft: rgba(0,0,0,0.04);
  --border-hover: #c7c7cc;
  --text: #1d1d1f;
  --text-muted: #86868b;
  --text-soft: #aeaeb2;
  --accent: #3b82f6;
  --accent-green: #16a34a;
  --accent-orange: #e36209;
  --accent-red: #dc2626;
  --accent-blue: #0969da;
  --accent-teal: #8250df;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: -30%;
  background:
    radial-gradient(ellipse 60% 40% at 30% 20%, rgba(124, 92, 252, 0.12), transparent 70%),
    radial-gradient(ellipse 50% 35% at 70% 60%, rgba(62, 207, 142, 0.08), transparent 65%),
    radial-gradient(ellipse 55% 45% at 50% 80%, rgba(255, 107, 74, 0.07), transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 25%, rgba(124, 92, 252, 0.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: bgBreathe 8s ease-in-out infinite;
}

:root[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 60% 40% at 25% 15%, rgba(124, 92, 252, 0.06), transparent 70%),
    radial-gradient(ellipse 50% 35% at 75% 55%, rgba(255, 150, 100, 0.05), transparent 65%),
    radial-gradient(ellipse 55% 45% at 45% 75%, rgba(62, 207, 142, 0.04), transparent 70%),
    radial-gradient(ellipse 40% 30% at 70% 20%, rgba(124, 92, 252, 0.04), transparent 60%);
}

:root[data-theme="light"] .header {
  background: rgba(245, 245, 247, 0.72);
}

:root[data-theme="light"] .api-key-btn:hover {
  border-color: #16a34a;
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

@keyframes bgBreathe {
  0%   { opacity: 0.4; filter: saturate(0.8) hue-rotate(0deg); }
  25%  { opacity: 0.8; filter: saturate(1.2) hue-rotate(20deg); }
  50%  { opacity: 0.5; filter: saturate(1.0) hue-rotate(-10deg); }
  75%  { opacity: 0.7; filter: saturate(1.3) hue-rotate(10deg); }
  100% { opacity: 0.4; filter: saturate(0.8) hue-rotate(0deg); }
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

/* App Container */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================
   Header — Glass Morphism
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: rgba(10,10,10,0.68);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--text);
}

.logo-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

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

.api-key-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.api-key-btn:hover {
  border-color: var(--accent-green);
  background: rgba(62, 207, 142, 0.18);
  color: var(--accent-green);
}

.api-key-btn svg {
  width: 16px;
  height: 16px;
}

.api-key-btn .key-set {
  color: var(--accent-green);
}

/* Theme Toggle */
.theme-toggle {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-normal);
  flex-shrink: 0;
}

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

.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ============================================
   Main Layout
   ============================================ */
.main {
  display: flex;
  flex: 1;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
}

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Left Panel */
.panel-left {
  width: 380px;
  flex-shrink: 0;
}

/* Right Panel */
.panel-right {
  flex: 1;
  min-width: 0;
}

/* ============================================
   Upload Zone
   ============================================ */
.upload-zone {
  padding: 36px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.upload-zone:hover {
  background: rgba(255,255,255,0.015);
}

.upload-zone.dragover {
  background: rgba(124, 92, 252, 0.06);
  border-color: rgba(124, 92, 252, 0.3);
}

.upload-zone.dragover .upload-icon {
  transform: scale(1.08);
  border-color: var(--accent);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  width: 60px;
  height: 60px;
  padding: 18px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  transition: all var(--transition-normal);
}

.upload-zone:hover .upload-icon {
  border-color: var(--border-hover);
  color: var(--text);
}

.upload-icon svg {
  width: 100%;
  height: 100%;
}

.upload-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-formats {
  font-size: 0.75rem;
  color: var(--text-soft);
  padding: 4px 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
}

/* ============================================
   Clipboard Import Bar
   ============================================ */
.clipboard-import-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.clipboard-import-bar .file-list-action-btn {
  width: 100%;
  justify-content: center;
}

/* ============================================
   File List
   ============================================ */
.file-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.file-list-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.file-list-header-actions {
  display: flex;
  gap: 8px;
}

.file-list-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 13px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  color: var(--text-muted);
}

.file-list-action-btn.import-btn {
  background: transparent;
  color: var(--text-muted);
}

.file-list-action-btn.import-btn:hover {
  background: rgba(62, 207, 142, 0.12);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.file-list-action-btn.clear-btn {
  background: transparent;
  color: var(--text-muted);
}

.file-list-action-btn.clear-btn:hover {
  background: rgba(248, 81, 73, 0.08);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--accent-red);
}

.file-list-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.file-list-items::-webkit-scrollbar {
  width: 5px;
}

.file-list-items::-webkit-scrollbar-track {
  background: transparent;
}

.file-list-items::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.file-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.file-item.active {
  background: rgba(124, 92, 252, 0.08);
  border-color: rgba(124, 92, 252, 0.25);
}

.file-icon {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon.docx {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent-blue);
}

.file-icon.xlsx {
  background: rgba(62, 207, 142, 0.12);
  color: var(--accent-green);
}

.file-icon.md {
  background: rgba(163, 113, 247, 0.12);
  color: var(--accent-teal);
}

.file-icon svg {
  width: 100%;
  height: 100%;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.7rem;
  color: var(--text-soft);
  margin-top: 1px;
}

.file-remove {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
}

.file-item:hover .file-remove {
  opacity: 1;
}

.file-remove:hover {
  background: rgba(248, 81, 73, 0.12);
  color: var(--accent-red);
}

.file-remove svg {
  width: 14px;
  height: 14px;
}

.file-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-soft);
  text-align: center;
}

.file-list-empty svg {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  opacity: 0.4;
}

.file-list-empty p {
  font-size: 0.85rem;
}

/* File List Footer */
.file-list-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

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

/* ============================================
   Preview Header
   ============================================ */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.preview-tabs {
  display: flex;
  position: relative;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.preview-tabs::before {
  content: '';
  position: absolute;
  top: 3px; bottom: 3px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.preview-tabs[data-active="original"]::before {left: 3px;right: calc(50% + 2px);}
.preview-tabs[data-active="preview"]::before  {left: calc(50%);right: 3px;}

.preview-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 22px;
  background: none;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
}

.preview-tab:hover {
  color: var(--text);
}

.preview-tab.active {
  color: #0a0a0a;
}

.preview-tab svg {
  width: 15px;
  height: 15px;
}

.preview-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: rgba(62, 207, 142, 0.12);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Preview Content
   ============================================ */
.preview-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.preview-pane {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.preview-pane.active {
  display: flex;
}

.editor-wrapper,
.preview-wrapper {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.editor-wrapper::-webkit-scrollbar,
.preview-wrapper::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.editor-wrapper::-webkit-scrollbar-track,
.preview-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.editor-wrapper::-webkit-scrollbar-thumb,
.preview-wrapper::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}

.editor {
  width: 100%;
  height: 620px;
  min-height: 300px;
  padding: 20px;
  background: var(--bg-field);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--text);
  resize: none;
  transition: border-color var(--transition-fast);
}

.editor:focus {
  outline: none;
  border-color: var(--accent);
}

.editor::placeholder {
  color: var(--text-soft);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-soft);
  text-align: center;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  opacity: 0.35;
}

.empty-state p {
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ============================================
   Markdown Body Styles
   ============================================ */
.markdown-body {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.02em;
}

.markdown-body h1 {
  font-size: 1.75rem;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-size: 1.4rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.markdown-body h3 { font-size: 1.15rem; }
.markdown-body h4 { font-size: 1rem; }

.markdown-body p { margin-bottom: 1em; }

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1em;
  padding-left: 2em;
}

.markdown-body li { margin-bottom: 0.4em; }

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.2em 0.5em;
  background: var(--bg-hover);
  border-radius: 4px;
  color: var(--accent-orange);
}

.markdown-body pre {
  margin-bottom: 1em;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  color: var(--text);
}

.markdown-body blockquote {
  margin-bottom: 1em;
  padding: 0.7em 1.2em;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.02);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

.markdown-body table {
  width: 100%;
  margin-bottom: 1em;
  border-collapse: collapse;
  font-size: 0.9em;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-hover);
  font-weight: 600;
}

.markdown-body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

:root[data-theme="light"] .markdown-body tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.025);
}

.markdown-body hr {
  margin: 2em 0;
  border: none;
  border-top: 1px solid var(--border);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.markdown-body a:hover { opacity: 0.8; }

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #0a0a0a;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgb(109, 72, 214), rgb(31, 178, 121), rgb(232, 93, 62));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.btn-primary:hover {
  transform: translateY(-2px);
  color: #fff;
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary span,
.btn-primary svg {
  position: relative;
  z-index: 1;
}

:root[data-theme="light"] .btn-primary {
  background: rgba(29,29,31,0.90);
  color: #fff;
}

:root[data-theme="light"] .btn-primary:hover {
  color: #fff;
}

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

.btn-primary:disabled {
  background: #333;
  color: #666;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

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

.btn-secondary:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

/* ============================================
   Stream Progress Bar
   ============================================ */
.stream-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.35s ease;
}

.stream-bar.active {
  transform: translateY(0);
}

.stream-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.stream-bar-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-bar-stop {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.stream-bar-stop:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--accent-red);
}

.stream-bar-stop svg {
  width: 12px;
  height: 12px;
}

.stream-bar-progress {
  height: 3px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.stream-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.stream-bar-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: rgba(22,23,26,0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: modalIn 0.25s ease;
}
:root[data-theme="light"] .modal { background: rgba(255,255,255,0.96); }

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 24px;
}

.modal-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.modal-input {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text);
  transition: border-color var(--transition-fast);
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent-green);
}

.modal-input::placeholder {
  color: var(--text-muted);
}
:root[data-theme="light"] .modal-input { background: rgba(0,0,0,0.04); }

/* API Guide */
.api-guide {
  margin-top: 18px;
  padding: 0;
  background: none;
  border: none;
}

.api-guide-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.api-guide-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.api-guide-steps a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.api-guide-steps a:hover {
  opacity: 0.8;
}

.api-guide-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--accent-green);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  border-radius: var(--radius-full);
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.leaving {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px); }
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--accent-green); }
.toast.error   .toast-icon { color: var(--accent-red); }
.toast.info    .toast-icon { color: var(--accent); }

.toast-message {
  font-size: 0.88rem;
  color: var(--text);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .main {
    flex-direction: column;
  }

  .panel-left {
    width: 100%;
    max-height: 320px;
  }

  .upload-zone {
    padding: 24px;
  }

  .file-list {
    max-height: 200px;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 10px 14px;
  }

  .logo-text {
    font-size: 0.9rem;
  }

  .main {
    padding: 14px;
    gap: 14px;
  }

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

  .preview-tabs {
    flex: 1;
  }

  .preview-tab {
    flex: 1;
    justify-content: center;
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .preview-tab svg {
    display: none;
  }

  .preview-actions {
    display: none;
  }

  .api-key-btn span {
    display: none;
  }
}
