body {
  font-family: "Noto Sans", sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f8f9fa;
  margin: 0;
  padding: 20px;
}

#grade_container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

#grade_input {
  width: 100%;
  height: 150px;
  font-size: 16px;
  padding: 12px;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  box-sizing: border-box;
  margin-bottom: 16px;
  resize: vertical;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
  font-family: "Noto Sans", sans-serif;
}
#grade_input:focus {
  outline: none;
  border-color: #3e6ea5;
  box-shadow: 0 0 0 3px rgba(62, 110, 165, 0.2);
}

#grade_button {
  background-color: #3e6ea5;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 20px;
  font-family: "Noto Sans", sans-serif;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
#grade_button:hover {
  background-color: #2c5080;
  transform: translateY(-2px);
}
#grade_button:active {
  transform: translateY(1px);
  background-color: #1d3b5f;
}
#grade_button::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.3s, opacity 0.5s;
}
#grade_button:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

#results_container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (min-width: 992px) {
  #results_container {
    flex-direction: row;
    align-items: flex-start;
  }
  #results_container #grade_output_container {
    flex: 1;
    order: 1;
  }
  #results_container #char_info_panel {
    width: 300px;
    position: sticky;
    top: 20px;
    order: 2;
  }
}
#results_container #grade_output_container {
  display: flex;
  flex-direction: column;
  order: 2;
}
#results_container #char_info_panel {
  order: 1;
}

#grade_legend {
  background-color: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
#grade_legend h4 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 16px;
  color: #6c757d;
}
#grade_legend .legend-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#grade_legend .legend-container .legend-item {
  flex: 1;
  min-width: 80px;
  padding: 8px 6px;
  border-radius: 0;
  text-align: center;
  font-weight: 600;
  display: flex;
  flex-direction: column;
}
#grade_legend .legend-container .legend-item .grade-number {
  font-size: 14px;
  margin-bottom: 2px;
}
#grade_legend .legend-container .legend-item .char-count {
  font-size: 13px;
  opacity: 0.8;
}
#grade_legend .legend-container .legend-ungraded {
  background-color: #f0f2f5;
  color: #555;
  border: 1px dashed #ccc;
}

#char_heatmap {
  background-color: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
}
#char_heatmap h4 {
  margin: 0 0 10px 0;
  font-size: 16px;
  color: #6c757d;
  border-bottom: 1px solid #e1e4e8;
  padding-bottom: 8px;
}
#char_heatmap #grade_output {
  padding: 0;
  width: 100%;
  overflow-x: scroll;
  overflow-y: auto;
  line-height: 1.8;
  font-family: "Noto Serif TC", serif;
  border: none;
  box-shadow: none;
  border-radius: 0;
  background: none;
}

#grade_output {
  background-color: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 200px;
  overflow-x: auto;
  overflow-y: auto;
  white-space: nowrap;
  line-height: 1.8;
  font-family: "Noto Serif TC", serif;
}

#char_list {
  background-color: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
}
#char_list h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #6c757d;
  border-bottom: 1px solid #e1e4e8;
  background: none;
  padding-bottom: 8px;
}
#char_list .char-list-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
#char_list .char-list-table thead tr.char-list-header {
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 700;
  color: #6c757d;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
#char_list .char-list-table thead tr.char-list-header th {
  padding: 4px 0;
  border-bottom: 1px solid #e1e4e8;
  background: none;
}
#char_list .char-list-table thead tr.char-list-header .char-rank {
  padding: 0 8px;
  width: 60px;
  text-align: left;
}
#char_list .char-list-table thead tr.char-list-header .char-display {
  width: 30px;
  text-align: center;
}
#char_list .char-list-table thead tr.char-list-header .char-frequency {
  min-width: 40px;
  text-align: right;
  padding: 0 8px;
}
#char_list .char-list-table thead tr.char-list-header .char-grade {
  width: 56px;
  text-align: center;
}
#char_list .char-list-table tbody tr.char-item {
  transition: background-color 0.2s ease;
}
#char_list .char-list-table tbody tr.char-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
#char_list .char-list-table tbody tr.char-item td {
  background: none;
  border: none;
  vertical-align: middle;
}
#char_list .char-list-table tbody tr.char-item .char-rank {
  padding: 0 8px;
  width: 60px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
#char_list .char-list-table tbody tr.char-item .char-display {
  width: 30px;
  height: 30px;
  font-family: "Noto Serif TC", serif;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
#char_list .char-list-table tbody tr.char-item .char-frequency {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  padding: 0 8px;
  min-width: 40px;
}
#char_list .char-list-table tbody tr.char-item:last-child {
  border-bottom: none;
}
#char_list .char-list-table tbody tr.char-item.ungraded {
  background-color: #f0f2f5;
  border-left: 2px dashed #ccc;
  border-bottom: 1px solid #e1e4e8;
}
#char_list .char-list-table tbody tr.char-item.ungraded:hover {
  background-color: #e6e8eb;
}
#char_list .char-list-table tbody tr.char-item.ungraded td {
  color: #555;
  font-weight: 600;
  background: none;
}
#char_list .char-list-table tbody tr.char-item.ungraded .char-rank,
#char_list .char-list-table tbody tr.char-item.ungraded .char-grade {
  color: #888;
  font-style: italic;
}
#char_list .char-list-table tbody tr.char-item.ungraded .char-display {
  font-family: "Noto Serif TC", serif;
  font-size: 18px;
  color: #555;
}
#char_list .char-list-table tbody tr.char-item.ungraded .char-frequency {
  color: #555;
}

#char_list .char-list-table thead th.char-rank,
#char_list .char-list-table thead th.char-frequency {
  text-decoration: underline;
  cursor: pointer;
}

#char_info_panel {
  background-color: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 200px;
}
#char_info_panel h3 {
  font-size: 42px;
  margin: 0 0 20px 0;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #333;
  font-family: "Noto Serif TC", serif;
  box-shadow: none;
}
#char_info_panel p {
  margin: 8px 0;
  color: #6c757d;
  font-weight: 500;
}

.character-span {
  display: inline-block;
  padding: 2px 4px;
  margin: 2px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-family: "Noto Serif TC", serif;
}
.character-span:hover {
  transform: scale(1.1);
  z-index: 2;
}

.character-whitespace {
  background-color: #f0f0f0;
  border: 1px dashed #ccc;
  color: #999;
  font-size: 14px;
}

.character-newline {
  display: block;
  height: 0.8em;
}

.grade-badge {
  display: inline-block;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  color: #fff !important;
  font-weight: bold;
  margin-left: 8px;
  box-shadow: none;
}

.grade-1 {
  background-color: #BDB2FF;
  color: #5a4fa0;
}

.grade-badge.grade-1 {
  background-color: #5a4fa0;
}

h3.grade-1 {
  background-color: #BDB2FF;
  color: #5a4fa0;
}

.char-item.grade-1 {
  border-bottom: 1px solid rgba(90, 79, 160, 0.15);
  border-left: 2px solid rgba(90, 79, 160, 0.5);
}
.char-item.grade-1 .char-display {
  background-color: #BDB2FF;
  color: #5a4fa0;
}
.char-item.grade-1 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #5a4fa0 !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-1 .char-frequency {
  color: #5a4fa0;
}

.rank-color-1 {
  color: #5a4fa0;
}

.grade-2 {
  background-color: #A0C4FF;
  color: #3a5982;
}

.grade-badge.grade-2 {
  background-color: #3a5982;
}

h3.grade-2 {
  background-color: #A0C4FF;
  color: #3a5982;
}

.char-item.grade-2 {
  border-bottom: 1px solid rgba(58, 89, 130, 0.15);
  border-left: 2px solid rgba(58, 89, 130, 0.5);
}
.char-item.grade-2 .char-display {
  background-color: #A0C4FF;
  color: #3a5982;
}
.char-item.grade-2 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #3a5982 !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-2 .char-frequency {
  color: #3a5982;
}

.rank-color-2 {
  color: #3a5982;
}

.grade-3 {
  background-color: #9BF6FF;
  color: #0a7a8c;
}

.grade-badge.grade-3 {
  background-color: #0a7a8c;
}

h3.grade-3 {
  background-color: #9BF6FF;
  color: #0a7a8c;
}

.char-item.grade-3 {
  border-bottom: 1px solid rgba(10, 122, 140, 0.15);
  border-left: 2px solid rgba(10, 122, 140, 0.5);
}
.char-item.grade-3 .char-display {
  background-color: #9BF6FF;
  color: #0a7a8c;
}
.char-item.grade-3 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #0a7a8c !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-3 .char-frequency {
  color: #0a7a8c;
}

.rank-color-3 {
  color: #0a7a8c;
}

.grade-4 {
  background-color: #CAFFBF;
  color: #2a7d4b;
}

.grade-badge.grade-4 {
  background-color: #2a7d4b;
}

h3.grade-4 {
  background-color: #CAFFBF;
  color: #2a7d4b;
}

.char-item.grade-4 {
  border-bottom: 1px solid rgba(42, 125, 75, 0.15);
  border-left: 2px solid rgba(42, 125, 75, 0.5);
}
.char-item.grade-4 .char-display {
  background-color: #CAFFBF;
  color: #2a7d4b;
}
.char-item.grade-4 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #2a7d4b !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-4 .char-frequency {
  color: #2a7d4b;
}

.rank-color-4 {
  color: #2a7d4b;
}

.grade-5 {
  background-color: #FDFFB6;
  color: #8a6d00;
}

.grade-badge.grade-5 {
  background-color: #8a6d00;
}

h3.grade-5 {
  background-color: #FDFFB6;
  color: #8a6d00;
}

.char-item.grade-5 {
  border-bottom: 1px solid rgba(138, 109, 0, 0.15);
  border-left: 2px solid rgba(138, 109, 0, 0.5);
}
.char-item.grade-5 .char-display {
  background-color: #FDFFB6;
  color: #8a6d00;
}
.char-item.grade-5 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #8a6d00 !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-5 .char-frequency {
  color: #8a6d00;
}

.rank-color-5 {
  color: #8a6d00;
}

.grade-6 {
  background-color: #FFD6A5;
  color: #9c5615;
}

.grade-badge.grade-6 {
  background-color: #9c5615;
}

h3.grade-6 {
  background-color: #FFD6A5;
  color: #9c5615;
}

.char-item.grade-6 {
  border-bottom: 1px solid rgba(156, 86, 21, 0.15);
  border-left: 2px solid rgba(156, 86, 21, 0.5);
}
.char-item.grade-6 .char-display {
  background-color: #FFD6A5;
  color: #9c5615;
}
.char-item.grade-6 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #9c5615 !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-6 .char-frequency {
  color: #9c5615;
}

.rank-color-6 {
  color: #9c5615;
}

.grade-7 {
  background-color: #FFADAD;
  color: #9c2b2b;
}

.grade-badge.grade-7 {
  background-color: #9c2b2b;
}

h3.grade-7 {
  background-color: #FFADAD;
  color: #9c2b2b;
}

.char-item.grade-7 {
  border-bottom: 1px solid rgba(156, 43, 43, 0.15);
  border-left: 2px solid rgba(156, 43, 43, 0.5);
}
.char-item.grade-7 .char-display {
  background-color: #FFADAD;
  color: #9c2b2b;
}
.char-item.grade-7 .char-grade {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #9c2b2b !important;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  border: none;
  padding: 0;
}
.char-item.grade-7 .char-frequency {
  color: #9c2b2b;
}

.rank-color-7 {
  color: #9c2b2b;
}

.character-ungraded {
  background-color: #f8f9fa;
  border: 1px solid #e0e0e0;
  color: #666;
}

h3.ungraded {
  background-color: #f0f2f5;
  color: #555;
  border: 1px dashed #ccc;
}

.info-grid {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.info-grid .info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e1e4e8;
}
.info-grid .info-item:last-child {
  border-bottom: none;
}
.info-grid .info-item .info-label {
  font-weight: 500;
  color: #555;
  font-size: 14px;
}
.info-grid .info-item .info-value {
  font-weight: 600;
  color: #222;
}

.info-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.info-placeholder img {
  max-width: 100%;
}

.info-content {
  text-align: center;
  margin-top: 15px;
  line-height: 1.6;
  color: #444;
}

.ungraded {
  color: #666;
}
