* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  max-width: 540px;
  margin: 0 auto;
  padding: 1rem;
  color: #111;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #ccc;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1rem;
  font-weight: 600;
}

.search-box {
  position: relative;
}

.search-box input {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  font-size: 0.9rem;
  width: 180px;
}

.search-box input:focus {
  outline: 1px solid #111;
}

.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  max-height: 250px;
  overflow-y: auto;
  width: 240px;
  z-index: 100;
  display: none;
}

.search-results.visible {
  display: block;
}

.search-result-item {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.search-result-item:hover {
  background: #eee;
}

.search-result-item .char {
  font-size: 1.3rem;
}

.search-result-item .meaning {
  color: #555;
}

.nav-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.nav-bar button {
  padding: 0.3rem 0.7rem;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.nav-bar button:hover {
  background: #eee;
}

.nav-bar button:disabled {
  color: #aaa;
  cursor: default;
}

.nav-bar button:disabled:hover {
  background: #fff;
}

.breadcrumb {
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 0.75rem;
}

.breadcrumb-item {
  cursor: pointer;
  color: #111;
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #aaa;
  margin: 0 0.15rem;
}

.kanji-display {
  margin-bottom: 1rem;
}

.kanji-char {
  font-size: 5rem;
  line-height: 1.1;
  font-weight: 400;
}

.kanji-meaning {
  font-size: 1.1rem;
  margin-top: 0.1rem;
}

.kanji-readings {
  font-size: 0.9rem;
  color: #555;
  margin-top: 0.2rem;
}

.reading-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 0.1rem;
}

.composition {
  border-top: 1px solid #ccc;
  padding-top: 0.75rem;
  margin-bottom: 1rem;
}

.composition-type {
  font-size: 0.8rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.component-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.component-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 1rem;
}

.component-row .comp-char {
  font-size: 1.8rem;
  line-height: 1.2;
  cursor: pointer;
}

.component-row .comp-char:hover {
  text-decoration: underline;
}

.component-row .comp-char.not-found {
  cursor: default;
}

.component-row .comp-char.not-found:hover {
  text-decoration: none;
}

.component-row .comp-meaning {
  color: #555;
}

.component-row .comp-position {
  color: #999;
  font-size: 0.85rem;
}

.radical-note {
  color: #777;
  font-size: 0.9rem;
  font-style: italic;
}

.mnemonic {
  color: #777;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  border-top: 1px solid #eee;
  padding-top: 0.5rem;
}

.view-toggle {
  margin-bottom: 0.75rem;
}

.view-toggle button {
  padding: 0.25rem 0.6rem;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.view-toggle button:first-child {
  border-right: none;
}

.view-toggle button.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 2px;
}

.browse-item {
  text-align: center;
  padding: 0.3rem;
  cursor: pointer;
  font-size: 1.5rem;
  border: 1px solid #eee;
}

.browse-item:hover {
  background: #eee;
}

#browse-view {
  display: none;
}

.vocab-section:not(:empty) {
  border-top: 1px solid #ccc;
  padding-top: 0.75rem;
  margin-bottom: 1rem;
}

.vocab-heading {
  font-size: 0.8rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.vocab-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.95rem;
  padding: 0.15rem 0;
}

.vocab-word {
  font-size: 1.1rem;
  min-width: 3em;
}

.vocab-kanji {
  cursor: pointer;
}

.vocab-kanji:hover {
  text-decoration: underline;
}

.vocab-reading {
  color: #555;
  font-size: 0.85rem;
  min-width: 4em;
}

.vocab-meaning {
  color: #555;
  font-size: 0.85rem;
}

footer {
  margin-top: 1.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #ccc;
  font-size: 0.8rem;
  color: #999;
}

footer a {
  color: #999;
}

@media (max-width: 480px) {
  .kanji-char {
    font-size: 4rem;
  }

  .search-box input {
    width: 140px;
  }
}
