:root {
  --ink:     #12203c;
  --slab:    #1b2f52;
  --line:    #c9d1e0;
  --wash:    #eef1f6;
  --paper:   #ffffff;
  --muted:   #5b6b85;
  --running: #1f6b4f;
  --alarm:   #9c1c1c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

/* ---------------- login / waiting / closed ---------------- */
.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--ink);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border-radius: 4px;
  padding: 40px 36px 32px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.crest {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  margin: 0;
}

.crest + p {
  margin: 6px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.paper-line {
  font-family: Georgia, serif;
  font-size: 16px;
  margin: 0 0 26px;
}

.standby {
  font-size: 15px;
  line-height: 1.7;
  margin: 26px 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.waitclock { margin: 26px 0; }

.waitclock time {
  display: block;
  font-size: 48px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.waitclock small {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fbfcfe;
  margin-bottom: 18px;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #4a7fd4;
  outline-offset: 2px;
}

button {
  width: 100%;
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--paper);
  background: var(--slab);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

button:hover { background: var(--ink); }

.notice {
  border-left: 3px solid var(--alarm);
  background: #fdf3f3;
  color: var(--alarm);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 20px;
}

.fineprint {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------------- exam ---------------- */
.exam-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  flex-shrink: 0;
}

.bar .who { font-size: 14px; line-height: 1.35; }
.bar .who strong { display: block; font-size: 15px; }
.bar .who span { color: #a9b6cd; }

.bar .paper-code {
  font-family: Georgia, serif;
  font-size: 15px;
  padding: 4px 10px;
  border: 1px solid #3d557f;
  border-radius: 3px;
}

.clock {
  margin-left: auto;
  text-align: right;
  line-height: 1;
}

.clock time {
  display: block;
  font-size: 40px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.clock small { font-size: 12px; color: #a9b6cd; }

.clock.warn time   { color: #ffc25c; }
.clock.alarm time  { color: #ff8d8d; animation: tick 1s steps(2) infinite; }
.clock.alarm small { color: #ff8d8d; }

@keyframes tick { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .clock.alarm time { animation: none; }
}

.bar button {
  width: auto;
  padding: 9px 18px;
  background: transparent;
  border: 1px solid #5b7bb0;
}

.bar button:hover { background: var(--slab); }

.viewer {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  background: #56585c;
  padding: 20px 0 40px;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}

.sheet {
  display: block;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 20px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
  pointer-events: none;
}

.fallback {
  color: #fff;
  padding: 40px;
  font-size: 15px;
  text-align: center;
}

.fallback a { color: #ffc25c; }

/* ---------------- answer sheet upload ---------------- */
.submit-wrap {
  min-height: 100%;
  display: grid;
  place-items: start center;
  padding: 32px 24px 60px;
  background: var(--ink);
}

.submit-card {
  width: 100%;
  max-width: 470px;
  background: var(--paper);
  border-radius: 4px;
  padding: 36px 36px 30px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.deadline {
  margin: 22px 0 24px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.deadline time {
  display: block;
  font-size: 40px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.deadline small {
  display: block;
  margin-top: 7px;
  font-size: 13px;
  color: var(--muted);
}

.deadline.warn time  { color: #a8681a; }
.deadline.alarm time { color: var(--alarm); }

input[type="file"] {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px dashed var(--line);
  border-radius: 3px;
  background: #fbfcfe;
  margin-bottom: 16px;
  cursor: pointer;
}

button:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: default;
}

.listhead {
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: normal;
  margin: 26px 0 8px;
}

.filelist {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}

.filelist li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.filelist span { word-break: break-all; }

.filelist em {
  font-style: normal;
  color: var(--muted);
  white-space: nowrap;
}

.empty {
  margin: 24px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------- finished ---------------- */
.done {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.done-card {
  max-width: 460px;
  background: var(--paper);
  border-top: 4px solid var(--running);
  padding: 36px;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(18, 32, 60, .12);
}

.done-card h1 {
  font-family: Georgia, serif;
  font-size: 24px;
  margin: 0 0 12px;
}

.done-card p { line-height: 1.65; color: #33405c; }

/* ---------------- admin ---------------- */
.admin-wrap { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

.admin-wrap h1 {
  font-family: Georgia, serif;
  font-size: 24px;
  margin: 0 0 4px;
}

.admin-wrap > p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

th { background: var(--ink); color: var(--paper); font-weight: 600; }

td.time { font-variant-numeric: tabular-nums; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--line);
}
.dot.running { background: var(--running); }
.dot.done    { background: var(--slab); }
.dot.over    { background: var(--alarm); }

/* ---------------- admin: sheets ---------------- */
.adminbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
  font-size: 14px;
}

.backlink {
  margin: 0 0 14px;
  font-size: 13px;
}

.backlink a, a.quiet {
  color: var(--muted);
  text-decoration: none;
}

.backlink a:hover, a.quiet:hover { color: var(--ink); }

a.open {
  color: var(--slab);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

a.open:hover { border-bottom-color: var(--slab); }

/* ---------------- login clock ---------------- */
.gateclock {
  margin: 0 0 24px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gateclock time {
  display: block;
  font-size: 38px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gateclock small {
  display: block;
  margin-top: 7px;
  font-size: 13px;
  color: var(--muted);
}

.gateclock.running time { color: var(--running); }
.gateclock.upload time  { color: #a8681a; }

.whenline {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.6;
}

.whenline span { color: var(--muted); font-size: 13px; }