html, body {
  margin: 0;
  padding: 0;
}

body {
  background: #f7f8fa;
  color: #222;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

/* 숫자 입력 스피너 제거 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* 헤더 */
.top {
  margin-bottom: 14px;
}

.top h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
}

.sub {
  margin-top: 8px;
  color: #666;
  font-size: 14px;
}

.back-link {
  display: inline-block;
  margin-bottom: 10px;
  color: #333;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* 패널 */
.panel {
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  background: #fff;
  margin-bottom: 16px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 20px;
}

/* 폼 */
.search-layout {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  gap: 12px;
}

.row-top {
  grid-template-columns: minmax(180px, 0.9fr) minmax(0, 2.1fr);
}

.row-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

label span,
.filter-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 14px;
}

input,
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  color: #222;
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(17, 17, 17, 0.15);
  outline-offset: 1px;
}

button {
  font: inherit;
  box-sizing: border-box;
  border: 1px solid #111;
  border-radius: 10px;
  background: #111;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button.secondary {
  border-color: #d9d9d9;
  background: #f8f9fa;
  color: #222;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* 판정 필터 */
.judge-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
  align-items: center;
}

.judge-tab {
  appearance: none;
  flex: 0 0 auto;
  width: auto;
  min-width: 66px;
  padding: 8px 12px;
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.judge-tab:hover {
  background: #f8f9fa;
}

.judge-tab.is-active {
  border-color: #111;
  background: #111;
  color: #fff;
}

/* 결과 헤더 */
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meta-text {
  color: #666;
  font-size: 14px;
}

.result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.stat-chip {
  appearance: none;
  width: auto;
  min-width: 84px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f1f3f5;
  color: #222;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.stat-chip.stat-safe {
  background: #e8f7ee;
  color: #1d5a2f;
}

.stat-chip.stat-fit {
  background: #eef4ff;
  color: #294d93;
}

.stat-chip.stat-up {
  background: #fff5e8;
  color: #8a5a13;
}

.stat-chip.is-active {
  border-color: #111;
  box-shadow: inset 0 0 0 1px #111;
}

/* 결과 리스트 */
.result-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.empty {
  padding: 18px;
  border: 1px dashed #ccc;
  border-radius: 12px;
  background: #fafafa;
  color: #666;
  font-size: 14px;
}

/* 공통 배지 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f3f5;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.badge.is-safe {
  background: #e8f7ee;
  color: #1d5a2f;
}

.badge.is-fit {
  background: #eef4ff;
  color: #294d93;
}

.badge.is-up {
  background: #fff5e8;
  color: #8a5a13;
}

.badge.is-challenge {
  background: #fdeeee;
  color: #922f2f;
}

.badge.is-risk {
  background: #fff1f1;
  color: #9c2f2f;
}

/* 카드 */
.compact-card {
  padding: 14px 16px;
  border: 1px solid #e5e5e5;
  border-radius: 14px;
  background: #fff;
}

.compact-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.compact-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.compact-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.compact-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  word-break: keep-all;
}

.compact-meta {
  margin-top: 4px;
  color: #666;
  font-size: 13px;
  word-break: keep-all;
}

.compact-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #f0f0f0;
}

.summary-line {
  color: #333;
  font-size: 13px;
  min-width: 0;
}

.summary-side {
  color: #666;
  white-space: nowrap;
  font-size: 13px;
  text-align: right;
  min-width: 0;
}

.meta-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.year-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #333;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
}

.detail-toggle {
  appearance: none;
  flex: 0 0 auto;
  width: auto;
  min-width: 88px;
  padding: 8px 12px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  background: #fff;
  color: #222;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.detail-toggle:hover {
  background: #f8f9fa;
}

.detail-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e5e5e5;
}

.detail-grid {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: grid;
  grid-template-columns: 70px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #ececec;
  border-radius: 10px;
  background: #fafafa;
}

.detail-subject {
  font-weight: 800;
  font-size: 14px;
}

.detail-val {
  color: #444;
  font-size: 13px;
}

.detail-note {
  margin-top: 10px;
  color: #666;
  font-size: 13px;
  line-height: 1.55;
  word-break: keep-all;
}

/* 과목 상태칩 */
.subchip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f1f3f5;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #222;
}

.subchip.is-pass {
  background: #e8f7ee;
  color: #1d5a2f;
}

.subchip.is-fail {
  background: #fdeeee;
  color: #922f2f;
}

/* 더 보기 */
.load-more-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
  padding-top: 2px;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  width: auto;
  min-width: 160px;
  padding: 12px 18px;
  border: 1px solid #d9d9d9;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.load-more-btn:hover {
  background: #f8f9fa;
}

.load-more-btn:active {
  transform: translateY(1px);
}

.load-more-btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

/* 3개년 관련 */
.year-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.year-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: #f1f3f5;
  color: #222;
}

.year-chip.is-safe {
  background: #e8f7ee;
  color: #1d5a2f;
}

.year-chip.is-fit {
  background: #eef4ff;
  color: #294d93;
}

.year-chip.is-up {
  background: #fff5e8;
  color: #8a5a13;
}

.year-chip.is-challenge {
  background: #fdeeee;
  color: #922f2f;
}

.year-chip.is-risk {
  background: #fff1f1;
  color: #9c2f2f;
}

.year-block-list {
  display: grid;
  gap: 10px;
}

.year-block {
  border: 1px solid #ececec;
  border-radius: 12px;
  background: #fafafa;
  overflow: hidden;
}

.year-toggle {
  appearance: none;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #222;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.year-toggle-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.year-toggle-summary {
  display: block;
  margin-top: 8px;
  color: #555;
  font-size: 13px;
  line-height: 1.4;
  word-break: keep-all;
}

.year-title {
  font-size: 15px;
  font-weight: 800;
}

.year-body {
  padding: 0 12px 12px;
}

/* 수시교과 전용 */
.school-card .compact-summary {
  align-items: flex-start;
}

.school-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.school-info-card {
  padding: 10px 12px;
  border: 1px solid #ececec;
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}

.school-info-label {
  color: #777;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.school-info-value {
  color: #222;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  word-break: keep-all;
}

/* 반응형 */
@media (max-width: 900px) {
  .row-top,
  .row-two {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .school-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .page {
    padding: 14px;
  }

  .top {
    margin-bottom: 14px;
  }

  .top h1 {
    font-size: 26px;
  }

  .sub {
    font-size: 13px;
  }

  .panel {
    padding: 14px;
  }

  .panel h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .search-layout {
    gap: 10px;
  }

  .row,
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .btn-row,
  .result-head,
  .compact-top,
  .compact-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-row > button {
    width: 100%;
  }

  .compact-card {
    padding: 12px 14px;
  }

  .compact-title {
    font-size: 16px;
  }

  .compact-meta,
  .summary-line,
  .summary-side,
  .year-toggle-summary,
  .detail-val,
  .detail-note,
  .school-info-value {
    font-size: 12px;
  }

  .compact-summary {
    gap: 6px;
  }

  .summary-side {
    white-space: normal;
    text-align: left;
  }

  .meta-chip {
    font-size: 11px;
    padding: 5px 8px;
    white-space: normal;
  }

  .detail-row {
    grid-template-columns: 56px 1fr auto;
    gap: 6px;
    padding: 9px 10px;
  }

  .detail-row .detail-val:nth-child(3) {
    grid-column: 2 / 3;
  }

  .subchip {
    justify-self: end;
  }

  .year-toggle-top {
    align-items: flex-start;
  }

  .year-chip {
    font-size: 11px;
    padding: 5px 8px;
  }

  .judge-tab {
    min-width: 66px;
    padding: 8px 11px;
    font-size: 12px;
  }

  .stat-chip {
    min-width: 70px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .result-head h2 {
    margin-bottom: 0;
  }

  .school-info-grid {
    grid-template-columns: 1fr;
  }

  .year-title {
    font-size: 14px;
  }

  .load-more-wrap {
    margin-top: 12px;
  }

  .load-more-btn {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 12px;
  }
}

.install-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  margin-bottom: 14px;
}

.install-btn {
  width: auto;
  min-width: 130px;
  padding: 10px 14px;
}

.install-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}

.install-guide-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.install-guide-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.install-guide-text {
  color: #444;
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 14px;
  white-space: pre-line;
}

@media (max-width: 768px) {
  .install-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .install-btn {
    width: 100%;
  }
}
