@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:          #0C0E14;
  --bg-surface:  #13161F;
  --bg-raised:   #1A1E2B;
  --border:      #252A3A;
  --border-mid:  #323952;
  --text-1:      #D4D9EE;
  --text-2:      #7B82A0;
  --text-3:      #454C66;
  --accent:      #6C7FFF;
  --accent-glow: rgba(108, 127, 255, 0.12);
  --success:     #4ADE80;
  --danger:      #FB7185;
  --info:        #7DD3FC;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --font-sans:   'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── App shell ── */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Header ── */
.app-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-title-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-glow);
  border: 1px solid rgba(108, 127, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.app-title h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ── Field ── */
.field {
  margin-bottom: 8px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-label-row .field-label {
  margin-bottom: 0;
}

.btn-paste {
  font-size: 11px;
  padding: 4px 10px;
  color: var(--text-2);
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 8px;
}

.textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  resize: vertical;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.7;
  caret-color: var(--accent);
}
.textarea::placeholder { color: var(--text-3); }
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 5px;
  margin-bottom: 16px;
}

/* ── Controls ── */
.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-1);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s, box-shadow 0.12s;
  user-select: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:hover:not(:disabled) {
  background: #232838;
  border-color: var(--border-mid);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #7B8FFF;
  border-color: #7B8FFF;
  box-shadow: 0 4px 16px rgba(108, 127, 255, 0.35);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-raised);
  border-color: var(--border);
  box-shadow: none;
}

.status-msg {
  font-size: 12px;
  color: var(--text-2);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* ── Toggle bar ── */
.toggle-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 28px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.toggle-bar:has(input:checked) {
  border-color: rgba(108, 127, 255, 0.3);
  background: rgba(108, 127, 255, 0.05);
}
.toggle-bar:hover { border-color: var(--border-mid); }

.toggle-bar > input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-bar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-label {
  font-size: 13px;
  color: var(--text-1);
}

.toggle-note {
  font-size: 11px;
  color: var(--text-2);
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.2s, background 0.2s;
}
.toggle-bar:has(input:checked) .toggle-switch {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-bar:has(input:checked) .toggle-thumb {
  transform: translateX(16px);
  background: #fff;
}

/* ── Section heading ── */
.section-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Index list ── */
.index-section { margin-bottom: 28px; }

.index-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.index-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  box-shadow: inset 3px 0 0 transparent;
}
.index-row:hover {
  border-color: rgba(108, 127, 255, 0.3);
  box-shadow: inset 3px 0 0 var(--accent);
  background: var(--bg-raised);
}

.index-badge {
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  border: 0.5px solid transparent;
  flex-shrink: 0;
}

.index-url {
  color: var(--text-2);
  word-break: break-all;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.index-dot {
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Image grid ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* ── Image card ── */
.image-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.image-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 0 1px rgba(108, 127, 255, 0.2);
  border-color: rgba(108, 127, 255, 0.3);
}

.card-img-wrap {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-raised);
  position: relative;
}

.card-img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
  animation: card-reveal 0.35s ease forwards;
}

@keyframes card-reveal {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.card-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--bg-raised) 25%,
    #20253500 50%,
    var(--bg-raised) 75%
  );
  background: linear-gradient(
    90deg,
    var(--bg-raised) 0%,
    var(--border) 50%,
    var(--bg-raised) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.card-num-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  border: 0.5px solid transparent;
  z-index: 1;
}

.card-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.card-name {
  font-size: 11px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.card-convert {
  font-size: 10px;
  margin-top: 3px;
  color: var(--text-2);
}

.card-status {
  font-size: 10px;
  margin-top: 2px;
  font-weight: 600;
  color: var(--text-2);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .btn, .image-card, .index-row,
  .toggle-bar, .toggle-thumb, .toggle-switch { transition: none; }
  .card-skeleton { animation: none; }
  .card-img { animation: none; }
}
