:root {
  --aqm-bg: #0b0f14;
  --aqm-surface: #141a22;
  --aqm-surface2: #1c2430;
  --aqm-border: #2a3544;
  --aqm-text: #e8edf4;
  --aqm-muted: #8b9cb3;
  --aqm-accent: #3b82f6;
  --aqm-accent-dim: rgba(59, 130, 246, 0.15);
  --aqm-active: #22c55e;
  --aqm-active-dim: rgba(34, 197, 94, 0.12);
  --aqm-warn: #f59e0b;
  --aqm-danger: #ef4444;
  --aqm-radius: 12px;
  --aqm-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--aqm-bg);
  color: var(--aqm-text);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(34, 197, 94, 0.06), transparent);
}

code {
  font-size: 0.85em;
  background: var(--aqm-surface2);
  padding: 2px 6px;
  border-radius: 4px;
}

.aqm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--aqm-border);
  background: rgba(20, 26, 34, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.aqm-header__badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aqm-warn);
  background: rgba(245, 158, 11, 0.15);
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.aqm-header h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 700;
}

.aqm-header__sub {
  margin: 0;
  color: var(--aqm-muted);
  font-size: 0.9rem;
  max-width: 520px;
}

.aqm-header__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.aqm-status {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: var(--aqm-radius);
  background: var(--aqm-surface);
  border: 1px solid var(--aqm-border);
  font-size: 0.9rem;
  color: var(--aqm-muted);
}

.aqm-status--ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: var(--aqm-active-dim);
}

.aqm-status--err {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.aqm-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 420px);
  gap: 20px;
  padding: 20px 24px 120px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .aqm-layout {
    grid-template-columns: 1fr;
  }
}

.aqm-panel {
  background: var(--aqm-surface);
  border: 1px solid var(--aqm-border);
  border-radius: var(--aqm-radius);
  box-shadow: var(--aqm-shadow);
  overflow: hidden;
}

.aqm-panel__head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--aqm-border);
}

.aqm-panel__head--sticky {
  position: sticky;
  top: 88px;
  z-index: 10;
  background: var(--aqm-surface);
}

.aqm-panel__head h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.aqm-count {
  font-weight: 400;
  color: var(--aqm-muted);
  font-size: 0.9em;
}

.aqm-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--aqm-muted);
}

.aqm-question-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.aqm-question {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--aqm-surface2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.aqm-question:hover {
  border-color: var(--aqm-border);
}

.aqm-question--active {
  border-color: var(--aqm-accent);
  background: var(--aqm-accent-dim);
  box-shadow: 0 0 0 1px var(--aqm-accent);
}

.aqm-question--mapped .aqm-question__slot {
  border-color: rgba(34, 197, 94, 0.5);
}

.aqm-question__slot {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 2px dashed var(--aqm-border);
  background: #0a0e12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.aqm-question__slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.aqm-question__slot-empty {
  font-size: 10px;
  color: var(--aqm-muted);
  text-align: center;
  padding: 4px;
  line-height: 1.2;
}

.aqm-question__body {
  min-width: 0;
}

.aqm-question__id {
  font-size: 11px;
  color: var(--aqm-accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.aqm-question__text {
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aqm-question__file {
  font-size: 11px;
  color: var(--aqm-muted);
  word-break: break-all;
}

.aqm-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.aqm-btn:active {
  transform: scale(0.98);
}

.aqm-btn--ghost {
  background: var(--aqm-surface2);
  color: var(--aqm-text);
  border: 1px solid var(--aqm-border);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.aqm-btn--ghost:hover {
  background: var(--aqm-border);
}

.aqm-btn--pick {
  background: var(--aqm-accent-dim);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  white-space: nowrap;
}

.aqm-question--active .aqm-btn--pick {
  background: var(--aqm-accent);
  color: #fff;
}

.aqm-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  padding: 14px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.aqm-gallery__item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid var(--aqm-border);
  background: #0a0e12;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.12s;
}

.aqm-gallery__item:hover {
  border-color: var(--aqm-accent);
  transform: scale(1.03);
}

.aqm-gallery__item--used::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--aqm-active);
  color: #052e16;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aqm-gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.aqm-gallery__label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  text-align: center;
  padding: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--aqm-muted);
}

.aqm-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 24px 18px;
  background: rgba(11, 15, 20, 0.95);
  border-top: 1px solid var(--aqm-border);
  backdrop-filter: blur(14px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.aqm-footer__stats {
  font-size: 0.85rem;
  color: var(--aqm-muted);
}

.aqm-footer__note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--aqm-muted);
  text-align: center;
  max-width: 640px;
}

.aqm-btn--save {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #052e16;
  font-size: 1rem;
  padding: 14px 28px;
  box-shadow: 0 4px 24px rgba(34, 197, 94, 0.35);
}

.aqm-btn--save:hover:not(:disabled) {
  filter: brightness(1.08);
}

.aqm-btn--save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
