*,
*::before,
*::after {
     box-sizing: border-box;
     margin: 0;
     padding: 0;
}

:root {
     --bg: #0d0d0d;
     --surface: #151515;
     --surface-2: #1c1c1c;
     --border: #2a2a2a;
     --border-mid: #333;
     --accent: #e8ff47;
     --accent-dim: #c8df2a;
     --text: #f0f0f0;
     --text-muted: #666;
     --text-dim: #444;
     --danger: #ff4d4d;
     --radius: 4px;
     --mono: 'Space Mono', monospace;
     --sans: 'DM Sans', sans-serif;
}

html {
     font-size: 15px;
}

body {
     background: var(--bg);
     color: var(--text);
     font-family: var(--sans);
     min-height: 100vh;
     display: grid;
     grid-template-rows: auto 1fr auto;
     grid-template-areas: "header" "main" "footer";
}

/* ── NOISE 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='1'/%3E%3C/svg%3E");
     opacity: 0.025;
     pointer-events: none;
     z-index: 0;
}

/* ── HEADER ── */
.app-header {
     grid-area: header;
     display: flex;
     align-items: center;
     justify-content: space-between;
     padding: 1.25rem 2rem;
     border-bottom: 1px solid var(--border);
     position: relative;
     z-index: 1;
}

.app-header h1 {
     font-family: var(--mono);
     font-size: 1rem;
     font-weight: 700;
     letter-spacing: -0.02em;
     color: var(--accent);
}

.app-header p {
     font-size: 0.75rem;
     color: var(--text-muted);
     margin-top: 2px;
     font-family: var(--mono);
}

.badge {
     font-family: var(--mono);
     font-size: 0.65rem;
     letter-spacing: 0.08em;
     text-transform: uppercase;
     color: var(--text-dim);
     border: 1px solid var(--border);
     padding: 0.3rem 0.6rem;
     border-radius: var(--radius);
}

/* ── MAIN ── */
main {
     grid-area: main;
     padding: 2rem;
     max-width: 960px;
     width: 100%;
     margin: 0 auto;
     position: relative;
     z-index: 1;
}

/* ── UPLOAD ROW ── */
.upload-row {
     display: grid;
     grid-template-columns: auto 1fr;
     gap: 0.75rem;
     margin-bottom: 1rem;
}

.upload-btn {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     padding: 0 1.25rem;
     background: var(--accent);
     color: #000;
     font-family: var(--mono);
     font-size: 0.8rem;
     font-weight: 700;
     border-radius: var(--radius);
     cursor: pointer;
     white-space: nowrap;
     transition: background 0.15s;
}

.upload-btn:hover {
     background: var(--accent-dim);
}

.upload-btn input {
     display: none;
}

.drop-zone {
     display: flex;
     align-items: center;
     justify-content: center;
     border: 1px dashed var(--border-mid);
     border-radius: var(--radius);
     padding: 0.9rem 1.5rem;
     font-family: var(--mono);
     font-size: 0.75rem;
     color: var(--text-dim);
     cursor: default;
     transition: border-color 0.15s, color 0.15s, background 0.15s;
     outline: none;
}

.drop-zone.dragover {
     border-color: var(--accent);
     color: var(--accent);
     background: rgba(232, 255, 71, 0.04);
}

/* ── CONTROLS ── */
.controls {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     padding: 0.875rem 0;
     border-top: 1px solid var(--border);
     border-bottom: 1px solid var(--border);
     margin-bottom: 1.5rem;
}

.control-group {
     display: flex;
     align-items: center;
     gap: 0.5rem;
}

.control-group label {
     font-family: var(--mono);
     font-size: 0.7rem;
     color: var(--text-muted);
     text-transform: uppercase;
     letter-spacing: 0.06em;
}

select {
     background: var(--surface-2);
     color: var(--text);
     border: 1px solid var(--border-mid);
     border-radius: var(--radius);
     font-family: var(--mono);
     font-size: 0.8rem;
     padding: 0.35rem 0.6rem;
     cursor: pointer;
     outline: none;
     transition: border-color 0.15s;
}

select:focus {
     border-color: var(--accent);
}

.spacer {
     flex: 1;
}

.action-btn {
     font-family: var(--mono);
     font-size: 0.75rem;
     font-weight: 700;
     padding: 0.45rem 1rem;
     border: none;
     border-radius: var(--radius);
     cursor: pointer;
     transition: background 0.15s, color 0.15s;
}

.convert-btn {
     background: var(--surface-2);
     color: var(--text);
     border: 1px solid var(--border-mid);
}

.convert-btn:hover {
     border-color: var(--accent);
     color: var(--accent);
}

.download-all-btn {
     background: var(--accent);
     color: #000;
}

.download-all-btn:hover {
     background: var(--accent-dim);
}

/* ── THUMBS GRID ── */
.thumbs {
     display: grid;
     grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
     gap: 0.75rem;
}

/* ── THUMB CARD ── */
.thumb {
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: var(--radius);
     overflow: hidden;
     display: flex;
     flex-direction: column;
     transition: border-color 0.2s;
     animation: fadeIn 0.2s ease;
}

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

     to {
          opacity: 1;
          transform: translateY(0);
     }
}

.thumb:hover {
     border-color: var(--border-mid);
}

.thumb .preview {
     width: 100%;
     aspect-ratio: 4/3;
     object-fit: cover;
     display: block;
     background: var(--surface-2);
}

.thumb .meta {
     padding: 0.6rem 0.75rem;
     flex: 1;
}

.thumb .meta strong {
     display: block;
     font-size: 0.75rem;
     font-family: var(--mono);
     color: var(--text);
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
     margin-bottom: 2px;
}

.thumb .meta div {
     font-size: 0.7rem;
     color: var(--text-muted);
     font-family: var(--mono);
}

.thumb-actions {
     display: flex;
     border-top: 1px solid var(--border);
}

.thumb-btn {
     flex: 1;
     padding: 0.45rem 0;
     font-family: var(--mono);
     font-size: 0.7rem;
     font-weight: 700;
     background: none;
     border: none;
     cursor: pointer;
     text-align: center;
     text-decoration: none;
     color: var(--text-muted);
     transition: color 0.15s, background 0.15s;
     display: flex;
     align-items: center;
     justify-content: center;
}

.thumb-btn+.thumb-btn {
     border-left: 1px solid var(--border);
}

.thumb-btn.convert:hover {
     color: var(--accent);
     background: rgba(232, 255, 71, 0.05);
}

.thumb-btn.download:hover {
     color: var(--accent);
     background: rgba(232, 255, 71, 0.05);
}

.thumb-btn.remove:hover {
     color: var(--danger);
     background: rgba(255, 77, 77, 0.05);
}

/* ── FOOTER ── */
.app-footer {
     grid-area: footer;
     display: flex;
     align-items: center;
     justify-content: space-between;
     padding: 1rem 2rem;
     border-top: 1px solid var(--border);
     font-family: var(--mono);
     font-size: 0.7rem;
     color: var(--text-dim);
     position: relative;
     z-index: 1;
}

.app-footer code {
     color: var(--text-muted);
     background: var(--surface-2);
     padding: 1px 5px;
     border-radius: 3px;
     font-family: var(--mono);
}

.app-footer a {
     color: var(--text-dim);
     text-decoration: none;
     transition: color 0.15s;
}

.app-footer a:hover {
     color: var(--accent);
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {

     .app-header,
     main,
     .app-footer {
          padding-left: 1rem;
          padding-right: 1rem;
     }

     .upload-row {
          grid-template-columns: 1fr;
     }

     .upload-btn {
          justify-content: center;
          padding: 0.75rem;
     }

     .controls {
          flex-wrap: wrap;
     }
}