:root {
  --bg: #101418;
  --surface: #171c22;
  --surface-2: #1f262e;
  --text: #eef1f4;
  --text-dim: #9aa5b1;
  --accent: #4da3ff;
  --border: #2a323b;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.topbar h1 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 600;
}

#search {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 10px;
  padding-bottom: 2px;
}

.chip {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  color: #04101f;
  border-color: var(--accent);
  font-weight: 600;
}

#content {
  padding: 12px 16px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

.status {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
}

.discipline-section {
  margin-top: 24px;
}

.discipline-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  display: block;
}

.card-label {
  padding: 6px 8px;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-dim);
  word-break: break-word;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }
.hidden { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  width: min(92vw, 640px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.modal-image-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  min-height: 200px;
}

#modal-img {
  max-width: 100%;
  max-height: 70vh;
  transition: transform 0.15s ease;
}

.modal-image-wrap.rot-90 #modal-img {
  max-width: 65vh;
  max-height: 80vw;
}

.modal-title {
  font-size: 0.85rem;
  color: var(--text-dim);
  word-break: break-word;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions button,
.modal-actions a {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-actions #btn-open {
  background: var(--accent);
  color: #04101f;
  font-weight: 600;
  border-color: var(--accent);
}
