@charset "UTF-8";
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #fbfaf6;
  color: #111827;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  display: grid;
  gap: 1.5rem;
}

header {
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1rem;
}
header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  letter-spacing: 0.02em;
}
header .subtitle {
  margin: 0;
  color: #374151;
  font-size: 0.95rem;
}
header .subtitle .ranks-inline b {
  font-weight: 700;
}

.input-section {
  display: grid;
}
.input-section .kana-input {
  width: 100%;
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1.6rem;
  color: #111827;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.input-section .kana-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.input-section .kana-input::placeholder {
  color: #9ca3af;
}

.result-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1rem;
  min-height: 5.5rem;
}
.result-section .hint {
  color: #6b7280;
  margin: 0;
  font-style: italic;
}
.result-section .nhk-resolved {
  margin: 0 0 0.75rem;
  padding: 0.4rem 0.6rem;
  background: #fff7e6;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  color: #78350f;
  font-size: 0.85rem;
}
.result-section .nhk-resolved b {
  color: #111827;
  font-weight: 600;
}
.result-section .nhk-tag {
  display: inline-block;
  background: #b45309;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  vertical-align: 0.05em;
}
.result-section .moras {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  align-items: flex-start;
}

.mora {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.55rem 0.55rem 0.4rem;
  min-width: 2.6rem;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  border-bottom-width: 4px;
  cursor: default;
  transition: transform 120ms;
}
.mora:hover {
  transform: translateY(-1px);
}
.mora .mora-text {
  font-size: 1.6rem;
  line-height: 1;
  color: #111827;
}
.mora .mora-badge {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #6b7280;
  /* Reserve a fixed line so non-candidate moras (empty badge) keep the
     same pill height as ranked ones. */
  height: 0.72rem;
}
.mora.rank-A {
  border-bottom-color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}
.mora.rank-A .mora-badge {
  color: #dc2626;
}
.mora.rank-B {
  border-bottom-color: #ea580c;
  background: rgba(234, 88, 12, 0.06);
}
.mora.rank-B .mora-badge {
  color: #ea580c;
}
.mora.rank-C {
  border-bottom-color: #ca8a04;
  background: rgba(202, 138, 4, 0.06);
}
.mora.rank-C .mora-badge {
  color: #ca8a04;
}
.mora.rank-D {
  border-bottom-color: #16a34a;
  background: rgba(22, 163, 74, 0.06);
}
.mora.rank-D .mora-badge {
  color: #16a34a;
}
.mora.rank-E {
  border-bottom-color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
}
.mora.rank-E .mora-badge {
  color: #2563eb;
}
.mora.rank-none-candidate {
  border-bottom-style: dashed;
  border-bottom-color: #6b7280;
}
.mora.rank-none-candidate .mora-badge {
  color: #6b7280;
}
.mora.rank-none {
  border-bottom-color: #e5e7eb;
}
.mora.nhk-silenced {
  box-shadow: 0 0 0 2px #b45309;
  background: #fff7e6;
}
.mora.nhk-silenced .mora-text {
  color: #78350f;
  font-style: italic;
}
.mora .nhk-mark {
  position: absolute;
  top: -0.55rem;
  right: -0.4rem;
  background: #b45309;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.legend {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem 1.25rem 1.1rem;
}
.legend h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.legend li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  align-items: start;
}
.legend li .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-weight: 700;
  color: #ffffff;
}
.legend li.rank-A .badge {
  background: #dc2626;
}
.legend li.rank-B .badge {
  background: #ea580c;
}
.legend li.rank-C .badge {
  background: #ca8a04;
}
.legend li.rank-D .badge {
  background: #16a34a;
}
.legend li.rank-E .badge {
  background: #2563eb;
}
.legend li .meaning {
  display: grid;
  gap: 0.1rem;
}
.legend li .meaning .ja {
  font-size: 0.95rem;
  color: #111827;
}
.legend li .meaning .en {
  font-size: 0.85rem;
  color: #374151;
}
.legend li .meaning .rule {
  font-size: 0.78rem;
  color: #6b7280;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.examples {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem 1.25rem 1.1rem;
}
.examples h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.examples .hint {
  margin: 0 0 0.8rem;
  color: #6b7280;
  font-size: 0.85rem;
}
.examples details {
  border-top: 1px solid #e5e7eb;
  padding: 0.6rem 0 0.4rem;
}
.examples details:first-of-type {
  border-top: none;
  padding-top: 0;
}
.examples details summary {
  cursor: pointer;
  font-weight: 600;
  color: #374151;
  padding: 0.25rem 0;
  list-style: none;
}
.examples details summary::-webkit-details-marker {
  display: none;
}
.examples details summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1rem;
  color: #6b7280;
  transition: transform 120ms;
}
.examples details[open] > summary::before {
  transform: rotate(90deg);
}
.examples details ul {
  list-style: none;
  padding: 0.4rem 0 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.examples .example-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  background: #fbfaf6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  color: #111827;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 120ms;
}
.examples .example-btn:hover {
  background: #ffffff;
  border-color: #c7c2b6;
  transform: translateY(-1px);
}
.examples .example-btn .ex-kana {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.examples .example-btn .ex-gloss {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.05rem;
}

footer {
  color: #6b7280;
  font-size: 0.8rem;
  text-align: center;
  padding-top: 0.5rem;
}
footer p {
  margin: 0;
}
