:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66737d;
  --line: #d9e0e5;
  --accent: #0c7c73;
  --accent-dark: #075f58;
  --soft: #eef7f5;
  --danger: #b42318;
  --letter-bg: #f4f8fb;
  --letter-line: #b9d1df;
  --letter-title: #174a66;
  --shadow: 0 18px 45px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(12, 124, 115, 0.08), rgba(47, 88, 135, 0.08)),
    var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.lookup-panel {
  width: min(100%, 760px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.brand {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.intro {
  margin: 12px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.lookup-form {
  display: grid;
  gap: 16px;
}

.lookup-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-size: 17px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(12, 124, 115, 0.16);
}

button {
  height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.status.error {
  color: var(--danger);
}

.result {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  scroll-margin-top: 18px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.result-eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result h2 {
  margin: 0 0 14px;
  font-size: 24px;
}

.student-number {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  padding: 7px 11px;
  font-size: 14px;
  font-weight: 800;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.subject-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fff;
}

.subject-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.subject-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.subject-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.subject-card dt {
  color: var(--muted);
  font-weight: 700;
}

.subject-card dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.subject-card dl .converted-grade-reference dt,
.subject-card dl .converted-grade-reference dd {
  color: #adb5ba;
  font-style: italic;
  font-weight: 500;
}

.subject-card dl .converted-grade-reference dd {
  font-size: 0.92em;
  font-weight: 600;
}

.family-letter {
  position: relative;
  margin-top: 28px;
  padding: 27px 28px 24px;
  overflow: hidden;
  border: 1px solid var(--letter-line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: var(--letter-bg);
  color: #263943;
  box-shadow: 0 9px 24px rgba(23, 74, 102, 0.08);
}

.family-letter p {
  margin: 13px 0 0;
  font-size: 15px;
  line-height: 1.58;
  word-break: keep-all;
}

.family-letter > p:first-child {
  margin-top: 0;
}

.family-letter blockquote {
  margin: 23px 0 20px;
  padding: 17px 18px;
  border: 1px solid rgba(12, 124, 115, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-dark);
  font-size: 17px;
  font-style: italic;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.opening-date {
  color: #d01919;
  font-weight: 900;
}

.family-letter .letter-signature {
  margin-top: 23px;
  color: var(--letter-title);
  font-weight: 800;
  text-align: right;
}

@media (max-width: 520px) {
  .lookup-panel {
    padding: 24px;
  }

  h1 {
    font-size: 24px;
  }

  button {
    width: 100%;
  }

  .result-header {
    display: block;
  }

  .student-number {
    display: inline-block;
    margin-top: 2px;
  }

  .subject-grid {
    grid-template-columns: 1fr;
  }

  .family-letter {
    padding: 23px 20px 21px;
  }

  .family-letter p {
    font-size: 14px;
    line-height: 1.55;
  }
}
