:root {
  --bg: #0b1020;
  --panel: #141a2e;
  --ink: #e8ecf5;
  --muted: #9aa3b8;
  --line: #2a334d;
  --accent: #81d742;
  --accent-dim: #3d6a1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #12182b, var(--bg));
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  color: var(--muted);
  font-size: 0.8rem;
  justify-content: flex-end;
}

.top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.auth {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth .user {
  color: var(--ink);
  font-weight: 600;
}

.auth-btn {
  height: 1.85rem;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

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

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.filter-label {
  margin-right: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter button {
  min-width: 2rem;
  height: 1.85rem;
  padding: 0 0.45rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.filter button:hover { border-color: var(--accent); }
.filter button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1020;
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  margin-right: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  font-family: inherit;
}

.stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.frame {
  position: relative;
  margin: 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(80% 60% at 50% 40%, rgba(129, 215, 66, 0.08), transparent 70%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  padding: 2rem;
}

.empty[hidden],
.frame img[hidden] {
  display: none !important;
}

.nav {
  align-self: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.nav:hover { border-color: var(--accent); color: var(--accent); }
.nav:disabled { opacity: 0.35; cursor: default; }

.meta {
  border-top: 1px solid var(--line);
  background: #0e1424;
  padding: 0.7rem 1.1rem 0.85rem;
  flex-shrink: 0;
  max-height: 28vh;
  overflow: auto;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.value {
  font-weight: 600;
  font-size: 1rem;
  word-break: break-word;
}

.muted {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-word;
}

.grade-row {
  display: flex;
  gap: 0.35rem;
}

.grade-row button {
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.grade-row button:hover { border-color: var(--accent); }
.grade-row button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1020;
}

.notes {
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--accent-dim);
  background: var(--panel);
  color: #c9d1e3;
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 4.5rem;
  overflow: auto;
}

.flash {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (max-width: 900px) {
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .keys { display: none; }
}
