/* ── reset & variables ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0c;
  --surface: #111114;
  --surface-2: #18181c;
  --border: #2a2a30;
  --border-hover: #3a3a42;
  --text: #c8c8d0;
  --text-dim: #6a6a75;
  --text-bright: #e8e8f0;
  --accent: #00e08e;
  --accent-dim: #00e08e33;
  --accent-glow: #00e08e18;
  --error: #ff4466;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
  --display: 'Space Mono', monospace;
}

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

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

/* ── atmospheric layers ── */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image:
    linear-gradient(var(--accent) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── layout ── */
main {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

/* ── header ── */
header {
  margin-bottom: 2.5rem;
  animation: fadeIn 0.6s ease-out;
}

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

.logo-bracket {
  color: var(--accent);
  font-weight: 400;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  letter-spacing: 0.04em;
}

/* ── tabs ── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  animation: fadeIn 0.6s ease-out 0.1s both;
}

.tab {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab:first-child {
  border-right: 1px solid var(--border);
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  color: var(--accent);
  background: var(--accent-glow);
  text-shadow: 0 0 20px var(--accent-dim);
}

.tab-icon {
  font-size: 0.65rem;
}

/* ── panels ── */
.panel {
  display: none;
  animation: slideUp 0.35s ease-out;
}

.panel.active {
  display: block;
}

/* ── field labels ── */
.field-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

/* ── textarea ── */
.input-area {
  margin-bottom: 1rem;
}

textarea {
  width: 100%;
  min-height: 160px;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-bright);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

textarea::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ── buttons ── */
.action-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.action-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 0 24px var(--accent-dim);
}

.action-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.action-btn.loading .btn-text {
  opacity: 0;
}

.action-btn.loading .btn-spinner {
  display: block;
}

.btn-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--bg);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.secondary-btn {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.6rem 1.2rem;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ── output areas ── */
.output-area {
  margin-top: 1.25rem;
  animation: slideUp 0.35s ease-out;
}

.image-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-frame img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 2px;
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.output-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ── drop zone ── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  margin-bottom: 1rem;
  background: var(--surface);
}

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

.drop-zone.drag-over {
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.drop-zone.has-file {
  padding: 1rem;
  border-style: solid;
  border-color: var(--border);
}

.drop-zone.has-file .drop-zone-content {
  display: none;
}

.drop-icon {
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  transition: color 0.25s;
}

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

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

.drop-subtext {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  letter-spacing: 0.04em;
}

/* ── file preview ── */
.file-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview img {
  max-width: 100%;
  max-height: 200px;
  image-rendering: pixelated;
  border-radius: 4px;
}

.remove-file {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

/* ── decoded text ── */
.decoded-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-bright);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

/* ── footer ── */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-text {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ── scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ── responsive ── */
@media (max-width: 480px) {
  main {
    padding: 2rem 1rem 1.5rem;
  }

  .logo {
    font-size: 2rem;
  }

  textarea {
    min-height: 120px;
  }

  .image-frame {
    padding: 1rem;
  }
}
