* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: #0b0d12;
  color: #e8e8ea;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  line-height: 1.55;
}
a { color: #c9a84c; text-decoration: none; }
a:hover { color: #e8c97a; }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid #2a3340;
  background: #1a1f2b;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  font-size: 1.05rem;
}
.brand .logo {
  color: #c9a84c;
  font-size: 1.3rem;
  text-shadow: 0 0 8px rgba(201, 168, 76, 0.5);
}
.topbar nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.topbar nav a.primary,
button.primary {
  background: #c9a84c;
  color: #10141b;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
}
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.4rem 4rem;
}

/* Gallery */
.section { margin-bottom: 2.5rem; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.section-head small {
  color: #8ea2bd;
  font-size: 0.78rem;
}
.section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #c9a84c;
}
.howto { margin-left: 1.4rem; color: #b6bdcc; }
.howto li { margin-bottom: 0.25rem; }
.howto em { color: #c9a84c; font-style: normal; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  background: #10141b;
  border: 1px solid #2a3340;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.1s, border-color 0.1s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: #c9a84c;
  transform: translateY(-1px);
}
.card-thumb {
  aspect-ratio: 9 / 16;
  background: linear-gradient(135deg, #1a1f2b, #2a3340);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  text-align: center;
}
.card-thumb span {
  font-size: 0.8rem;
  color: #c9a84c;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.card-meta { padding: 0.6rem 0.7rem 0.7rem; }
.card-meta h3 {
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: #fff;
}
.card-meta .directive {
  font-size: 0.74rem;
  color: #8ea2bd;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.3rem;
}
.knob-summary {
  font-family: ui-monospace, 'Menlo', monospace;
  font-size: 0.66rem;
  color: #c9a84c;
  letter-spacing: 0.02em;
}
.empty {
  color: #8ea2bd;
  font-size: 0.88rem;
}
.error { color: #ff7676; }

/* Creation page */
.creation .panel {
  max-width: 640px;
  margin: 1.5rem auto 0;
  background: #10141b;
  border: 1px solid #2a3340;
  border-radius: 6px;
  padding: 1.4rem;
}
.creation h2 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}
.creation .hint {
  color: #8ea2bd;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.creation form label {
  display: block;
  margin-bottom: 0.5rem;
}
.creation form label > span {
  display: block;
  font-size: 0.8rem;
  color: #9aa3b2;
  margin-bottom: 0.3rem;
}
.creation textarea {
  width: 100%;
  background: #0b0d12;
  border: 1px solid #2a3340;
  color: #e8e8ea;
  padding: 0.6rem 0.7rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
  resize: vertical;
}
.creation textarea:focus {
  outline: none;
  border-color: #c9a84c;
}
.form-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.8rem;
}
.form-row small {
  color: #8ea2bd;
  font-size: 0.78rem;
  flex: 1;
}

/* Play page */
.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  padding: 1.5rem 1.4rem;
  align-items: start;
}
@media (max-width: 800px) {
  .play {
    grid-template-columns: 1fr;
    padding: 0.6rem 0.5rem 1.5rem;
    gap: 0.75rem;
  }
}
.play iframe {
  width: 100%;
  height: 720px;
  max-height: calc(100dvh - 6rem);
  background: #000;
  border: 1px solid #2a3340;
  border-radius: 6px;
}
@media (max-width: 800px) {
  /* mobile: full-bleed playable area, meta below */
  .play iframe { height: calc(100dvh - 8rem); border-radius: 4px; }
}
.meta {
  background: #10141b;
  border: 1px solid #2a3340;
  border-radius: 6px;
  padding: 1rem;
}
.meta h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #fff;
}
.meta .directive {
  font-size: 0.85rem;
  color: #b6bdcc;
  margin-bottom: 0.8rem;
}
.meta .meta-line {
  font-size: 0.75rem;
  color: #8ea2bd;
}

/* Pipeline trace (creation page) */
.trace {
  max-width: 640px;
  margin: 1rem auto 0;
  background: #10141b;
  border: 1px solid #2a3340;
  border-radius: 6px;
  padding: 1rem 1.4rem 1.2rem;
}
.trace h3 {
  font-size: 0.85rem;
  color: #c9a84c;
  margin-bottom: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.trace ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.trace li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  background: #0b0d12;
  border-left: 3px solid #2a3340;
  font-size: 0.85rem;
}
.trace li b {
  color: #b6bdcc;
  font-weight: 500;
}
.trace li span {
  color: #8ea2bd;
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
  text-align: right;
  flex: 1;
}
.trace li.pending { opacity: 0.5; }
.trace li.running {
  border-left-color: #c9a84c;
  background: #1a1f2b;
}
.trace li.running b { color: #c9a84c; }
.trace li.ok {
  border-left-color: #6edb8f;
}
.trace li.ok b { color: #6edb8f; }
.trace li.fail {
  border-left-color: #ff7676;
  background: #2a1a1a;
}
.trace li.fail b { color: #ff7676; }

/* Mobile tightening */
@media (max-width: 600px) {
  .topbar { padding: 0.7rem 0.9rem; }
  .topbar nav { gap: 0.5rem; }
  .topbar nav a.primary { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
  .brand { font-size: 0.95rem; }
  main { padding: 1rem 0.9rem 3rem; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .card-meta { padding: 0.45rem 0.55rem 0.55rem; }
  .card-meta h3 { font-size: 0.8rem; }
  .card-meta .directive { font-size: 0.7rem; -webkit-line-clamp: 2; }
  .knob-summary { font-size: 0.62rem; }
  .creation .panel { padding: 1rem; margin-top: 0.6rem; }
  .creation textarea { font-size: 1rem; } /* keep iOS from zooming */
  .form-row { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .form-row button { width: 100%; }
  .meta { padding: 0.7rem; }
  .play iframe { height: calc(100dvh - 11rem); }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}
