:root {
  --bg: #f7f5f0;
  --paper: #fff;
  --text: #1a1a1a;
  --muted: #5a5a5a;
  --ipa: #1a7a3c;
  --label: #7a2f9e;
  --tilde: #0b57a4;
  --wrong: #c62828;
  --line: #d8d2c8;
  --usage-border: #c62828;
  --usage-bg: #fff8f7;
  --bar: #ece8e1;
  --accent: #2f5d8c;
}
* { box-sizing: border-box; }
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  touch-action: manipulation;
  overscroll-behavior: none;
}
.cat-buddy {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 18;
  width: 11rem;
  height: 11rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  will-change: transform;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
@media (prefers-reduced-motion: reduce) {
  .cat-buddy {
    display: none !important;
  }
}
.topbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.9rem;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar select,
.topbar input,
.topbar button {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid #c5bfb4;
  border-radius: 4px;
  background: #fff;
}
.topbar .combo {
  flex: 1;
  min-width: 0;
  position: relative;
}
.topbar .combo input {
  width: 100%;
  padding-right: 2.1rem;
}
.topbar .combo .clear-btn {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.topbar .combo .clear-btn:hover,
.topbar .combo .clear-btn:active {
  color: var(--text);
  background: #e8e2d8;
}
.topbar .combo .clear-btn[hidden] {
  display: none !important;
}
.topbar .hist-btn {
  flex-shrink: 0;
  background: #fff;
  color: var(--accent);
  border-color: #c5bfb4;
  cursor: pointer;
  white-space: nowrap;
}
.topbar button.go {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}
.topbar .opt {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}
.topbar .opt input { accent-color: var(--accent); }
.setup {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.15rem 1.1rem 1.35rem;
  margin-top: 1rem;
}
.setup h2 {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}
.setup .lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.setup .dict-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.setup .dict-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  background: #faf8f4;
}
.setup .dict-list .tag {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.setup .dict-list .tag.need {
  color: #9a3b00;
  font-weight: 700;
}
.setup .dict-list .tag.ok {
  color: #1a7a3c;
  font-weight: 700;
}
.pass-label {
  display: block;
  margin: 0.75rem 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.pass-label input {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  font: inherit;
  font-size: 1.15rem;
  padding: 0.75rem 0.85rem;
  border: 2px solid #c5bfb4;
  border-radius: 8px;
}
.pass-label input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
.btn-primary {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 1rem 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 0 #1f4468;
}
.btn-primary:active {
  transform: translateY(1px);
  box-shadow: none;
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}
.btn-secondary {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  cursor: pointer;
}
.progress {
  height: 12px;
  background: #ddd;
  border-radius: 6px;
  overflow: hidden;
  margin: 0.85rem 0 0.5rem;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.15s linear;
}
#dlMsg {
  min-height: 1.4em;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.install-panel {
  background: linear-gradient(180deg, #e8f1fb 0%, #fff 70%);
  border: 2px solid #9db7d4;
  border-radius: 10px;
  padding: 1.1rem;
  margin-top: 1rem;
}
.install-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}
.install-panel .lead {
  margin: 0 0 0.9rem;
  color: var(--muted);
}
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}
.sheet[hidden] { display: none !important; }
.sheet-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px 14px 10px 10px;
  padding: 1.2rem 1.1rem 1.3rem;
}
.sheet-card h3 { margin: 0 0 0.75rem; }
.history-card {
  width: min(480px, 100%);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  padding-bottom: 0.75rem;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.history-head h3 { margin: 0; }
.history-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  margin: 0 -0.25rem;
  padding: 0 0.25rem 0.5rem;
}
.history-item {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}
.history-item .history-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf8f4;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.history-item .history-main:active { background: #f0ebe3; }
.history-item .word {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item .meta {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.history-item .history-del {
  flex-shrink: 0;
  width: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.history-item .history-del:active {
  background: #f0ebe3;
  color: var(--wrong);
}
.history-empty {
  color: var(--muted);
  padding: 1.5rem 0.5rem;
  text-align: center;
}
.sheet-steps {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
  line-height: 1.7;
}
@media (max-width: 640px) {
  .x-head { font-size: 1.3rem; }
  .line-ex { margin-left: 0.5rem; }
  .topbar { flex-wrap: wrap; }
  .btn-primary { font-size: 1.25rem; padding: 1.15rem 1rem; }
}

.dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  z-index: 6;
  list-style: none;
  padding: 0;
  margin: 0;
}
.dropdown.open { display: block; }
.dropdown li {
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.dropdown li:hover,
.dropdown li.active { background: #f0ebe3; }
.dropdown .sec {
  font-size: 0.75rem;
  color: var(--muted);
  background: #f5f2ec;
  cursor: default;
}
.dropdown .sec:hover { background: #f5f2ec; }
.dropdown .drop-meta {
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}
.dropdown li.pinned .drop-word {
  font-weight: 700;
}
.layout {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.75rem 1rem 2.5rem;
  overflow-x: hidden;
}
.article-wrap {
  position: relative;
  margin-top: 0.9rem;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
  will-change: transform, opacity;
}
.article-wrap[hidden] {
  display: none !important;
}
.article-wrap.view-exit-left {
  transform: translateX(-36%);
  opacity: 0;
}
.article-wrap.view-exit-right {
  transform: translateX(36%);
  opacity: 0;
}
.article-wrap.view-enter-left,
.article-wrap.view-enter-right {
  transition: none;
  opacity: 0;
}
.article-wrap.view-enter-left {
  transform: translateX(-36%);
}
.article-wrap.view-enter-right {
  transform: translateX(36%);
}
.article-wrap.view-enter-active {
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .article-wrap {
    transition: none !important;
  }
}
.pin-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 4;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.pin-btn.pinned {
  opacity: 1;
  border-color: var(--accent);
  background: #e8f1fb;
}
.pin-btn:active {
  transform: scale(0.96);
}
.article {
  margin-top: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 2.6rem 1.4rem 1.1rem;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
.history-item.pinned .history-main {
  border-color: #9db7d4;
  background: #f3f7fc;
}
.history-pin {
  flex-shrink: 0;
  width: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.45;
}
.history-pin.pinned {
  opacity: 1;
  border-color: #9db7d4;
  background: #e8f1fb;
}
.dict-card-body {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: none;
}
.article.multi {
  background: transparent;
  border: 0;
  padding: 0;
}
.article.multi .dict-card:first-child {
  padding-right: 2.6rem;
}
.dict-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.1rem 1.4rem;
  margin-bottom: 0.75rem;
}
.dict-card:last-child {
  margin-bottom: 0;
}
.dict-card-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.55rem;
}
a.dict-link {
  color: var(--tilde);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.pos-chip {
  display: inline;
  margin: 0 0.05rem;
  padding: 0.05rem 0.15rem;
  border: 0;
  border-bottom: 1px dashed var(--label);
  border-radius: 2px;
  background: transparent;
  color: var(--label);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  cursor: pointer;
  vertical-align: baseline;
}
.pos-chip:active {
  background: #f3e8fb;
}
.pos-help-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  margin: 0;
  padding: 0.25rem 0.15rem 0.75rem;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 0.98rem;
  color: var(--text);
}
.jump-tip {
  position: fixed;
  z-index: 30;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.points-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(120%);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.22, 1.4, 0.36, 1), opacity 0.35s ease;
}
.points-toast[hidden] {
  display: none !important;
}
.points-toast.show {
  display: block !important;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.points-toast-inner {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.7rem 1.1rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff8a3d 0%, #ff5cad 45%, #7b6cff 100%);
  color: #fff;
  font-weight: 800;
  box-shadow:
    0 10px 28px rgba(123, 108, 255, 0.35),
    0 0 0 3px rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}
.points-toast.pop .points-toast-inner {
  animation: points-pop 0.55s cubic-bezier(0.22, 1.6, 0.36, 1);
}
.points-star {
  font-size: 1.25rem;
  animation: points-spin 0.9s ease-out;
}
.points-delta {
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}
.points-total {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.95;
  padding-left: 0.35rem;
  border-left: 2px solid rgba(255, 255, 255, 0.45);
}
.points-bursts {
  position: absolute;
  left: 50%;
  top: 30%;
  width: 0;
  height: 0;
  z-index: -1;
}
.points-burst {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 1rem;
  animation: points-burst var(--bd, 0.7s) ease-out forwards;
  opacity: 0;
}
@keyframes points-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes points-spin {
  0% { transform: rotate(-20deg) scale(0.5); }
  60% { transform: rotate(12deg) scale(1.25); }
  100% { transform: rotate(0) scale(1); }
}
@keyframes points-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0) scale(0.4);
  }
  20% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(var(--bx), var(--by)) rotate(var(--br)) scale(1.1);
  }
}
.x-head { font-size: 1.55rem; font-weight: 700; }
.x-homograph {
  font-size: 0.85rem;
  vertical-align: super;
  margin-left: 0.15rem;
  color: var(--muted);
}
.x-ipa,
.x-ipa-sup { color: var(--ipa); }
.x-ipa-sup { font-size: 0.75em; vertical-align: super; }
.x-label { color: var(--label); }
.x-em { font-weight: 700; }
.x-tilde {
  color: var(--tilde);
  font-style: italic;
  font-weight: 600;
}
.x-wrong { color: var(--wrong); font-weight: 700; }
.btn-sound {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
  border: 0;
  background: #e8f1fb;
  color: #1e5a96;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.75rem;
  vertical-align: middle;
  cursor: pointer;
}
.line-main { margin: 0.35rem 0; }
.line-ex {
  margin: 0.15rem 0 0.15rem 1.25rem;
  padding-left: 0.5rem;
  border-left: 2px solid #e6e0d6;
  white-space: pre-wrap;
}
.box-usage,
.box-note {
  margin: 0.7rem 0 0.7rem 1.1rem;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--usage-border);
  background: var(--usage-bg);
  border-radius: 2px;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.box-note {
  border-color: #666;
  background: #fafafa;
}
.empty,
.error,
.banner { margin-top: 1rem; color: var(--muted); }
.banner.update {
  background: #e8f1fb;
  border: 1px solid #9db7d4;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  color: #123;
}
