:root {
  --bg:      #0b0d12;
  --panel:   #12151b;
  --panel-2: #171b23;
  --edge:    #262c39;
  --text:    #e7eaf0;
  --muted:   #949dae;
  --label:   #63769a;
  --accent:  #4da3ff;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) 1fr;
  grid-template-rows: auto 1fr;
  gap: 1.25rem;
  margin: 0;
  padding: 1.25rem;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 1.1rem;
}

/* ---------- header ---------- */

#app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .85rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--edge);
}

#app-header img {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
}

#app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -.01em;
}


/* ---------- catalogue ---------- */

#catalogue {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  overflow-y: auto;
  padding-right: .35rem;
}

.card {
  padding: .85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  outline: none;
}

.card h1 {
  margin: 0 0 .2rem;
  font-size: 1.7rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--muted);
  /* keep every card the same height however long the description is */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card:focus,
.card.focused,
.card:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

/* ---------- details ---------- */

#details {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 2rem 2.25rem;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 12px;
}

/*
 * The display:flex above outranks the UA stylesheet's [hidden] {display:none},
 * so without this the pane would be on screen before a card is picked.
 */
#details[hidden] {
  display: none;
}

#details-name {
  margin: 0 0 .5rem;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

#details-desc {
  max-width: 65ch;
  margin: 0 0 2.25rem;
  color: var(--muted);
}

#details label {
  display: block;
  margin-bottom: .4rem;
  color: var(--label);
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

#details label + p {
  margin: 0 0 1.75rem;
}

#details-src {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
  word-break: break-all;
}

#details-contrib {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.contributor {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .7rem .25rem .3rem;
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 999px;
  font-size: .95rem;
  white-space: nowrap;
}

.contributor img {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--edge);
  object-fit: cover;
}

/*
 * The terminal is the last row of the details pane and swallows whatever is
 * left over, so it ends at the bottom of the panel however short the
 * description above it is. FitAddon measures the *parent* of the .xterm
 * element, which makes #details-stdout the one that has to carry the height;
 * min-height:0 stops the default min-content floor from propping it open.
 * The min-height on the wrapper is a floor for very short windows -- past
 * that point #details scrolls rather than crushing the terminal.
 */
#details-term {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 12rem;
}

#details-stdout {
  flex: 1 1 auto;
  min-height: 0;
}

#details-stdout .xterm {
  height: 100%;
}

#pick-dialog {
  width: min(34rem, 90vw);
  padding: 1.5rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}

#pick-dialog::backdrop {
  background: rgba(4, 6, 12, .65);
}

/*
 * Belt and braces for the load-time flash: the UA sheet already does this for
 * a real <dialog>, and it costs nothing to state it for the builds where the
 * element is unknown and dialog.js has not run yet.
 */
#pick-dialog:not([open]) {
  display: none;
}

/*
 * Fallback modal for WebKit without <dialog> (see dialog.js). None of the UA
 * modal styling exists there, so the centring, the stacking and the backdrop
 * all have to be spelled out. width is restated because the base rule uses
 * CSS min(), which those builds may also be missing.
 */
.no-dialog #pick-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 10000;
}

.no-dialog #pick-dialog[open] {
  display: block;
}

.dialog-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 6, 12, .65);
  z-index: 9999;
}

#pick-title {
  margin: 0 0 .25rem;
  font-weight: 650;
}

#pick-title::after {
  content: "Choose a release";
  display: block;
  margin: .35rem 0 1rem;
  color: var(--label);
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-size: .9rem;
}

#pick-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

#pick-list button {
  width: 100%;
  padding: .7rem .9rem;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  outline: none;
}

#pick-list button.focused,
#pick-list button:hover {
  background: #1c2231;
  border-color: var(--accent);
}

#toast-list {
  position: fixed;
  bottom: 20px;
  left: 0;
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  background: transparent;
  z-index: 9999;
}

#toast-list p {
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--edge);
    padding: 12px 20px;
    border-radius: 6px;

  margin: 0;
}

/* ---------- trim ---------- */

::selection { background: var(--accent); color: #04070d; }

#catalogue, #details {
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}

/* narrow window: stack instead of squeezing the two columns */
@media (max-width: 820px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  #catalogue { flex-direction: row; overflow-x: auto; }
  .card { flex: 0 0 15rem; }
}
