/* 關卡的原生流程（quest-flow.js）。顏色沿用學區的 --d-color／--d-pale。 */
.flow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  background: #fffef8;
  /* 裡面有絕對定位的元素（驗收清單隱藏的核取方塊）：不在這裡定位的話，
     它們會算進外層側欄的高度，側欄就多出第二條捲軸。 */
  position: relative;
}
.flow-head {
  padding: 16px 22px 0;
}
.flow-id {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font: 700 11px var(--nums);
  letter-spacing: 0.06em;
  color: var(--d-color);
}
.flow-id span {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}
.flow-head h2 {
  margin: 4px 0 14px;
  font-size: 23px;
  line-height: 1.3;
  outline: none;
}
.flow-stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  border-bottom: 1px solid var(--line);
}
.flow-stages a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 4px 10px;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 680;
  color: #6a7b70;
  white-space: nowrap;
}
.flow-stages b {
  display: grid;
  place-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e6eadf;
  font: 700 11px var(--nums);
  color: #55675b;
}
.flow-stages a:hover {
  color: var(--ink);
}
.flow-stages a[aria-current] {
  color: var(--ink);
  border-bottom-color: var(--d-color);
}
.flow-stages a[aria-current] b {
  background: var(--d-color);
  color: #fffcef;
}
.flow-stages a.is-done b {
  background: #f4cf79;
  color: #264534;
  font-size: 0;
}
.flow-stages a.is-done b:before {
  content: "✓";
  font-size: 12px;
}
.flow-body {
  flex: 1;
  padding: 18px 22px 8px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.flow-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: #fffef8f2;
  backdrop-filter: blur(6px);
}
.flow-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid #174737;
  border-radius: 9px;
  background: #fffdf5;
  color: #174737;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}
.flow-button:hover {
  background: #edf2e7;
}
.flow-primary {
  background: #174737;
  color: #fffcef;
}
.flow-primary:hover {
  background: #28594a;
}
.flow-time {
  font: 700 11px var(--nums);
  letter-spacing: 0.05em;
  color: var(--d-color);
}
.flow-step-title {
  margin-top: -10px;
  font-size: 18px;
  line-height: 1.35;
}
.flow-goal {
  padding-left: 11px;
  border-left: 3px solid var(--d-color);
  font-size: 14.5px;
  color: #3d5246;
}
.flow-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbf3;
}
.flow-card > h3,
.flow-story h3 {
  margin-bottom: 8px;
  font-size: 15.5px;
  line-height: 1.4;
}
.flow h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  color: #3d5246;
}
.flow h5 {
  margin: 10px 0 4px;
  font-size: 12.5px;
}
.flow-body p,
.flow-body li,
.flow-body dd {
  font-size: 14px;
  line-height: 1.7;
  color: #33463b;
}
.flow-body p + p {
  margin-top: 8px;
}
.flow-list,
.flow-prose ol,
.flow-prose ul,
.flow-more ol,
.flow-more ul,
.flow-after ol,
.flow-after ul,
.flow-selfcheck ul {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  gap: 6px;
}
.flow-body a:not(.flow-button) {
  color: #1d5a45;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.flow-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #ecefe2;
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
}
.flow-body pre {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 9px;
  background: #1f3a31;
  color: #f3f1de;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12.5px/1.65 ui-monospace, "SF Mono", Menlo, monospace;
}
.flow-body pre code {
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
}
.flow-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.flow-body th,
.flow-body td {
  padding: 6px 8px;
  border: 1px solid var(--line);
  text-align: left;
}
.flow-prose .resource-row,
.flow-prose .result-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.flow-prose .example-outcomes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.flow-prose .example-outcomes > div {
  padding: 10px 12px;
  border-radius: 9px;
  background: #fffef8;
  border: 1px solid var(--line);
}
.flow-prose .example-outcomes h4 {
  margin-top: 0;
}
.flow-prose .example-caption {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.flow-example {
  background: var(--d-pale);
  border-color: transparent;
}
/* 故事 */
.flow-story {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 14px;
  background: var(--d-pale);
}
.flow-story img {
  flex: none;
  width: 124px;
  height: 150px;
  object-fit: cover;
  object-position: top;
  border-radius: 12px;
  background: #fffef8;
}
.flow-kicker {
  font: 700 11px var(--sans) !important;
  letter-spacing: 0.08em;
  color: var(--d-color) !important;
}
.flow-story blockquote {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 4px 14px 14px 14px;
  background: #fffef8;
}
.flow-story blockquote p {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.flow-story cite {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}
.flow-reward {
  margin-top: 10px !important;
  padding: 8px 11px;
  border-radius: 8px;
  background: #faedc9;
  font-size: 13px !important;
  font-weight: 650;
  color: #5e4410 !important;
}
/* 小測驗 */
.flow-quiz fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 7px;
}
.flow-quiz legend {
  margin-bottom: 9px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}
.flow-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffef8;
  font-size: 14px;
  line-height: 1.55;
  cursor: pointer;
}
.flow-option input {
  margin-top: 4px;
  accent-color: #174737;
}
.flow-option:has(input:checked) {
  border-color: var(--d-color);
  background: var(--d-pale);
}
.flow-quiz .flow-button {
  margin-top: 11px;
}
.flow-status {
  margin-top: 8px;
  font-size: 12.5px !important;
  color: var(--muted) !important;
}
.flow-quiz[data-result="right"] .flow-status {
  color: #1d5a45 !important;
  font-weight: 650;
}
.flow-quiz[data-result="wrong"] .flow-status {
  color: #9a4a2c !important;
  font-weight: 650;
}
/* Prompt */
.flow-lead {
  color: var(--muted) !important;
}
.flow-tabs {
  display: inline-flex;
  gap: 3px;
  margin: 14px 0 4px;
  padding: 3px;
  border-radius: 10px;
  background: #e9ede0;
}
.flow-tabs button {
  padding: 7px 16px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 680;
  color: #55675b;
  cursor: pointer;
}
.flow-tabs button[aria-selected="true"] {
  background: #fffef8;
  color: var(--ink);
  box-shadow: 0 1px 3px #183b3526;
}
.flow-promptbox {
  margin-top: 12px;
  border: 1px solid #1f3a31;
  border-radius: 11px;
  overflow: hidden;
  background: #1f3a31;
}
.flow-promptbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  font-size: 12.5px;
  font-weight: 650;
  color: #dfe7d5;
}
.flow-promptbar .flow-button {
  min-height: 32px;
  border-color: #f4cf79;
  background: #f4cf79;
  color: #264534;
}
.flow-promptbox .flow-status {
  margin: 0;
  padding: 0 14px 6px;
  color: #b9c9b6 !important;
}
.flow-promptbox pre {
  margin: 0;
  max-height: 300px;
  border-radius: 0;
  border-top: 1px solid #ffffff1f;
}
.flow-more {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffef8;
}
.flow-more > summary {
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 680;
  cursor: pointer;
}
.flow-more > :not(summary) {
  margin: 0 12px 10px;
}
.flow-more dt {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
}
.flow-more dd {
  margin: 2px 0 0;
}
.flow-required {
  border-color: var(--d-color);
}
.flow-challenge {
  margin-top: 0;
}
/* 勾選：這一步做完了 */
.flow-check {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 2px solid #174737;
  border-radius: 12px;
  background: #fffef8;
  cursor: pointer;
}
.flow-check input {
  position: absolute;
  opacity: 0;
}
.flow-check-box {
  flex: none;
  display: grid;
  place-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #174737;
  border-radius: 9px;
  background: #fff;
  color: transparent;
  font-size: 18px;
  font-weight: 800;
}
.flow-check-box:before {
  content: "✓";
}
.flow-check input:checked + .flow-check-box {
  background: #f4cf79;
  color: #264534;
}
.flow-check input:focus-visible + .flow-check-box {
  outline: 3px solid #b76610;
  outline-offset: 3px;
}
.flow-check strong {
  display: block;
  font-size: 14.5px;
  line-height: 1.5;
}
.flow-check small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.flow-check:has(input:checked) {
  background: #fdf4d8;
}
.flow-finish.is-done {
  border-color: #e3c06a;
  background: #fdf4d8;
}
.flow-note label {
  display: block;
  margin: 10px 0 6px;
  font-size: 13px;
  font-weight: 700;
}
.flow-note textarea {
  width: 100%;
  min-height: 130px;
  padding: 10px 12px;
  border: 1px solid #b9c5b4;
  border-radius: 9px;
  background: #fffef8;
  font: 14px/1.6 var(--sans);
  color: var(--ink);
  resize: vertical;
}
.flow-loading {
  padding: 30px 22px;
  color: var(--muted);
}
@media (max-width: 680px) {
  .flow-head {
    padding: 12px 14px 0;
  }
  .flow-head h2 {
    font-size: 20px;
  }
  .flow-body {
    padding: 14px 14px 6px;
  }
  .flow-foot {
    padding: 10px 14px;
  }
  .flow-stages a {
    flex-direction: column;
    gap: 3px;
    font-size: 11.5px;
  }
  .flow-story {
    flex-direction: column;
  }
  .flow-story img {
    width: 92px;
    height: 110px;
  }
}

.flow-draft {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: #faedc9;
  font-weight: 650;
  color: #5e4410 !important;
}
.flow-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.flow-tabs button {
  display: grid;
  gap: 1px;
  padding: 7px 12px;
  text-align: left;
}
.flow-tabs small {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.flow-reveal > .flow-promptbox {
  margin: 0 0 0;
  border-radius: 0 0 8px 8px;
}
.flow-reveal > :not(summary) {
  margin: 0;
}

.flow-newfiles {
  margin-top: 8px;
  font-size: 13px !important;
  color: #5e4410 !important;
}
.flow-extra h2 {
  margin-bottom: 8px;
  font-size: 15.5px;
}
.flow-closing {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--muted) !important;
}

.flow-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 12px;
}
.flow-plain {
  padding: 6px 2px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  color: #9a4a2c;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* 操作指南 */
.reader-bar button.back {
  cursor: pointer;
}
.flow-guide {
  display: grid;
  gap: 12px;
}
.flow-guide h2 {
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.4;
}
.flow-guide h3 {
  font-size: 15px;
}
.flow-guide blockquote {
  margin: 0;
  padding: 9px 13px;
  border-left: 3px solid var(--line);
  background: #fbfbf3;
}
.flow-guide img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.flow-copyrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.flow-copyrow .flow-button {
  min-height: 30px;
  padding: 4px 11px;
  font-size: 12px;
}
.flow-copyrow .flow-status {
  margin: 0;
}
.flow-guide .table-scroll {
  overflow-x: auto;
}

/* 閱讀寬度：面板變寬時，內文維持好讀的行長並置中 */
.flow-head,
.flow-body,
.flow-foot {
  padding-inline: max(22px, calc((100% - 880px) / 2));
}
.flow-body p,
.flow-body li,
.flow-body dd {
  font-size: 15px;
}
.flow-head h2 {
  font-size: 26px;
}
.reader-widen {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  color: #456957;
  white-space: nowrap;
  cursor: pointer;
}
.reader-widen:hover {
  background: #edf2e7;
}
.reader-widen .icon {
  width: 14px;
  height: 14px;
}
.flow-island {
  padding: 8px 11px;
  border-radius: 8px;
  background: #fffef8;
  font-size: 13px !important;
  color: #5e4410 !important;
}
@media (max-width: 680px) {
  .reader-widen {
    display: none;
  }
  .flow-head,
  .flow-body,
  .flow-foot {
    padding-inline: 14px;
  }
  .flow-head h2 {
    font-size: 21px;
  }
}

/* 窄螢幕：長路徑、長指令與表格不把版面撐寬 */
.flow-body {
  grid-template-columns: minmax(0, 1fr);
}
.flow-body :is(p, li, dd, td, th, code, summary, h3, h4) {
  overflow-wrap: anywhere;
}
.flow-prose .table-scroll,
.flow-prose:has(> table) {
  overflow-x: auto;
}
.flow-prose h2 {
  margin: 10px 0 2px;
  font-size: 17px;
  line-height: 1.4;
}
