/* ============================================================
   CSS VARIABLES & THEMES
   ============================================================ */
:root {
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #faf8f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f0eb;
  --bg-accent: #eee9e0;
  --text-primary: #1a1714;
  --text-secondary: #6b6560;
  --text-muted: #a09a93;
  --border: #e5e0d8;
  --border-strong: #cdc6bb;
  --accent: #c45d3e;
  --accent-hover: #a84d32;
  --accent-light: rgba(196,93,62,0.08);
  --accent-glow: rgba(196,93,62,0.15);
  --success: #3a8a5c;
  --success-bg: rgba(58,138,92,0.08);
  --error: #c44040;
  --error-bg: rgba(196,64,64,0.08);
  --warning: #b8860b;
  --warning-bg: rgba(184,134,11,0.08);
  --drop-zone-bg: #f8f5f0;
  --drop-zone-active: rgba(196,93,62,0.06);
  --preview-bg: #fdfcfa;
  --code-bg: #f5f2ed;
  --scrollbar-track: #f0ece6;
  --scrollbar-thumb: #d4cec5;
  --overlay: rgba(26,23,20,0.4);
}

[data-theme="dark"] {
  --bg-primary: #141210;
  --bg-secondary: #1e1b18;
  --bg-tertiary: #262320;
  --bg-accent: #2e2a26;
  --text-primary: #ede8e2;
  --text-secondary: #9e9890;
  --text-muted: #6b6560;
  --border: #332f2a;
  --border-strong: #48433d;
  --accent: #e07050;
  --accent-hover: #eb8068;
  --accent-light: rgba(224,112,80,0.1);
  --accent-glow: rgba(224,112,80,0.2);
  --success: #5cb87a;
  --success-bg: rgba(92,184,122,0.1);
  --error: #e06060;
  --error-bg: rgba(224,96,96,0.1);
  --warning: #d4a020;
  --warning-bg: rgba(212,160,32,0.1);
  --drop-zone-bg: #1a1816;
  --drop-zone-active: rgba(224,112,80,0.08);
  --preview-bg: #1a1816;
  --code-bg: #1a1816;
  --scrollbar-track: #1e1b18;
  --scrollbar-thumb: #3d3832;
  --overlay: rgba(0,0,0,0.6);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ============================================================
   BACKGROUND TEXTURE
   ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, var(--accent-light), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, var(--accent-light), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   SKIP LINK
   ============================================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 200;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  text-decoration: none;
}

.skip-link:focus {
  top: 8px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
  box-shadow: 0 2px 8px rgba(196,93,62,0.3);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-subtitle {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  line-height: 1;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.privacy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-privacy 2s ease infinite;
}

@keyframes pulse-privacy {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.app-hero {
  text-align: center;
  margin-bottom: 44px;
}

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0;
  transition: all var(--transition);
  position: relative;
  width: 68px;
  height: 34px;
}

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

.theme-toggle-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 5px;
  transition: transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .theme-toggle-knob {
  transform: translateX(34px);
}

.theme-toggle-knob svg {
  width: 13px;
  height: 13px;
  fill: #fff;
}

.app-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 42px);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.app-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 300;
  max-width: 520px;
  margin: 0 auto;
}

.format-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}

.format-badge {
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}

.card + .card { margin-top: 20px; }

.card-title {
  font-family: var(--font-display);
  font-size: 20px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.card-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ============================================================
   DROP ZONE
   ============================================================ */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--drop-zone-bg);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--drop-zone-active);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.drop-zone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.drop-zone:hover .drop-zone-icon { transform: scale(1.08); }

.drop-zone-icon svg {
  width: 26px;
  height: 26px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-zone-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 400;
}

.drop-zone-text strong {
  color: var(--accent);
  font-weight: 600;
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.file-input { display: none; }

/* ============================================================
   FILE INFO
   ============================================================ */
.file-info {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-top: 16px;
  border: 1px solid var(--border);
}

.file-info.visible { display: flex; }

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.file-icon.epub { background: #5b8c5a; }
.file-icon.pdf { background: #c44040; }
.file-icon.txt { background: #6b8cae; }
.file-icon.html { background: #d4772c; }
.file-icon.fb2 { background: #7b68ae; }
.file-icon.rtf { background: #5c8a9e; }
.file-icon.md { background: #4a7c6f; }
.file-icon.default { background: var(--text-muted); }

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

.file-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-accent);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.file-remove:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* ============================================================
   PREVIEW PANEL
   ============================================================ */
.preview-panel {
  display: none;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.preview-panel.visible { display: block; }

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
}

.preview-content {
  padding: 16px;
  background: var(--preview-bg);
  max-height: 260px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   CONVERSION OPTIONS
   ============================================================ */
.convert-section {
  display: none;
}

.convert-section.visible { display: block; }

.format-select-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.format-select-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.format-select {
  flex: 1;
  min-width: 160px;
  padding: 10px 40px 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239e9890' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.format-select:hover { border-color: var(--border-strong); }
.format-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.arrow-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
}

.arrow-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.convert-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.convert-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.convert-btn:active:not(:disabled) { transform: translateY(0); }

.convert-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.convert-btn .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.convert-btn.loading .spinner { display: inline-block; }
.convert-btn.loading .btn-text { opacity: 0.8; }

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

/* ============================================================
   STATUS MESSAGES
   ============================================================ */
.status-bar {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  align-items: center;
  gap: 8px;
}

.status-bar.visible { display: flex; }

.status-bar.info {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

.status-bar.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(58,138,92,0.2);
}

.status-bar.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(196,64,64,0.2);
}

.status-bar.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(184,134,11,0.2);
}

.status-icon { flex-shrink: 0; font-size: 16px; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-wrap {
  display: none;
  margin-top: 12px;
}

.progress-wrap.visible { display: block; }

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* ============================================================
   SUPPORTED CONVERSIONS TABLE
   ============================================================ */
.conversions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.conv-arrow { color: var(--accent); font-weight: 600; }

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footer-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 300;
}

.footer-text strong { font-weight: 500; color: var(--text-secondary); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeUp 0.5s ease both; }
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }

@keyframes pulse-accent {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .app-wrapper { padding: 24px 16px 40px; }
  .card { padding: 20px 18px; border-radius: var(--radius-md); }
  .drop-zone { padding: 36px 16px; }
  .format-select-group { flex-direction: column; align-items: stretch; }
  .arrow-icon { transform: rotate(90deg); align-self: center; }
  .format-badges { gap: 4px; }
  .format-badge { font-size: 11px; padding: 3px 8px; }
  .header-inner { height: 56px; }
  .logo-text { font-size: 17px; }
  .logo-subtitle { display: none; }
  .conversions-grid { grid-template-columns: 1fr; }
}

/* ===== SITE FOOTER ===== */
.site-footer{
  margin-top:60px;padding:48px 28px 36px;
  border-top:1px solid var(--border);
  background:var(--bg-primary);color:var(--text-secondary);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  font-size:14px;line-height:1.6;
}
.site-footer .footer-inner{max-width:1100px;margin:0 auto}
.site-footer .footer-grid{
  display:grid;grid-template-columns:2fr 1fr 1fr 1fr;
  gap:40px;margin-bottom:40px;
}
.site-footer .footer-brand{display:flex;align-items:center;gap:10px;margin-bottom:16px}
.site-footer .footer-brand svg{width:32px;height:32px;color:#a855f7;flex-shrink:0}
.site-footer .footer-brand-name{
  font-size:20px;font-weight:700;
  background:linear-gradient(90deg,#8B5CF6,#EC4899,#3B82F6);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
}
.site-footer .footer-desc{color:var(--text-muted);margin-bottom:16px;max-width:360px}
.site-footer .footer-copy{font-size:12px;color:var(--text-muted);opacity:.7}
.site-footer h3{font-weight:700;margin-bottom:16px;color:var(--text-primary);font-size:15px}
.site-footer ul{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:10px}
.site-footer a{color:var(--text-secondary);text-decoration:none;transition:color .2s}
.site-footer a:hover{color:#a855f7}
.site-footer .footer-bottom{
  border-top:1px solid var(--border);
  padding-top:20px;text-align:center;
}
.site-footer .footer-bottom p{color:var(--text-muted);font-size:13px;opacity:.7}
.site-footer .footer-bottom span{color:#a855f7}

@media(max-width:768px){
  .site-footer .footer-grid{grid-template-columns:1fr;gap:32px}
  .site-footer{padding:36px 16px 28px}
}
