/* © 2569 (2026) mindData Technology Co., Ltd. */

:root {
  color-scheme: light dark;
  --paper: #f5f4ef;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #4d5a66;
  --line: #d6d9d3;
  --accent: #0a5c63;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ef;
  --danger: #a3261c;
  --danger-soft: #fbeceb;
  --ok: #1d6a3a;
  --ok-soft: #e6f3ea;
  --focus: #b3540a;
  --radius: 12px;
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10171d;
    --surface: #18222b;
    --ink: #e8edf0;
    --muted: #a9b6c0;
    --line: #33424e;
    --accent: #6fcfd0;
    --accent-ink: #06282b;
    --accent-soft: #17363a;
    --danger: #ff9d92;
    --danger-soft: #3a1d1b;
    --ok: #8bd8a5;
    --ok-soft: #173224;
    --focus: #ffb86b;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.65 var(--font);
}

/* Ownership mark: a faint tiled wordmark behind the page. It never takes a click. */
.watermark {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  opacity: 0.05;
}

.watermark text {
  fill: var(--ink);
  font: 600 17px var(--font);
  letter-spacing: 0.04em;
}

.top,
main,
.foot {
  position: relative;
  z-index: 1;
}

a {
  color: var(--accent);
  text-underline-offset: 0.3em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

main:focus {
  outline: none;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 2;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.skip:focus {
  top: 0.75rem;
}

/* --- header --- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}

/* The mindData wordmark, set in type: inline SVG, nothing fetched. */
.wordmark {
  width: 104px;
  height: 28px;
  flex: none;
}

.wordmark text {
  fill: var(--accent);
  font: 700 22px var(--font);
}

.brand-product {
  padding-left: 0.6rem;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem 1rem;
  flex-wrap: wrap;
}

.top-nav a,
.top-nav .link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.top-nav form {
  margin: 0;
}

.who {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.pill {
  padding: 0 1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
}

/* --- page --- */

main {
  flex: 1;
  width: 100%;
  padding: clamp(1.25rem, 5vw, 3.5rem) 1rem;
}

.card {
  width: 100%;
  max-width: 27rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 5vw, 2.25rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.05);
}

.card.wide {
  max-width: 44rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.45rem, 4.5vw, 1.75rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h2 {
  margin: 1.75rem 0 0.25rem;
  font-size: 1.1rem;
  line-height: 1.4;
}

p {
  margin: 0 0 1rem;
}

.lead {
  color: var(--muted);
}

.prose p {
  max-width: 65ch;
}

/* --- forms --- */

form {
  margin: 1.25rem 0 0;
}

.field {
  margin-bottom: 1.1rem;
}

label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

input:not([type="hidden"]) {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--muted);
  border-radius: 8px;
  font: inherit;
}

input:focus-visible {
  border-color: var(--accent);
  border-radius: 8px;
}

input[name="code"] {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.35em;
}

.invalid input {
  border-color: var(--danger);
}

.hint,
.error {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.hint {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-weight: 600;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.6rem 1.25rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
}

button.primary:hover,
.button:hover,
button.secondary:hover {
  filter: brightness(1.1);
}

button.link {
  min-height: 44px;
  padding: 0;
  border: 0;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.quiet {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.quiet p {
  margin-bottom: 0.6rem;
  color: var(--muted);
}

.consent {
  color: var(--muted);
  font-size: 0.95rem;
}

.alt {
  margin: 1.1rem 0 0;
  color: var(--muted);
}

/* --- messages --- */

/* A tinted box with a hairline border. The state is also a glyph, never colour alone. */
.notice,
.alert,
.success {
  position: relative;
  margin: 1rem 0;
  padding: 0.8rem 1rem 0.8rem 2.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
}

.notice::before,
.alert::before,
.success::before {
  content: "i";
  position: absolute;
  left: 0.85rem;
  top: 0.95rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 0.9rem/1.4rem system-ui, sans-serif;
  text-align: center;
}

.notice p {
  margin-bottom: 0.75rem;
}

.notice .button {
  background: var(--surface);
}

.alert::before {
  content: "!";
  background: var(--danger);
}

.success::before {
  content: "✓";
  background: var(--ok);
}

.alert {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.success {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
}

.facts {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.facts div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* --- competition pages --- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One column: heading, tabs, then the panels of the page. */
.sheet {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
}

.sheet .card {
  max-width: none;
  margin: 0 0 1rem;
}

.sheet h2 {
  margin-top: 0;
}

.round-head h1 {
  overflow-wrap: anywhere;
}

.round-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  color: var(--muted);
}

.chip {
  padding: 0.05rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip-open {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.tabs {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0 0.25rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0 0.85rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current] {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.count {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem 0 0;
}

.button.solid {
  background: var(--accent);
  color: var(--accent-ink);
}

.rules {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.rules li {
  max-width: 65ch;
  margin-bottom: 0.4rem;
}

.total {
  margin-top: 0.25rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.total dd {
  font-size: 1.15rem;
}

/* Data files: the name and what it is, with its download beside it. */
.files {
  margin: 0;
  padding: 0;
  list-style: none;
}

.files li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.files li > div {
  flex: 1 1 14rem;
  min-width: 0;
}

.file-name,
.code {
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

.round-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.code {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

/* Uploads and picks. */
input[type="file"] {
  padding: 0.5rem;
  border-style: dashed;
}

input[type="file"]::file-selector-button {
  min-height: 36px;
  margin-right: 0.75rem;
  padding: 0 0.9rem;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input[type="checkbox"] {
  display: inline-block;
  width: 1.5rem;
  min-height: 0;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.busy,
.htmx-request .idle {
  display: none;
}

.htmx-request .busy {
  display: inline;
}

#submit-result:not(:empty) {
  margin-top: 1.25rem;
}

.alert p,
.success p {
  margin: 0;
  overflow-wrap: anywhere;
}

.alert .plain,
.success .plain {
  margin-top: 0.35rem;
  color: var(--ink);
  font-weight: 400;
}

.score-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6rem;
}

.score {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.quota {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

/* The leaderboard, and the table of a learner's own files. */
.scroll {
  overflow-x: auto;
}

.board {
  width: 100%;
  border-collapse: collapse;
}

.board th,
.board td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.board th {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.board .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board .name {
  min-width: 6rem;
  overflow-wrap: break-word;
}

.board .check {
  width: 3.5rem;
}

.board label {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  font-weight: 400;
}

.board .me td {
  background: var(--accent-soft);
  font-weight: 600;
}

.you {
  padding: 0 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.shake {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.shake .up {
  color: var(--ok);
}

.shake .down {
  color: var(--danger);
}

.standing {
  font-weight: 600;
}

.footnote {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.board + button {
  margin-top: 1rem;
}

form + .hint {
  margin-top: 0.9rem;
}

/* --- staff: one block per learner's report --- */

.reports {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hint + .reports {
  margin-top: 0.9rem;
}

.reports > li {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.report-head,
.report-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.report-head h3 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.report-file {
  margin-top: 0.6rem;
}

.report-file > div {
  flex: 1 1 14rem;
  min-width: 0;
}

/* A name the learner chose is prose, often Thai: the page font, not the code font. */
.report-file .file-name {
  font-family: inherit;
  font-size: 1rem;
}

.report-file .hint,
.notice .hint {
  margin: 0;
}

.notice .hint {
  margin-top: 0.75rem;
}

.notice .actions,
.notice form {
  margin: 0;
}

.mark {
  margin-top: 0.9rem;
}

.mark-row {
  display: flex;
  gap: 0.6rem;
}

.mark-row input {
  flex: 0 1 8rem;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.alert p {
  margin: 0;
}

.alert ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* --- footer --- */

.foot {
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 1.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.foot-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 1.25rem;
}

.foot-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.foot-nav a[aria-current] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.copyright {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
  .brand-product,
  .narrow-hide {
    display: none;
  }

  .tabs {
    gap: 0;
  }

  .tabs a {
    flex: 1 0 auto;
    justify-content: center;
    padding: 0 0.3rem;
  }

  .count {
    padding: 0 0.35rem;
  }

  .board th,
  .board td {
    padding: 0.6rem 0.3rem;
  }

  .files .button,
  .report-file .button,
  .actions .button,
  .actions form {
    width: 100%;
  }

  .mark-row input {
    flex: 1 1 5rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .skip {
    transition: top 0.15s ease-out;
  }
}

/* --- staff: who a learner is (external ids beside the display name), id disputes --- */

.who-is {
  flex: 1 1 12rem;
  min-width: 0;
}

.ext-id {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.ext-id-label::after {
  content: ":";
}

.chip-warn {
  border-color: var(--danger);
  background: var(--danger-soft);
  display: inline-block;
  color: var(--danger);
  white-space: normal;
}

.disputes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.disputes li {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.disputes .ext-id {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.dispute-names {
  display: block;
  overflow-wrap: anywhere;
}

.actions + .hint {
  margin-top: 0.6rem;
}
