*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0a;
  --surface:  #111111;
  --border:   #222222;
  --border-hi:#333333;
  --text:     #e8e4dc;
  --muted:    #555555;
  --accent:   #c8f564;
  --accent2:  #f5c864;
  --danger:   #f56464;
  --radius:   6px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  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)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
}

/* layout */
.page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* header */
header {
  padding: 28px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { width: 16px; height: 16px; color: #0a0a0a; }

.logo-text {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.logo-text span { color: var(--muted); }

.header-tag {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* main */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 48px;
}

.hero-text {
  text-align: center;
  max-width: 520px;
}

.hero-text h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.hero-text h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-text p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  max-width: 380px;
  margin: 0 auto;
}

/* upload zone */
.upload-wrap {
  width: 100%;
  max-width: 520px;
}

.drop-zone {
  border: 1.5px dashed var(--border-hi);
  border-radius: 12px;
  padding: 52px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: #111f00;
  transform: translateY(-1px);
}

.drop-zone.drag-over { border-style: solid; }

.drop-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  background: #1a1a1a;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  background: #1e2e00;
  border-color: var(--accent);
}

.drop-icon svg { width: 22px; height: 22px; color: var(--muted); transition: color 0.2s; }
.drop-zone:hover .drop-icon svg,
.drop-zone.drag-over .drop-icon svg { color: var(--accent); }

.drop-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.drop-sub { font-size: 12px; color: var(--muted); }
.drop-sub strong { color: #777; }

#file-input { display: none; }

/* file selected state */
.file-selected {
  display: none;
  align-items: center;
  gap: 12px;
  background: #111f00;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
}

.file-selected.visible { display: flex; }

.file-icon {
  width: 36px;
  height: 36px;
  background: #1e3000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon svg { width: 18px; height: 18px; color: var(--accent); }

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }

.file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.file-remove:hover { color: var(--danger); }
.file-remove svg { width: 16px; height: 16px; display: block; }

/* convert button */
.btn-convert {
  width: 100%;
  padding: 15px 24px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-convert:hover:not(:disabled) { background: #d4ff70; transform: translateY(-1px); }
.btn-convert:active:not(:disabled) { transform: translateY(0); }
.btn-convert:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-convert svg { width: 16px; height: 16px; }

/* loading */
.loading-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.loading-wrap.visible { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-steps { text-align: center; }

.loading-step {
  font-size: 12px;
  color: var(--muted);
  transition: color 0.3s, opacity 0.3s;
  opacity: 0.4;
  margin-bottom: 4px;
}

.loading-step.active { color: var(--accent); opacity: 1; }
.loading-step.done   { color: #4a7a00; opacity: 0.7; }

/* result */
.result-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 36px 32px;
  background: #0d1a00;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  text-align: center;
}

.result-wrap.visible { display: flex; }

.result-icon {
  width: 52px;
  height: 52px;
  background: #1e3000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon svg { width: 24px; height: 24px; color: var(--accent); }

.result-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.4rem;
  font-weight: 400;
}

.result-sub { font-size: 12px; color: var(--muted); max-width: 280px; }

.btn-download {
  padding: 13px 28px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-download:hover { background: #d4ff70; transform: translateY(-1px); }
.btn-download svg { width: 15px; height: 15px; }

.btn-reset {
  background: none;
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.03em;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.btn-reset:hover { color: var(--text); }

/* error */
.error-wrap {
  display: none;
  padding: 14px 18px;
  background: #1a0a0a;
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 12px;
  color: #f08080;
  gap: 10px;
  align-items: flex-start;
  margin-top: 10px;
}

.error-wrap.visible { display: flex; }
.error-wrap svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

/* info strip */
.info-strip {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.info-dot {
  width: 4px;
  height: 4px;
  background: var(--border-hi);
  border-radius: 50%;
}

/* footer */
footer {
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-l { font-size: 11px; color: var(--muted); }
.footer-l a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.footer-l a:hover { color: var(--text); }
.footer-r { font-size: 11px; color: #2a2a2a; }

/* responsive */
@media (max-width: 600px) {
  header { padding: 20px; }
  footer { padding: 16px 20px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .header-tag { display: none; }
  .info-strip { gap: 14px; }
}

/* animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-text   { animation: fadeUp 0.5s ease both; }
.upload-wrap { animation: fadeUp 0.5s 0.1s ease both; }
.info-strip  { animation: fadeUp 0.5s 0.2s ease both; }