/* CS330 competition — additions on top of the shared app.css design system. */

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
:not(pre) > code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
pre.code { margin: 10px 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; line-height: 1.5; font-size: 13px; }
pre.code.log { max-height: 320px; white-space: pre-wrap; word-break: break-word; }
.text-danger { color: var(--danger); }
.hero-stats dd.dd-small, .stat dd.dd-small { font-size: 20px; }
.hero .lead code { background: var(--surface); }
.page-head--admin { background: radial-gradient(520px 220px at 0% 0%, color-mix(in srgb, #0fa598 14%, transparent), transparent 70%); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.narrow { max-width: 560px; }

/* Leaderboard */
.lb-wrap { position: relative; }
.lb-table, .data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.lb-table th, .lb-table td, .data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.lb-table th, .data-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.lb-table tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: 0; }
.lb-table td { vertical-align: middle; }
.data-table tbody th { width: 180px; font-weight: 700; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.lb-rank { width: 72px; }
.lb-team { font-weight: 700; }
.lb-score { font-weight: 800; font-size: 16px; }
.lb-metric { text-transform: none; letter-spacing: 0; font-weight: 600; }
.rank-badge { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.lb-top-1 .rank-badge { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #5b3a00; }
.lb-top-2 .rank-badge { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; }
.lb-top-3 .rank-badge { background: linear-gradient(135deg, #fed7aa, #c2410c); color: #fff; }
.lb-top { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.lb-me td { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--accent) 10%, transparent); }
.lb-empty { margin-top: 12px; }
.lb-updated { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.lb-flash td { animation: lb-flash 1.2s ease; }
@keyframes lb-flash { from { background: var(--primary-soft); } }
.table-scroll { overflow-x: auto; }
@media (max-width: 640px) { .hide-sm { display: none; } .lb-table th, .lb-table td, .data-table th, .data-table td { padding: 10px 10px; } }

/* Status badges */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.status .icon { width: 14px; height: 14px; }
.status--queued { color: var(--low); background: var(--low-bg); }
.status--running { color: var(--primary); background: var(--primary-soft); }
.status--running .icon { animation: pulse-icon 1.2s ease-in-out infinite; }
@keyframes pulse-icon { 50% { opacity: .35; } }
.status--completed { color: var(--high); background: var(--high-bg); }
.status--failed, .status--disabled { color: var(--danger); background: var(--danger-bg); }
.status--timed_out { color: var(--medium); background: var(--medium-bg); }

/* Stat tiles */
.stat-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 2px; }
.stat dt { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat dd { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; color: var(--primary); }
.stat dd small { font-size: 15px; color: var(--muted); font-weight: 700; }
.stat span { font-size: 13px; color: var(--muted); }

/* Steps & rules */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.step { display: flex; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.step-n { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.explainer { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: start; padding: 28px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
@media (max-width: 860px) { .explainer { grid-template-columns: 1fr; } }
.rule-list { list-style: none; margin: 10px 0 14px; padding: 0; display: grid; gap: 10px; }
.rule-list li { display: flex; gap: 10px; align-items: flex-start; }
.rule-list li > .icon { margin-top: 4px; color: var(--high); }
.rule-list li > .icon[aria-hidden] use[href="#i-x"] { color: var(--danger); }
.doc section > h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.doc section > h3 { font-size: 16px; font-weight: 800; margin: 18px 0 6px; }
.doc section > p { max-width: 52rem; margin-bottom: 10px; }
.doc .data-table { margin: 12px 0; }
.page-head { padding: 40px 0 24px; margin-bottom: 28px; border-bottom: 1px solid var(--border); }
.page-head .lead { margin-top: 6px; }
.page-head .hero-actions { margin-top: 18px; }
.notice { margin: 12px 0 0; }

/* Forms */
.field textarea, .field input[type="file"], .field input[type="datetime-local"], .field select, .form-inline input[type="text"] {
  padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.field select { padding-right: 34px; }
.field input[type="file"] { padding: 9px 10px; }
.field textarea:focus, .form-inline input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-inline .grow { flex: 1; min-width: 220px; }
.form-inline input[type="text"] { height: 40px; padding: 0 12px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.settings-form { display: grid; gap: 18px; max-width: 760px; }
.settings-form fieldset.panel { padding: 20px; }
.settings-form legend { float: left; width: 100%; }
.upload-form { display: grid; gap: 18px; max-width: 760px; }
.upload-form.is-disabled { opacity: .6; }
.mode-switch { display: flex; flex-wrap: wrap; gap: 10px; }
.mode-switch legend { float: left; width: 100%; }
.chip-radio { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); cursor: pointer; font-weight: 600; font-size: 14px; }
.chip-radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.auth-wrap--single { grid-template-columns: minmax(0, 520px); }
.auth-head .empty-icon { margin: 0 auto 14px; }
.token-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1.5px dashed var(--border-strong); }
.token-box code { font-size: 17px; font-weight: 700; letter-spacing: .04em; background: none; word-break: break-all; flex: 1; }
.token-panel { border-color: var(--primary); }

/* Admin */
.admin-bar { border-bottom: 1px solid var(--border); background: var(--surface); }
.admin-bar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.admin-bar .chip-row { padding: 10px 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13.5px; white-space: nowrap; color: var(--muted); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip .icon { width: 15px; height: 15px; }

/* Registration codes */
.token-box .code-list { flex: 1; margin: 0; padding: 0; background: none; border: 0; font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 16px; font-weight: 700; letter-spacing: .06em; line-height: 1.7; white-space: pre-wrap; max-height: 320px; overflow: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.doc details { margin: 12px 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.doc details summary { cursor: pointer; font-weight: 700; }
.doc details[open] summary { margin-bottom: 8px; }
