* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  color: #222;
  background: #fafafa;
}
#app {
  display: flex;
  height: 100vh;
}
#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #1f2430;
  color: #ddd;
  overflow-y: auto;
  padding: 1rem 0;
}
#sidebar h1 {
  font-size: 1.1rem;
  margin: 0 1rem 0.75rem;
  color: #fff;
}
#loading {
  margin: 0 1rem;
  font-size: 0.85rem;
  color: #9aa;
}
#chunk-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#chunk-list li {
  font-size: 0.9rem;
}
#chunk-list li a {
  display: block;
  padding: 0.5rem 1rem;
  color: inherit;
  text-decoration: none;
}
#chunk-list li:hover {
  background: #2c3344;
}
#chunk-list li.active {
  background: #3b4a6b;
  color: #fff;
  font-weight: 600;
}
#content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}
.hint {
  color: #888;
}
.word-row {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #fff;
}
.word-row .word-summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
}
.word-row .word-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  align-self: center;
}
.word-row .rank {
  color: #999;
  font-size: 0.8rem;
  width: 2.5rem;
  flex-shrink: 0;
}
.word-row .headword {
  font-size: 1.1rem;
  font-weight: 600;
}
.word-row .reading {
  color: #666;
  font-size: 0.9rem;
}
.word-row .gloss {
  color: #444;
  margin-left: auto;
  font-size: 0.9rem;
  text-align: right;
}
.word-row .pos {
  color: #999;
  font-size: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  flex-shrink: 0;
}
.word-detail {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0 0.9rem 0.9rem;
  border-top: 1px solid #eee;
}
.word-detail .detail-body {
  flex: 1;
  min-width: 0;
}
.word-detail .detail-image {
  width: 240px;
  height: 240px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
}

@media (max-width: 700px) {
  .word-detail { flex-direction: column-reverse; }
  .word-detail .detail-image { width: 100%; height: auto; max-height: 240px; }
}
.mnemonic {
  font-style: italic;
  color: #555;
  margin: 0.5rem 0;
}
.example {
  margin: 0.5rem 0;
  padding: 0.4rem 0;
}
.example .jp { font-size: 1rem; }
.example .reading { color: #777; font-size: 0.85rem; }
.example .en { color: #555; font-size: 0.9rem; }
.example audio { display: block; margin-top: 0.3rem; width: 260px; }
.grammar-note {
  font-style: italic;
  color: #555;
  font-size: 0.85rem;
  margin-top: 0.4rem;
  border-left: 3px solid #3b4a6b;
  padding-left: 0.5rem;
}
.reading-warning {
  color: #8a6d00;
  background: #fff6d8;
  border: 1px solid #e6cf73;
  border-radius: 3px;
  font-size: 0.75rem;
  margin-top: 0.3rem;
  padding: 0.15rem 0.4rem;
  display: inline-block;
  cursor: help;
}
.breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.breakdown-token {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #f0f1f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  min-width: 3.5rem;
}
.breakdown-token .bt-surface { font-size: 1rem; font-weight: 600; }
.breakdown-token .bt-reading { color: #777; font-size: 0.75rem; }
.breakdown-token .bt-meaning { color: #444; font-size: 0.7rem; margin-top: 0.2rem; line-height: 1.3; }
.breakdown-token .bt-meaning em { color: #888; font-style: normal; }
.chunk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.chunk-actions {
  display: flex;
  gap: 0.5rem;
}
.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.report-bug, .copy-item-link {
  display: inline-block;
  font-size: 0.8rem;
  text-decoration: none;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
}
.report-bug {
  color: #b3261e;
  border: 1px solid #e0b3b0;
  background: none;
}
.report-bug:hover {
  background: #fdeceb;
}
.copy-item-link {
  color: #3b4a6b;
  border: 1px solid #b7c0d6;
  background: none;
}
.copy-item-link:hover {
  background: #eaeef6;
}
#feedback-link {
  display: block;
  margin: 0.75rem 1rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid #2c3344;
  color: #9aa;
  font-size: 0.8rem;
  text-decoration: none;
}
#feedback-link:hover {
  color: #fff;
}
button.quiz-btn, button.primary {
  background: #3b4a6b;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
}
button.quiz-btn:hover, button.primary:hover { background: #4a5d85; }

.quiz-question {
  font-size: 1.6rem;
  margin: 1.5rem 0 1.5rem;
}
.quiz-image {
  display: block;
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.quiz-reading {
  font-size: 1rem;
  color: #777;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 600px;
}
.quiz-options button {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.quiz-options button:hover { background: #f0f0f0; }
.quiz-options button.correct { background: #c6f0c6; border-color: #4caf50; }
.quiz-options button.incorrect { background: #f0c6c6; border-color: #e53935; }
.quiz-progress {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.quiz-summary {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

@media (max-width: 700px) {
  #app { flex-direction: column; height: auto; }
  #sidebar { width: 100%; max-height: 35vh; }
  #content { padding: 1rem; }
}
