:root {
  --ink: #212830;
  --sub: #5f6873;
  --mute: #8a939d;
  --line: #e3e7eb;
  --bg: #f5f7f9;
  --card: #fff;
  --dark: #2a2f36;
  --accent: #0e8fcc;
  --t-safe: #15803d;
  --t-good: #0e8fcc;
  --t-fair: #b45309;
  --t-push: #c2410c;
  --t-dream: #9d174d;
  --t-low: #8a939d;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 14px 40px;
}

.intro { padding: 4px 2px 14px; }

.kicker {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--accent);
}

.kicker::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 2px;
  margin-right: 10px;
  vertical-align: middle;
  background: #a3c614;
}

h1 { margin: 0; font-size: 26px; line-height: 1.3; }

.accent { color: var(--accent); }

.lead { margin: 8px 0 0; color: var(--sub); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.field { display: block; }

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}

select, input {
  font: inherit;
  color: inherit;
}

select {
  width: 100%;
  height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid #cfd5db;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6873' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
  -webkit-appearance: none;
  appearance: none;
}

.score-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
}

.score-head .label { margin-bottom: 0; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.scores {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.score label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.score input {
  width: 100%;
  height: 46px;
  padding: 0 4px;
  border: 1px solid #cfd5db;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.score input::-webkit-outer-spin-button,
.score input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.score input::placeholder { font-size: 13px; font-weight: 400; color: #b3bac2; }

.score input:focus, select:focus, #q:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 143, 204, .15);
}

.score .pr {
  display: block;
  min-height: 18px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--mute);
  text-align: center;
  white-space: nowrap;
}

.hint { margin: 10px 0 0; font-size: 12.5px; color: var(--mute); }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 0;
}

.seg button {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--sub);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.seg button b {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  background: #eef1f4;
  font-size: 12px;
  font-weight: 600;
}

.seg button b:empty { display: none; }

.seg button.on { background: var(--dark); border-color: var(--dark); color: #fff; }

.seg button.on b { background: rgba(255, 255, 255, .16); }

.tiers {
  display: flex;
  gap: 6px;
  margin: 12px -14px 0;
  padding: 0 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tiers::-webkit-scrollbar { display: none; }

.tiers button {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.tiers button .n { display: block; font-size: 18px; font-weight: 700; line-height: 1.3; }

.tiers button .t { display: block; font-size: 12px; color: var(--sub); }

.tiers button.on { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }

.advice { margin-top: 12px; padding: 12px 14px; }

.advice h2 { margin: 0 0 6px; font-size: 14px; }

.advice ul { margin: 0; padding: 0; list-style: none; }

.advice li { padding: 3px 0; font-size: 14px; color: var(--sub); }

.advice li b { color: var(--ink); }

.advice li a {
  margin-left: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.note { margin: 10px 2px 0; font-size: 13px; color: var(--sub); }

.tools { margin-top: 14px; }

#q {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #cfd5db;
  border-radius: 8px;
  background: #fff;
  -webkit-appearance: none;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 8px;
  margin-top: 8px;
}

.tool-row select { height: 40px; font-size: 14px; }

.count { margin: 14px 2px 6px; font-size: 13px; color: var(--sub); }

.list { margin: 0; padding: 0; list-style: none; }

.item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.row .main { flex: 1; min-width: 0; }

.school { display: block; font-size: 13px; color: var(--sub); }

.dept { display: block; font-size: 16px; font-weight: 600; line-height: 1.4; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  margin-top: 5px;
  font-size: 12px;
  color: var(--mute);
}

.subj {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  background: #eef1f4;
  color: var(--sub);
  font-weight: 600;
  line-height: 20px;
}

.subj.miss { background: #fde8e8; color: #b42318; text-decoration: line-through; }

.stage { color: var(--mute); }

.side { flex: 0 0 auto; text-align: right; }

.tier {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.pct { display: block; margin-top: 3px; font-size: 12px; color: var(--mute); }

.t-safe { color: var(--t-safe); }
.t-good { color: var(--t-good); }
.t-fair { color: var(--t-fair); }
.t-push { color: var(--t-push); }
.t-dream { color: var(--t-dream); }
.t-low { color: var(--t-low); }

.tier.t-safe { background: var(--t-safe); color: #fff; }
.tier.t-good { background: var(--t-good); color: #fff; }
.tier.t-fair { background: var(--t-fair); color: #fff; }
.tier.t-push { background: var(--t-push); color: #fff; }
.tier.t-dream { background: var(--t-dream); color: #fff; }
.tier.t-low { background: #e6e9ec; color: var(--sub); }
.tier.t-no { background: #fde8e8; color: #b42318; }
.tier.t-ok { background: #e7f6ec; color: var(--t-safe); }
.tier.t-none { background: #eef1f4; color: var(--sub); font-weight: 600; }

.detail {
  padding: 0 12px 12px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--sub);
}

.detail p { margin: 10px 0 0; }

.detail b { color: var(--ink); }

.hist {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13px;
}

.hist th, .hist td { padding: 5px 4px; border-bottom: 1px solid #eef1f4; text-align: right; }

.hist th:first-child, .hist td:first-child { text-align: left; }

.hist th { font-weight: 600; color: var(--mute); }

.hist td.std, .hist th:last-child { text-align: left; }

.hist td.std { padding-left: 10px; color: var(--ink); }

.detail small { color: var(--mute); }

.more { margin: 4px 2px; font-size: 13px; color: var(--mute); text-align: center; }

.empty { padding: 30px 0; text-align: center; color: var(--mute); }

.foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--mute);
}

.foot h3 { margin: 14px 0 4px; font-size: 13px; color: var(--sub); }

.foot p { margin: 4px 0; }

.vtables { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 6px; }

.foot table { border-collapse: collapse; }

.foot caption { padding-bottom: 2px; text-align: left; font-weight: 600; color: var(--sub); }

.foot td, .foot th { padding: 2px 10px 2px 0; text-align: left; font-weight: 400; }

@media (max-width: 359px) {
  .scores { grid-template-columns: repeat(3, 1fr); }
  .seg button { font-size: 14px; white-space: nowrap; }
  .seg button b { margin-left: 2px; padding: 1px 5px; }
  .tool-row { grid-template-columns: 1fr 1fr; }
  .tool-row #sort { grid-column: span 2; }
}

@media (min-width: 640px) {
  .wrap { padding-top: 32px; }
  h1 { font-size: 32px; }
  .card { padding: 18px; }
}
