:root {
  --bg: #f4f5f7; --card: #ffffff; --fg: #1b1d21; --muted: #5d6471; --line: #dcdfe5;
  --accent: #c8282c; --accent-fg: #ffffff; --ok: #1f7a3a; --warn: #9a6200; --bad: #b3261e;
  --head: #131417; --field: #ffffff; --chip: #eef0f3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215; --card: #1b1d22; --fg: #e7e9ee; --muted: #9aa1ad; --line: #2e323a;
    --field: #15171b; --chip: #262a31; --ok: #5cc27a; --warn: #e0a640; --bad: #f07067;
  }
}
:root[data-theme="dark"] {
  --bg: #111215; --card: #1b1d22; --fg: #e7e9ee; --muted: #9aa1ad; --line: #2e323a;
  --field: #15171b; --chip: #262a31; --ok: #5cc27a; --warn: #e0a640; --bad: #f07067;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
       background: var(--head); color: #fff; padding: 0 16px; height: 64px; }
.top::before { content: ""; }
.brand { text-align: center; }
.brand { font-weight: 800; letter-spacing: .04em; font-size: 30px; line-height: 1; white-space: nowrap; }
.brand .sw { color: var(--accent); }
.brand .mgr { font-weight: 500; letter-spacing: 0; color: #c9ccd3; margin-left: 6px; }
.who { font-size: 14px; color: #c9ccd3; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.who button { padding: 4px 10px; }
.ghmenu { position: relative; }
.ghmenu summary { list-style: none; cursor: pointer; padding: 4px 10px; border: 1px solid #3a3e46; border-radius: 8px;
                  color: #fff; background: #23262c; user-select: none; }
.ghmenu summary::-webkit-details-marker { display: none; }
.ghmenu summary::after { content: " \25BE"; color: #c9ccd3; }
.ghmenu[open] summary { border-color: var(--accent); }
.ghlist { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 230px; display: flex; flex-direction: column;
          background: #1d2026; border: 1px solid #3a3e46; border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.ghlist a { color: #e7e9ee; text-decoration: none; padding: 7px 10px; border-radius: 6px; white-space: nowrap; }
.ghlist a:hover { background: var(--accent); color: #fff; }

main { margin: 16px auto; padding: 0 16px; }
.foot { max-width: 980px; margin: 32px auto; padding: 0 16px; font-size: 13px; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }
.row.bar { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
/* the wizard keeps one height: its content scrolls, the buttons stay at the bottom */
.card.wiz { display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 460px;
            max-width: 1400px; margin-left: auto; margin-right: auto; }
/* the scroll area clips at its edge: a little room inside (and the same off
   outside) keeps the focus ring of a field whole, the layout where it was */
.wizbody { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 4px 8px 4px 4px; margin: -4px -4px 0 -4px; }
table.list { margin-top: 18px; }
.row.center { justify-content: center; }
.hidden { display: none; }
.fileline { display: flex; gap: 6px; align-items: center; flex: 1; }
input[type=text].dir { width: auto; flex: 1; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--fg);
               border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--fg); }
textarea { min-height: 90px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 4px 16px 4px 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.wizhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.wizhead .action { font-weight: 700; font-size: 17px; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.trail { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -6px 0 18px; padding: 8px 12px;
         background: var(--chip); border-radius: 8px; font-weight: 600; }
.trail .sep { color: var(--accent); font-weight: 400; }
.filebox { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--field); border: 1px solid var(--line);
           border-radius: 8px; padding: 8px 10px; min-height: 38px; }
.steps span { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.steps span.on { background: var(--accent); color: var(--accent-fg); }
.steps span.done { color: var(--fg); }

.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.choices.six { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .choices.six { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .choices.six { grid-template-columns: 1fr; } }
.choice { text-align: left; padding: 8px 12px; line-height: 1.3; }
.choice b { display: block; margin-bottom: 1px; }
.choice span { font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }

.tree { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--field);
        border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.tree div { display: flex; justify-content: space-between; gap: 10px; }
.tree .rm { color: var(--bad); border: 0; background: none; padding: 0 4px; }

.msgs { margin: 10px 0 0; padding: 0; list-style: none; }
.msgs li { padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 14px; }
.msgs .err { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.msgs .warn { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.msgs .ok { background: color-mix(in srgb, var(--ok) 14%, transparent); }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--fg); }
.preview { font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre; background: var(--field);
           border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: inline-block; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); }
.badge.success { color: var(--ok); } .badge.failure { color: var(--bad); } .badge.pending { color: var(--warn); }
progress { width: 100%; }

/* the Library block of the main menu */
.row.tabs { margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
table.lib { font-size: 12px; color: var(--fg); table-layout: auto; }
table.lib th, table.lib td { padding: 2px 6px; white-space: nowrap; line-height: 1.35; }
table.lib th { color: var(--fg); font-weight: 700; }
table.lib tr.gadgets th { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
table.lib tr.gadgets select, table.lib tr.gadgets input[type=text] { font-size: 12px; padding: 2px 4px; border-radius: 6px; width: 100%; min-width: 64px; }
table.lib tr.gadgets th.mid { text-align: left; }
table.lib td { border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
table.lib.fit { table-layout: fixed; width: 100%; }
table.lib.fit td, table.lib.fit th { overflow: hidden; text-overflow: ellipsis; }
table.lib.fit tr.gadgets select, table.lib.fit tr.gadgets input[type=text] { min-width: 0; }
.count { font-size: 12px; margin-top: 6px; }

@media (max-width: 560px) {
  .top { grid-template-columns: 1fr; height: auto; padding: 10px 16px; }
  .top::before { display: none; }
  .who { justify-content: center; }
  .brand { font-size: 20px; }
  .card { padding: 14px; }
}
button.small { font-size: 12px; padding: 2px 10px; border-radius: 6px; }
table.lib .acts { display: inline-flex; gap: 6px; }
.badge.open { color: var(--warn); } .badge.merged { color: var(--ok); } .badge.discarded { color: var(--muted); }

/* the ROM modules of a ROM release, in ROM order: drag or arrows */
.romlist { background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 6px; margin-bottom: 8px; }
.romrow { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.romrow + .romrow { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.romrow .grip { cursor: grab; color: var(--muted); user-select: none; }
.romrow .pos { width: 2em; text-align: right; color: var(--muted); }
.romrow .mname { flex: 1 1 auto; }
.romrow select { width: auto; padding: 2px 6px; font-size: 13px; }
.romrow .rm { color: var(--bad); border: 0; background: none; padding: 0 4px; }
.romrow.dragging { opacity: .4; }
.romrow.over { outline: 2px solid var(--accent); }
.romlist + .row select { width: auto; min-width: 280px; }
table.romtable { margin-top: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
table.romtable td:nth-child(2) { text-align: right; padding-right: 16px; }
.romtick { margin-bottom: 10px; }
.romtick label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.romtick select { width: auto; padding: 4px 8px; }

/* ApolloKnowledgeBase-Manager additions */
.field { margin: 12px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400 !important; }
.choice.on { border-color: var(--accent); }
.mono, textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
pre.preview { white-space: pre-wrap; max-height: 480px; overflow: auto; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 13px; background: var(--chip); }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); }
p.ok { color: var(--ok); }
