/* ========== CSS VARIABLES & THEMES ========== */
:root {
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Consolas', monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #FAF9F7;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F3F1EE;
  --bg-input: #FFFFFF;
  --bg-hover: #EDEAE6;
  --text-primary: #1A1714;
  --text-secondary: #6B6560;
  --text-tertiary: #9B9590;
  --border-primary: #E5E1DC;
  --border-focus: #C8A97E;
  --accent: #B8860B;
  --accent-hover: #9A7209;
  --accent-soft: rgba(184, 134, 11, 0.08);
  --accent-text: #FFFFFF;
  --success: #2D8A4E;
  --success-bg: rgba(45, 138, 78, 0.08);
  --error: #C53030;
  --error-bg: rgba(197, 48, 48, 0.08);
  --tag-bg: #F0EDE8;
  --tag-text: #6B6560;
  --tag-active-bg: #1A1714;
  --tag-active-text: #FAF9F7;
  --drop-bg: rgba(184, 134, 11, 0.04);
  --drop-border: var(--accent);
  --scrollbar-thumb: #D1CCC6;
  --scrollbar-track: transparent;
  --grain-opacity: 0.03;
}

[data-theme="dark"] {
  --bg-primary: #141210;
  --bg-secondary: #1E1C19;
  --bg-tertiary: #262320;
  --bg-input: #1E1C19;
  --bg-hover: #2E2B27;
  --text-primary: #F0EDE8;
  --text-secondary: #A09A93;
  --text-tertiary: #6B6560;
  --border-primary: #332F2A;
  --border-focus: #C8A97E;
  --accent: #D4A843;
  --accent-hover: #E0BC5E;
  --accent-soft: rgba(212, 168, 67, 0.1);
  --accent-text: #141210;
  --success: #4ADE80;
  --success-bg: rgba(74, 222, 128, 0.1);
  --error: #F87171;
  --error-bg: rgba(248, 113, 113, 0.1);
  --tag-bg: #262320;
  --tag-text: #A09A93;
  --tag-active-bg: #F0EDE8;
  --tag-active-text: #141210;
  --drop-bg: rgba(212, 168, 67, 0.05);
  --drop-border: var(--accent);
  --scrollbar-thumb: #3D3935;
  --scrollbar-track: transparent;
  --grain-opacity: 0.04;
}

/* ========== 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;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grain texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

/* ========== SKIP LINK ========== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 10000;
  transition: top 0.2s;
}

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

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

/* ========== LAYOUT ========== */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== HEADER ========== */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  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: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.logo-text em {
  font-style: italic;
  color: var(--accent);
}

.logo-sub {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-top: 1px;
  font-family: var(--font-body);
}

.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; }
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

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

/* ========== MAIN SECTION ========== */
main { padding: 36px 0 60px; }

.hero-desc {
  text-align: center;
  font-size: 1rem;
  color: var(--text-tertiary);
  margin-bottom: 28px;
}

/* ========== CONVERSION TAGS ========== */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.conversion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.tag {
  appearance: none;
  border: 1px solid var(--border-primary);
  background: var(--tag-bg);
  color: var(--tag-text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  padding: 7px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.tag:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}

.tag.active {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
  border-color: var(--tag-active-bg);
}

/* ========== EDITOR AREA ========== */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.editor-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.editor-panel:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.panel-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.panel-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn svg { width: 15px; height: 15px; }

textarea {
  width: 100%;
  min-height: 280px;
  padding: 16px;
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: background var(--transition), color var(--transition);
}

textarea::placeholder {
  color: var(--text-tertiary);
}

.output-area {
  width: 100%;
  min-height: 280px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-input);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background var(--transition), color var(--transition);
}

.output-area.empty {
  color: var(--text-tertiary);
  font-style: italic;
}

/* ========== STATS BAR ========== */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 14px 0;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ========== FILE DROP ZONE ========== */
.drop-zone {
  border: 2px dashed var(--border-primary);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 20px;
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--drop-border);
  background: var(--drop-bg);
}

.drop-zone.drag-over {
  transform: scale(1.005);
}

.drop-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--text-tertiary);
  transition: color var(--transition);
}

.drop-zone:hover .drop-icon { color: var(--accent); }

.drop-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

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

.drop-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-preview {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

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

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

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

.file-size {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.file-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
}

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

/* ========== ACTION BUTTONS ========== */
.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-sm);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

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

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow-lg);
}

.toast.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.toast.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}

.toast.info {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ========== FOOTER ========== */
footer {
  padding: 24px 0;
  border-top: 1px solid var(--border-primary);
}

footer p {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 700px) {
  .header-inner { height: 56px; }
  .logo-text { font-size: 18px; }
  .logo-sub { display: none; }
  .privacy-badge span:not(.privacy-dot) { display: none; }
  .privacy-badge { padding: 8px; }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  textarea, .output-area {
    min-height: 200px;
  }

  .conversion-tags {
    gap: 6px;
  }

  .tag {
    font-size: 0.72rem;
    padding: 6px 11px;
  }

  .stats-bar { gap: 14px; }

  header { padding-top: 20px; }
  main { padding: 24px 0 40px; }

  .toast-container {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .toast { width: 100%; }
}

/* ========== ANIMATIONS ========== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fade-up 0.4s ease both;
}

.fade-in-d1 { animation-delay: 0.05s; }
.fade-in-d2 { animation-delay: 0.1s; }
.fade-in-d3 { animation-delay: 0.15s; }
.fade-in-d4 { animation-delay: 0.2s; }

/* ===== SITE FOOTER ===== */
.site-footer{
  margin-top:60px;padding:48px 28px 36px;
  border-top:1px solid var(--border-primary);
  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-tertiary);margin-bottom:16px;max-width:360px}
.site-footer .footer-copy{font-size:12px;color:var(--text-tertiary);opacity:.7}
.site-footer h2{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-primary);
  padding-top:20px;text-align:center;
}
.site-footer .footer-bottom p{color:var(--text-tertiary);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}
}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
