:root {
  --bg: #16161a;
  --bar: #0b0b0d;
  --line: #2a2a31;
  --text: #f2f2f2;
  --muted: #9a9aa3;
  --red: #e4002b;
  --bar-h: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* Barra superior */
.topbar {
  flex: 0 0 var(--bar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bar);
  border-bottom: 2px solid var(--red);
  position: relative;
  z-index: 10;
}

.brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand strong { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; }
.brand span { font-size: 12px; color: var(--muted); }

.current { text-align: center; min-width: 0; }
.counter { font-size: 12px; color: var(--red); font-weight: 700; letter-spacing: .08em; }
.current h1 { margin: 2px 0 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; justify-content: flex-end; gap: 8px; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #24242b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #2e2e37; }
.btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.btn-primary { background: var(--red); border-color: var(--red); }
.btn-primary:hover { background: #ff1a45; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* Lista de telas */
.menu {
  position: absolute;
  top: var(--bar-h);
  left: 0;
  right: 0;
  z-index: 9;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 16px 32px rgba(0,0,0,.5);
}
.menu[hidden] { display: none; }

.menu button {
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text);
  background: #1c1c22;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.menu button:hover { background: #2a2a32; }
.menu button.active { border-color: var(--red); background: #2a1319; }
.menu .num { color: var(--red); font-weight: 700; min-width: 28px; }

/* Visualização */
.viewer {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  background: #101013;
}

.viewer img {
  display: block;
  margin: 0 auto;
  /* Tamanho original (100%): nunca amplia nem reduz, então não perde qualidade */
  width: auto;
  max-width: none;
  height: auto;
  user-select: none;
  opacity: 0;
  transition: opacity .2s;
}
.viewer img.loaded { opacity: 1; }

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.loader.hidden { display: none; }

.hint {
  flex: 0 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
  background: var(--bar);
  border-top: 1px solid var(--line);
}
kbd {
  background: #24242b;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "cur ctl"; padding: 0 12px; }
  .brand { display: none; }
  .current { text-align: left; }
  .btn { padding: 8px 10px; }
  .hint { display: none; }
}
