:root {
  --paper: #faf9f5;
  --ink: #141413;
  --accent: #d97757;
  --sans: "Hiragino Sans", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --jp: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  color-scheme: light;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(rgb(20 20 19 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(20 20 19 / 5%) 1px, transparent 1px),
    var(--paper);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
.study-content:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  border-inline: 1px solid rgb(20 20 19 / 22%);
  background: var(--paper);
  box-shadow: 7px 0 0 rgb(217 119 87 / 58%);
}

.topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  height: 70px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(20 20 19 / 22%);
  background: rgb(250 249 245 / 94%);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  background: var(--accent);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--jp);
  font-size: 23px;
  font-weight: 700;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 14px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 1px;
  opacity: .52;
  font-family: var(--jp);
  font-size: 10px;
  letter-spacing: .07em;
}

.voice-switch {
  display: flex;
  align-self: stretch;
  border-left: 1px solid rgb(20 20 19 / 22%);
}

.voice-button {
  width: 54px;
  border: 0;
  border-right: 1px solid rgb(20 20 19 / 14%);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.voice-button:last-child {
  border-right: 0;
}

.voice-button[aria-pressed="true"] {
  background: var(--accent);
}

.study-content {
  position: absolute;
  inset: 70px 0 74px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 18px 14px calc(32px + env(safe-area-inset-bottom));
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.study-content::-webkit-scrollbar,
.level-strip::-webkit-scrollbar,
.filter-strip::-webkit-scrollbar,
.scene-strip::-webkit-scrollbar {
  display: none;
}

.page-heading {
  display: flex;
  min-height: 36px;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.page-title h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -.045em;
  line-height: 1;
}

.page-title span {
  opacity: .48;
  font-family: var(--jp);
  font-size: 13px;
}

.count {
  opacity: .56;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.level-strip,
.filter-strip,
.scene-strip {
  display: flex;
  gap: 7px;
  margin-right: -14px;
  padding: 1px 14px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.level,
.filter,
.scene {
  min-width: 46px;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid rgb(20 20 19 / 34%);
  border-radius: 999px;
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.level[aria-pressed="true"],
.filter[aria-pressed="true"],
.scene[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.scene {
  min-width: auto;
}

.search {
  position: relative;
  display: block;
  margin-bottom: 13px;
}

.search::before {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  content: "";
  opacity: .5;
  transform: translateY(-62%);
}

.search::after {
  position: absolute;
  top: 58%;
  left: 25px;
  width: 7px;
  height: 2px;
  background: var(--ink);
  content: "";
  opacity: .5;
  transform: rotate(45deg);
  transform-origin: left center;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 13px 0 39px;
  border: 1px solid rgb(20 20 19 / 34%);
  border-radius: 0;
  background: var(--paper);
  appearance: none;
}

.loading,
.empty-state,
.load-error {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(20 20 19 / 30%);
  color: rgb(20 20 19 / 60%);
  text-align: center;
}

.load-error button {
  margin-top: 12px;
}

.kana-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 11px;
  border: 1px solid rgb(20 20 19 / 34%);
}

.kana-controls button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid rgb(20 20 19 / 22%);
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}

.kana-controls button:last-child {
  border-right: 0;
}

.kana-controls button[aria-pressed="true"] {
  background: var(--accent);
}

.kana-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-right: 4px;
  border-top: 1px solid rgb(20 20 19 / 38%);
  border-left: 1px solid rgb(20 20 19 / 38%);
  box-shadow: 5px 5px 0 var(--accent);
}

.kana-board.is-contracted {
  grid-template-columns: repeat(3, 1fr);
}

.kana,
.kana-empty {
  min-height: 68px;
  border: 0;
  border-right: 1px solid rgb(20 20 19 / 20%);
  border-bottom: 1px solid rgb(20 20 19 / 20%);
}

.kana {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--paper);
  cursor: pointer;
}

.kana[data-speaking="true"] {
  background: rgb(217 119 87 / 20%);
}

.kana-char {
  font-family: var(--jp);
  font-size: 26px;
  font-weight: 700;
}

.kana-romaji {
  position: absolute;
  right: 0;
  bottom: 4px;
  left: 0;
  opacity: .48;
  font-size: 9px;
  text-align: center;
}

.word-card,
.conversation-card,
.grammar-card {
  position: relative;
  margin: 0 4px 8px 0;
  border: 1px solid rgb(20 20 19 / 42%);
  background: var(--paper);
}

.word-card,
.conversation-card {
  box-shadow: 4px 4px 0 rgb(217 119 87 / 72%);
}

.word-card {
  display: grid;
  min-height: 84px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px 13px;
}

.word-main {
  min-width: 0;
  padding-right: 44px;
}

.word-jp {
  font-family: var(--jp);
  font-size: 23px;
  font-weight: 700;
}

.word-kana {
  margin-left: 7px;
  opacity: .58;
  font-family: var(--jp);
  font-size: 12px;
}

.word-meaning {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-mark {
  align-self: start;
  padding: 3px 7px;
  background: rgb(217 119 87 / 18%);
  font-size: 10px;
  font-weight: 750;
}

.conversation-card {
  padding: 13px 13px 12px;
}

.conversation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  opacity: .58;
  font-size: 10px;
  font-weight: 700;
}

.conversation-jp {
  margin: 0;
  padding-right: 45px;
  font-family: var(--jp);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.58;
}

.conversation-meaning {
  margin: 5px 44px 0 0;
  color: rgb(20 20 19 / 65%);
  font-size: 12px;
}

.grammar-card {
  min-height: 120px;
  padding: 7px 10px 6px;
  box-shadow: 4px 4px 0 rgb(217 119 87 / 76%);
}

.grammar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  opacity: .56;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1;
}

.grammar-pattern {
  margin: 0;
  padding-right: 42px;
  overflow: hidden;
  font-family: var(--jp);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grammar-meaning {
  margin: 2px 42px 4px 0;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grammar-form {
  margin: 0 -10px;
  padding: 4px 10px;
  overflow: hidden;
  border-block: 1px solid rgb(20 20 19 / 14%);
  background: rgb(217 119 87 / 11%);
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grammar-example {
  display: block;
  width: calc(100% + 2px);
  margin: 4px -1px -2px;
  padding: 0 38px 0 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.grammar-example-jp {
  display: block;
  overflow: hidden;
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grammar-example-meaning {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: rgb(20 20 19 / 62%);
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-index {
  position: absolute;
  right: 10px;
  top: 9px;
  font-size: 9px;
  font-weight: 750;
}

.speak {
  position: absolute;
  right: 10px;
  bottom: 6px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.speak::before {
  width: 6px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  content: "";
}

.speak::after {
  position: absolute;
  bottom: 7px;
  width: 11px;
  height: 6px;
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 9px 9px;
  content: "";
}

.speak[data-speaking="true"] {
  background: var(--ink);
}

.speak[data-speaking="true"]::before,
.speak[data-speaking="true"]::after {
  border-color: var(--paper);
}

.load-more {
  width: 100%;
  min-height: 42px;
  margin-top: 2px;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.bottom-nav {
  position: absolute;
  inset: auto 0 0;
  z-index: 20;
  display: grid;
  height: 74px;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid rgb(20 20 19 / 28%);
  background: rgb(250 249 245 / 96%);
  backdrop-filter: blur(14px);
}

.nav-button {
  display: grid;
  place-content: center;
  border: 0;
  border-right: 1px solid rgb(20 20 19 / 12%);
  background: transparent;
  cursor: pointer;
}

.nav-button:last-child {
  border-right: 0;
}

.nav-button[aria-selected="true"] {
  background: var(--accent);
}

.nav-jp,
.nav-cn {
  display: block;
  text-align: center;
}

.nav-jp {
  font-family: var(--jp);
  font-size: 15px;
  font-weight: 700;
}

.nav-cn {
  margin-top: 2px;
  opacity: .66;
  font-size: 10px;
}

.toast {
  position: fixed;
  right: max(16px, calc((100vw - 430px) / 2 + 16px));
  bottom: 88px;
  left: max(16px, calc((100vw - 430px) / 2 + 16px));
  z-index: 50;
  padding: 9px 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .18s ease;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 359px) {
  .brand-copy small {
    display: none;
  }

  .brand {
    padding-left: 10px;
  }

  .voice-button {
    width: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
