:root {
  --ink: #16383a;
  --muted: #657779;
  --teal: #174a4d;
  --teal-2: #27767a;
  --mint: #e8f3f1;
  --gold: #e9aa22;
  --red: #b84646;
  --green: #267042;
  --bg: #f3f6f5;
  --white: #fff;
  --line: #d9e3e1;
  --shadow: 0 12px 35px rgb(19 55 57 / 12%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  line-height: 1.65;
}

.topbar {
  background: linear-gradient(135deg, #123c3f, #247277);
  color: #fff;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1180px;
  margin: auto;
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}
.brand h1 { margin: 0; font-size: clamp(24px, 4vw, 36px); }
.brand p { margin: 4px 0 0; color: #d8eeec; }
.container { max-width: 1180px; margin: 28px auto 70px; padding: 0 18px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 6px 22px rgb(19 55 57 / 7%);
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
.align-end { display: flex; align-items: end; }
label { display: block; font-weight: 700; margin-bottom: 7px; }
.hint, .muted { color: var(--muted); font-size: 14px; }
.required { color: var(--red); }

input, select, textarea {
  width: 100%;
  border: 1px solid #bfcfcd;
  background: #fff;
  border-radius: 11px;
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: .18s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgb(39 118 122 / 14%);
}
input:disabled, select:disabled { background: #edf1f0; color: #788; }
button, .button {
  border: 0;
  border-radius: 11px;
  padding: 11px 17px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: .18s;
}
.primary { background: var(--teal); color: #fff; }
.primary:hover { background: #0d393b; }
.secondary { background: var(--mint); color: var(--teal); }
.outline { background: transparent; color: #fff; border: 1px solid #ffffffaa; }
button:disabled, .button.disabled { opacity: .48; cursor: not-allowed; pointer-events: none; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.loading { opacity: .6; pointer-events: none; }

.status-pill {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 1200;
  padding: 7px 9px 7px 13px;
  border-radius: 16px;
  background: rgb(23 74 77 / 96%);
  border: 1px solid rgb(255 255 255 / 55%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background .25s, transform .25s;
}
.timer { font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 900; }
.pause-button { padding: 6px 10px; border-radius: 9px; background: #fff; color: var(--teal); font-size: 13px; }
.pause-meta { font-size: 11px; color: #d9efec; }
.status-pill.warning {
  background: #d97706;
  border-color: #fff3c4;
  transform: scale(1.03);
  animation: timer-pulse 1s ease-in-out infinite alternate;
}
.status-pill.expired { background: #b91c1c; border-color: #fecaca; animation: none; }
.status-pill.paused { background: #315b85; border-color: #d8e8f9; animation: none; }
@keyframes timer-pulse {
  from { box-shadow: 0 8px 24px rgb(0 0 0 / 22%); }
  to { box-shadow: 0 0 0 7px rgb(217 119 6 / 24%), 0 8px 24px rgb(0 0 0 / 22%); }
}

.task-card { overflow: hidden; }
.task-heading { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.task-heading h2 { margin: 0; }
.task-kicker { font-size: 13px; color: var(--teal-2); font-weight: 800; letter-spacing: .04em; }
.task-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  flex: none;
}
.task-content { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 22px; }
.task-main { min-width: 0; }
.task-side { background: #f5f9f8; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.task-steps { margin: 8px 0 18px; padding: 0; list-style: none; counter-reset: step; }
.task-steps li {
  counter-increment: step;
  position: relative;
  padding: 12px 12px 12px 48px;
  margin: 8px 0;
  background: #f8fbfa;
  border: 1px solid #e1ebe9;
  border-radius: 12px;
}
.task-steps li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 11px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}
.download-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 18px; }
.upload { border: 2px dashed #a9c3c0; border-radius: 14px; padding: 16px; background: #f9fbfb; }
.upload input { border: 0; padding: 5px; background: transparent; }
.upload-gap { margin-top: 12px; }
.file-state { font-size: 13px; color: var(--muted); margin-top: 7px; overflow-wrap: anywhere; }
.file-state.error { color: var(--red); font-weight: 700; }
.file-limit { font-size: 12px; color: var(--muted); margin-top: 5px; }
.column-panel { margin: 16px 0; border: 1px solid #c9dcda; border-radius: 14px; overflow: hidden; }
.column-panel h4 { margin: 0; padding: 11px 14px; background: var(--teal); color: #fff; }
.column-panel.hidden-list h4 { background: #6b7778; }
.column-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; background: #f9fbfb; }
.column-chip { padding: 5px 9px; border-radius: 999px; background: #dff0ed; color: var(--teal); font-size: 13px; font-weight: 800; }
.hidden-list .column-chip { background: #e9ecec; color: #596566; }
.output-order { margin-top: 12px; padding: 12px 14px; border-left: 4px solid var(--gold); background: #fff7df; border-radius: 10px; }

.chat { max-width: 760px; background: #eef4f3; border-radius: 18px; padding: 16px; }
.bubble { max-width: 78%; padding: 12px 15px; border-radius: 17px; margin: 8px 0; white-space: pre-wrap; }
.incoming { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.outgoing { background: #cdebe5; margin-left: auto; border-bottom-right-radius: 5px; }
.chat-compose { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }
.chat-compose textarea { min-height: 76px; resize: vertical; }
.char-count { text-align: right; color: var(--muted); font-size: 12px; }
.notice { padding: 14px 16px; border-radius: 12px; background: #fff7df; border-left: 4px solid var(--gold); }
.notice.success { background: #e3f4e7; border-left-color: #4b9b59; }
.notice.error { background: #fae5e5; border-left-color: var(--red); }
.submit-message, .submit-actions { margin-top: 12px; }
#examForm.exam-paused { opacity: .58; pointer-events: none; filter: grayscale(.2); }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.kpi .value { font-size: 27px; font-weight: 900; color: var(--teal); }
.kpi .label { font-size: 13px; color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.table-gap { margin-top: 14px; }
table { border-collapse: collapse; width: 100%; min-width: 1050px; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 11px; text-align: left; vertical-align: top; font-size: 14px; }
th { position: sticky; top: 0; background: var(--teal); color: #fff; z-index: 1; white-space: nowrap; }
tr:hover td { background: #f6faf9; }
.score { width: 65px; padding: 7px; }
.small-input { min-width: 115px; padding: 7px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.links a { color: var(--teal-2); font-weight: 700; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--mint); color: var(--teal); font-size: 12px; font-weight: 800; }
.badge.red { background: #f8dede; color: #993939; }
.badge.gold { background: #fff0c8; color: #80600f; }
details pre { white-space: pre-wrap; max-width: 360px; font-size: 11px; background: #eef3f2; padding: 8px; border-radius: 8px; }

.result-page { min-height: 100vh; background: #f2f6f5; color: #213738; }
.result-hero { background: linear-gradient(135deg, #173f42, #216568); color: #fff; padding: 54px 24px 46px; }
.result-hero-inner { max-width: 1160px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.result-eyebrow { font-size: 13px; font-weight: 800; letter-spacing: .16em; color: #bfe1dc; margin-bottom: 10px; }
.result-hero h1 { font-size: 42px; margin: 0 0 10px; }
.result-hero p { margin: 0; color: #d6ece8; font-size: 17px; }
.result-score-ring {
  width: 174px;
  height: 174px;
  border-radius: 50%;
  background: #d5a94f;
  color: #173b3d;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 14px 32px #0003;
  flex: none;
}
.result-score-ring strong { font-size: 62px; line-height: 1; }
.result-score-ring span { font-size: 18px; font-weight: 700; margin-top: 8px; }
.result-container { max-width: 1160px; margin: -20px auto 0; padding: 0 24px 60px; }
.result-summary { background: #fff; border-radius: 18px; box-shadow: 0 12px 34px #163b3d18; display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; }
.result-summary div { padding: 22px 24px; border-right: 1px solid #e3ecea; border-bottom: 1px solid #e3ecea; }
.result-summary span { display: block; color: #6a7b7c; font-size: 13px; margin-bottom: 6px; }
.result-summary strong { font-size: 17px; }
.result-notice { margin: 22px 0; background: #fff5d9; border-left: 5px solid #d5a94f; padding: 18px 22px; border-radius: 12px; }
.result-notice p { margin: 6px 0 0; color: #5d553d; }
.result-section-title { display: flex; justify-content: space-between; align-items: end; margin: 34px 0 16px; }
.result-section-title span { color: #387174; font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.result-section-title h2 { margin: 5px 0 0; }
.result-auto-limit { background: #e4f0ee; border-radius: 999px; padding: 10px 16px; color: #245457; }
.result-tasks { display: grid; gap: 18px; }
.result-task { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 8px 26px #163b3d12; }
.result-task-head { padding: 20px 24px; background: #eaf3f1; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.result-task-head h3 { margin: 0; color: #173f42; }
.result-task-score { font-size: 24px; font-weight: 900; color: #173f42; white-space: nowrap; }
.result-criteria { width: 100%; border-collapse: collapse; min-width: 720px; }
.result-criteria th, .result-criteria td { padding: 13px 16px; border-bottom: 1px solid #edf1f0; text-align: left; vertical-align: top; }
.result-criteria th { font-size: 12px; color: #fff; }
.result-criteria td:nth-child(2) { white-space: nowrap; font-weight: 800; }
.result-status { display: inline-block; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.result-status.pass { background: #dcefe5; color: #16653a; }
.result-status.partial { background: #fff0c6; color: #7a5500; }
.result-status.fail { background: #fde0df; color: #a22d27; }
.result-note { color: #647576; font-size: 13px; line-height: 1.55; }
.result-answer-section { margin-top: 30px; }
.result-answer-badge { background: #e4f0ee; border-radius: 999px; padding: 10px 16px; color: #245457; font-weight: 800; }
.result-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.result-answer { background: #fff; border: 1px solid #dce8e6; border-radius: 18px; padding: 22px 24px; box-shadow: 0 8px 26px #163b3d0d; }
.result-answer h3 { margin: 0 0 12px; color: #173f42; }
.result-answer ul { margin: 0; padding-left: 1.35rem; color: #536768; }
.result-answer li { margin: 7px 0; line-height: 1.65; }
.result-model-answer { margin-top: 16px; padding: 15px 17px; border-radius: 12px; background: #eef6f4; border-left: 4px solid #387174; }
.result-model-answer strong { color: #245457; }
.result-model-answer p { margin: 7px 0 0; color: #334f51; line-height: 1.7; }
.result-answer-files-card { margin-top: 20px; padding: 24px; background: #fff; border-radius: 18px; box-shadow: 0 8px 26px #163b3d0d; }
.result-answer-files-card h3 { margin: 0 0 6px; color: #173f42; }
.result-answer-files-card p { margin: 0 0 18px; color: #647576; }
.result-answer-files { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.result-answer-file { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border: 1px solid #cbdedb; border-radius: 13px; color: #173f42; background: #f8fbfa; text-decoration: none; }
.result-answer-file:hover { border-color: #387174; background: #eef6f4; }
.result-answer-file.featured { grid-column: 1 / -1; background: #173f42; border-color: #173f42; color: #fff; }
.result-answer-file span { min-width: 0; }
.result-answer-file strong, .result-answer-file small { display: block; }
.result-answer-file small { margin-top: 4px; color: #6c7b7c; overflow-wrap: anywhere; }
.result-answer-file.featured small { color: #cfe5e1; }
.result-answer-file em { flex: none; font-size: 12px; font-style: normal; font-weight: 900; color: #387174; }
.result-answer-file.featured em { color: #f1cf82; }
.result-download-card, .result-reset-card {
  margin-top: 24px;
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: 0 8px 26px #163b3d12;
}
.result-download-card h2, .result-reset-card h3 { margin: 0 0 8px; }
.result-download-card p, .result-reset-card p { margin: 0; color: #687879; }
.result-download-button { font-size: 17px; padding: 14px 24px; white-space: nowrap; }
.result-error { color: #9e2924; margin-top: 10px; }
.result-drive-status { margin-top: 8px !important; }
.result-drive-link { display: inline-block; margin-top: 8px; color: #17636a; font-weight: 800; }
.result-report-actions { display: flex; flex-direction: column; gap: 9px; align-items: stretch; }
.result-retry-button { background: #fff; border: 1px solid var(--red); color: #9e2924; }
.result-reset-card { display: block; text-align: center; border: 1px dashed #bdc9c7; box-shadow: none; }
.result-reset-button { margin-top: 16px; background: #fff; border: 1px solid #9dacab; color: #3d5556; }

@media (max-width: 850px) {
  .col-2, .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
  .topbar-inner { align-items: flex-start; flex-direction: column; }
  .task-content { grid-template-columns: 1fr; }
  .task-side { order: 2; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .result-summary { grid-template-columns: 1fr 1fr; }
  .result-section-title, .result-download-card { align-items: stretch; flex-direction: column; }
  .result-answers { grid-template-columns: 1fr; }
  .result-answer-files { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .status-pill { top: 8px; right: 8px; font-size: 12px; max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: flex-end; }
  .timer { font-size: 16px; }
  .pause-meta { display: none; }
  .chat-compose { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .result-hero-inner { display: block; }
  .result-score-ring { margin-top: 24px; width: 130px; height: 130px; }
  .result-score-ring strong { font-size: 46px; }
  .result-summary { grid-template-columns: 1fr; }
  .result-task-head { align-items: flex-start; }
}
