:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #62717f;
  --line: #dbe3ea;
  --card-line: #b8c7d0;
  --surface: #ffffff;
  --soft: #edf6f3;
  --accent: #0d766e;
  --accent-dark: #095a54;
  --sun: #f1b940;
  --shadow: 0 18px 44px rgba(24, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f6f8f7;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body.modal-open {
  position: fixed;
  right: 0;
  left: 0;
  overflow: hidden;
  touch-action: none;
}

body.is-locked {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(135deg, rgba(13, 118, 110, 0.92), rgba(24, 32, 42, 0.94)),
    #18202a;
}

.lock-panel {
  display: grid;
  width: min(390px, 100%);
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: clamp(22px, 6vw, 34px);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.lock-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
}

.lock-copy {
  display: grid;
  gap: 7px;
}

.lock-copy h2 {
  margin: 0;
  font-size: 30px;
}

.lock-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.lock-kicker {
  color: var(--accent-dark) !important;
  font-size: 12px !important;
  font-weight: 900;
  text-transform: uppercase;
}

.lock-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 4px 0;
}

.lock-dot {
  width: 13px;
  height: 13px;
  border: 2px solid #9eacb7;
  border-radius: 50%;
  background: transparent;
}

.lock-dot.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}

.lock-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.lock-key {
  min-height: 56px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 21px;
}

.lock-key:hover,
.lock-key:focus-visible {
  border-color: var(--accent);
  background: var(--soft);
  outline: none;
}

.lock-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.lock-status.is-error {
  color: #b42318;
  font-weight: 800;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(219, 227, 234, 0.9);
  background: rgba(246, 248, 247, 0.94);
  backdrop-filter: blur(14px);
}

.topbar-title {
  display: grid;
  min-width: 190px;
  gap: 2px;
}

.topbar-title h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: clamp(19px, 2vw, 25px);
  line-height: 1.18;
}

.module-emoji {
  flex: 0 0 auto;
  font-size: 1.05em;
  line-height: 1;
}

.topbar-path {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.topbar-path a {
  color: var(--accent-dark);
}

.topbar-path a::after {
  content: "/";
  margin-left: 6px;
  color: #9aa9b4;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.nav a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--soft);
  color: var(--accent-dark);
}

.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px) max(20px, env(safe-area-inset-right)) clamp(40px, 7vw, 88px) max(20px, env(safe-area-inset-left));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(24px, 4vw, 36px);
}

p {
  color: #435260;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.7;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.entry-card {
  position: relative;
  display: flex;
  overflow: hidden;
  min-height: 260px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 34px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.entry-card:hover,
.entry-card:focus-visible {
  border-color: rgba(13, 118, 110, 0.42);
  outline: none;
  transform: translateY(-2px);
}

.entry-card:active {
  transform: scale(0.99);
}

.entry-card-main {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

.entry-card-watermark {
  position: absolute;
  right: -54px;
  bottom: -80px;
  z-index: 0;
  font-size: 430px;
  line-height: 1;
  opacity: 0.12;
  pointer-events: none;
  transform: rotate(-8deg);
  transform-origin: center;
}

.entry-kicker {
  width: fit-content;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.entry-card-arrow {
  position: relative;
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  align-self: flex-end;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 800;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.entry-card:hover .entry-card-arrow,
.entry-card:focus-visible .entry-card-arrow {
  background: var(--accent);
  color: #fff;
  transform: translateX(3px);
}

.placeholder-panel,
.settings-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 34px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-form .form-actions,
.settings-form .form-status {
  grid-column: 1 / -1;
}

.settings-module-main {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.emoji-field {
  min-width: 0;
}

.emoji-select {
  height: 43px;
  padding-inline: 8px 6px;
  text-align: center;
  font-size: 20px;
}

.settings-module-main input,
.settings-module-main select {
  height: 43px;
  line-height: 1.2;
}

fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

legend {
  padding: 0 8px;
  color: var(--accent-dark);
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c9d5dd;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(13, 118, 110, 0.15);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

button,
.text-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 18px;
  font: inherit;
  font-weight: 800;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
}

.text-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.form-status,
.load-error,
.settings-hint {
  margin: 0;
  color: var(--muted);
}

.settings-hint {
  font-size: 14px;
  line-height: 1.5;
}

.tool-workspace {
  display: grid;
  gap: 14px;
}

.term-workspace {
  display: grid;
  gap: 16px;
}

.tool-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.tool-toolbar-actions {
  display: flex;
  gap: 10px;
}

.quiz-launch {
  border: 1px solid #d3a326;
  background: #f1b940;
  color: #3f2d02;
}

.quiz-launch:hover {
  background: #e5ad2f;
}

.tooth-position-workspace {
  display: grid;
  gap: 14px;
}

.tooth-tabs {
  display: inline-flex;
  width: fit-content;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tooth-tab {
  min-width: 112px;
  border-radius: 0;
  background: #fff;
  color: var(--accent-dark);
}

.tooth-tab + .tooth-tab {
  border-left: 1px solid var(--line);
}

.tooth-tab.is-active,
.tooth-tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

.tooth-label-toggle {
  display: inline-flex;
  width: fit-content;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.tooth-label-button {
  min-width: 48px;
  height: 30px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  padding: 0 10px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1;
}

.tooth-label-button + .tooth-label-button {
  border-left: 1px solid var(--line);
}

.tooth-label-button.is-active,
.tooth-label-button[aria-pressed="true"] {
  background: #f1b940;
  color: #3f2d02;
}

.tooth-study-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.tooth-chart-panel {
  position: relative;
  z-index: 0;
  isolation: isolate;
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(14px, 2vw, 20px);
  background: #fff;
  box-shadow: var(--shadow);
}

.tooth-chart-panel[hidden] {
  display: none;
}

.tooth-chart-head {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 8px;
}

.tooth-chart-title-line {
  display: grid;
  grid-template-columns: max-content minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.tooth-chart-title-line .tooth-label-toggle {
  justify-self: end;
}

.tooth-chart-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.tooth-chart-head h2 {
  margin: 0;
  font-size: 26px;
}

.tooth-chart-title-line p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
}

.tooth-orientation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.tooth-orientation span:last-child {
  text-align: right;
}

.tooth-arch {
  position: relative;
  width: min(100%, 600px);
  min-height: clamp(620px, 72vw, 760px);
  justify-self: center;
  overflow: hidden;
  border: 1px solid #dbe3ea;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(244, 120, 100, 0.13) 0 25%, transparent 26%),
    radial-gradient(ellipse at 50% 50%, #ffffff 0 29%, transparent 30%),
    linear-gradient(180deg, #f8fbfa, #eef6f3);
  min-width: 0;
}

.jaw-label {
  position: absolute;
  z-index: 4;
  min-width: 48px;
  border: 1px solid rgba(13, 118, 110, 0.16);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 6px 14px rgba(24, 32, 42, 0.08);
}

.jaw-label-upper {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.jaw-label-lower {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.chart-side-label {
  position: absolute;
  top: 12px;
  z-index: 4;
  border: 1px solid rgba(13, 118, 110, 0.16);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 6px 14px rgba(24, 32, 42, 0.08);
}

.chart-side-label-right {
  left: 12px;
}

.chart-side-label-left {
  right: 12px;
}

.mouth-center {
  position: absolute;
  top: 9%;
  bottom: 9%;
  left: 50%;
  z-index: 1;
  width: 1px;
  background: linear-gradient(180deg, transparent, #b7c7d0 18%, #b7c7d0 82%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mouth-center span {
  position: absolute;
  top: 50%;
  left: 8px;
  width: max-content;
  transform: translateY(-50%);
}

.tooth-arc {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tooth-arc::before {
  content: "";
  position: absolute;
  right: 10%;
  left: 10%;
  height: 47%;
  border: 2px dashed rgba(13, 118, 110, 0.2);
  pointer-events: none;
}

.tooth-arc-upper::before {
  top: 5%;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.tooth-arc-lower::before {
  bottom: 5%;
  border-top: 0;
  border-radius: 0 0 999px 999px;
}

.tooth-button {
  position: absolute;
  top: var(--tooth-y);
  left: var(--tooth-x);
  z-index: 3;
  display: grid;
  width: clamp(42px, 5vw, 62px);
  min-height: clamp(58px, 6vw, 78px);
  align-content: center;
  gap: 4px;
  border: 2px solid #aebfc9;
  border-radius: 44% 44% 50% 50%;
  padding: 6px 4px;
  background: #f8fbfa;
  color: var(--ink);
  box-shadow: 0 8px 16px rgba(24, 32, 42, 0.08);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%) rotate(var(--tooth-rotation));
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.tooth-button:hover,
.tooth-button:focus-visible {
  z-index: 10;
  border-color: rgba(13, 118, 110, 0.72);
  outline: none;
  transform: translate(-50%, -50%) rotate(var(--tooth-rotation)) translateY(-2px);
}

.tooth-button.is-selected {
  z-index: 9;
  border-color: var(--accent);
  background: #e5f4ef;
  box-shadow: 0 0 0 4px rgba(13, 118, 110, 0.14), 0 8px 16px rgba(24, 32, 42, 0.08);
  animation: tooth-breathe 1.8s ease-in-out infinite;
}

.tooth-number {
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.tooth-name {
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.tooth-detail {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 2vw, 22px);
  background: #fff;
  box-shadow: var(--shadow);
}

.tooth-detail-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px auto;
  gap: 10px;
  align-items: start;
}

.tooth-detail h2 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 28px;
  line-height: 1.2;
}

.tooth-title-code {
  display: inline-flex;
  min-width: 44px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(13, 118, 110, 0.24);
  border-radius: 8px;
  padding: 2px 10px;
  background: #dff2ee;
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.speak-tooth {
  display: grid;
  width: 42px;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.speak-tooth:hover,
.speak-tooth:focus-visible {
  border-color: var(--accent);
  background: var(--soft);
  outline: none;
}

.edit-tooth {
  display: grid;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1;
}

.edit-tooth:hover,
.edit-tooth:focus-visible {
  border-color: var(--accent);
  background: var(--soft);
  outline: none;
}

.edit-tooth.is-saving {
  background: var(--accent);
  color: #fff;
}

.tooth-detail > p:not(.eyebrow) {
  margin: 0;
  color: #344554;
  font-size: 15px;
  line-height: 1.6;
}

.tooth-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.tooth-detail-list div,
.tooth-rule-box {
  min-width: 0;
  border: 1px solid #dbe3ea;
  border-radius: 8px;
  padding: 10px;
  background: #f7faf9;
}

.tooth-detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tooth-detail-list dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}

.tooth-edit-input {
  min-height: 36px;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 15px;
  font-weight: 800;
}

.tooth-edit-input + .tooth-edit-input {
  margin-top: 6px;
}

.tooth-rule-box {
  display: grid;
  gap: 6px;
  background: #fff8e7;
}

.tooth-rule-box h3 {
  margin: 0;
  color: #735302;
  font-size: 16px;
}

.tooth-rule-box p {
  margin: 0;
  color: #4f3a06;
  font-size: 14px;
  line-height: 1.55;
}

.tool-search span {
  color: var(--muted);
  font-size: 14px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.term-sections {
  display: grid;
  align-items: start;
  gap: 28px;
}

.term-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.term-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 4px 10px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}

.term-section-head .eyebrow {
  grid-column: 1 / -1;
  margin: 0;
}

.term-section-head h2 {
  margin: 0;
  font-size: 24px;
}

.term-section-head span {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 900;
}

.term-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.term-card {
  display: grid;
  min-height: 278px;
  gap: 7px;
  border: 2px solid var(--card-line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 12px 26px rgba(24, 32, 42, 0.1);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.term-card-term {
  background: #f4faf7;
}

.term-card-unit {
  background: #fff8e7;
}

.term-card-element {
  border-color: #8291dc;
  background: #edf0ff;
}

.term-card-element .term-category {
  color: #33419a;
}

.term-section-element .term-section-head {
  border-color: #9aa7e6;
}

.term-card:focus,
.term-card:hover {
  border-color: rgba(13, 118, 110, 0.68);
  outline: none;
  transform: translateY(-2px);
}

.term-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
}

.term-category {
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.term-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 21px;
  line-height: 1.2;
}

.term-japanese {
  margin: 0;
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.35;
}

.term-card dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.term-card dl div {
  min-width: 0;
  border-radius: 8px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.68);
}

.term-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.term-card dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.term-desc-ja,
.term-desc-zh {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  -webkit-box-orient: vertical;
  font-size: 13px;
  line-height: 1.45;
}

.term-desc-ja {
  -webkit-line-clamp: 2;
}

.term-desc-zh {
  color: #344554;
  -webkit-line-clamp: 2;
}

.speak-term {
  display: grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: var(--accent-dark);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.speak-term:hover,
.speak-term:focus-visible {
  border-color: var(--accent);
  background: var(--soft);
  outline: none;
}

.term-section-empty {
  margin: 0;
  border: 1px dashed #b9c8d0;
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.tool-card {
  overflow: hidden;
  border: 2px solid var(--card-line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(24, 32, 42, 0.11);
  cursor: grab;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.tool-card:focus,
.tool-card:hover {
  border-color: rgba(13, 118, 110, 0.68);
  outline: none;
  transform: translateY(-2px);
}

.tool-card:active {
  cursor: grabbing;
}

.tool-card.is-dragging {
  opacity: 0.55;
}

.tool-card.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 118, 110, 0.16), 0 12px 28px rgba(24, 32, 42, 0.11);
}

.tool-card-image {
  display: grid;
  aspect-ratio: 4 / 3;
  place-items: center;
  background: linear-gradient(135deg, #e8f1ef, #f9fbfa);
}

.tool-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tool-image-placeholder {
  color: var(--muted);
  font-weight: 800;
}

.tool-card-body {
  display: grid;
  gap: 7px;
  padding: 11px;
}

.tool-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: start;
  gap: 6px;
}

.tool-card h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.22;
}

.speak-tool {
  display: grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: var(--accent-dark);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.speak-tool:hover,
.speak-tool:focus-visible {
  border-color: var(--accent);
  background: var(--soft);
  outline: none;
}

.tool-japanese,
.tool-function {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  -webkit-box-orient: vertical;
}

.tool-japanese {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  -webkit-line-clamp: 1;
}

.tool-function {
  font-size: 13px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
}

.tool-card dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.tool-card dl div {
  min-width: 0;
  border-radius: 8px;
  padding: 6px;
  background: #f4f7f6;
}

.tool-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tool-card dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.empty-state {
  border: 1px dashed #b9c8d0;
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  text-align: center;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(24, 32, 42, 0.42);
  backdrop-filter: blur(4px);
}

.tool-dialog {
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.quiz-dialog {
  width: min(860px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tool-form,
.quiz-box,
.confirm-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(12px, 2vw, 18px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-form-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 14px;
  align-items: stretch;
}

.term-form-layout {
  display: grid;
  gap: 12px;
}

.term-description-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tool-form-media,
.tool-form-detail {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.tool-form-detail {
  grid-template-rows: auto auto minmax(20px, auto) auto;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.dialog-head h2,
.confirm-box h2 {
  margin: 0;
  font-size: 24px;
}

.icon-button {
  position: relative;
  width: 38px;
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0;
  background: #eef3f1;
  color: var(--accent-dark);
}

.close-button::before,
.close-button::after {
  content: "";
  position: absolute;
  top: 18px;
  left: 10px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.close-button::before {
  transform: rotate(45deg);
}

.close-button::after {
  transform: rotate(-45deg);
}

.image-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-preview {
  display: grid;
  min-height: 154px;
  place-items: center;
  border: 1px dashed #afbec7;
  border-radius: 8px;
  background: #f8fbfa center / cover no-repeat;
  color: var(--muted);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-self: end;
}

.quiz-board {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
  gap: 14px;
  min-height: 314px;
}

.quiz-question,
.quiz-answer-area {
  display: grid;
  grid-template-rows: 18px 1fr;
  gap: 8px;
  min-width: 0;
}

.quiz-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
}

.quiz-prompt {
  display: grid;
  height: 288px;
  place-items: center;
  border: 2px solid var(--card-line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
  color: var(--ink);
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.25;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  height: 288px;
}

.quiz-option {
  height: 139px;
  border: 2px solid var(--card-line);
  padding: 10px;
  background: #fff;
  color: var(--ink);
  overflow: hidden;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.3;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.quiz-option.is-selected {
  border-color: var(--accent);
  background: var(--soft);
}

.quiz-option.is-correct {
  border-color: #138a45;
  background: #eaf8ee;
  color: #0f6f38;
  animation: quiz-correct 0.46s ease;
}

.quiz-option.is-wrong {
  border-color: #b42318;
  background: #fff0ee;
  color: #9f1f17;
  animation: quiz-wrong 0.42s ease;
}

.quiz-option:disabled {
  cursor: default;
  opacity: 1;
}

.quiz-image {
  display: block;
  width: 100%;
  max-height: 250px;
  object-fit: contain;
  border-radius: 6px;
}

.quiz-option .quiz-image {
  max-height: 112px;
}

.quiz-actions {
  justify-content: flex-end;
}

#quiz-feedback,
#term-quiz-feedback {
  min-height: 26px;
  line-height: 26px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

@keyframes quiz-correct {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tooth-breathe {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(var(--tooth-rotation)) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) rotate(var(--tooth-rotation)) scale(1.08);
  }
}

@keyframes quiz-wrong {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

.tool-form-detail textarea {
  min-height: 116px;
}

.tool-form-detail label:first-child textarea {
  min-height: 150px;
}

.danger-button {
  background: #b42318;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .nav {
    justify-content: flex-start;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-card {
    min-height: 220px;
  }

  .entry-card-watermark {
    right: -44px;
    bottom: -64px;
    font-size: 340px;
  }

  .topbar-title {
    min-width: 0;
  }

  .tool-toolbar,
  .tool-toolbar-actions,
  .tool-grid,
  .term-sections,
  .term-grid,
  .tooth-study-layout,
  .tooth-chart-head,
  .tool-form-layout,
  .term-description-grid,
  .quiz-board,
  .quiz-options,
  .settings-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions > * {
    width: 100%;
  }

  .dialog-actions > *,
  .tool-toolbar-actions,
  .tool-toolbar-actions > button {
    width: 100%;
  }

  .tool-toolbar-actions {
    flex-direction: column;
  }

  .tooth-tabs {
    width: 100%;
  }

  .tooth-tab {
    flex: 1 1 0;
  }

  .tooth-label-button {
    flex: 0 0 auto;
  }

  .tooth-chart-panel {
    overflow: visible;
  }

  .tooth-chart-title-line {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .tooth-chart-title-line p {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .tooth-arch {
    width: min(100%, 430px);
    min-height: 610px;
  }

  .tooth-arch-primary {
    min-height: 520px;
  }

  .tooth-button {
    width: 46px;
    min-height: 62px;
  }

  .tooth-name {
    font-size: 10px;
  }

  .tooth-detail {
    position: static;
  }

  .tooth-detail-list {
    grid-template-columns: 1fr;
  }

  .quiz-prompt {
    height: 190px;
    font-size: 24px;
  }

  .quiz-board {
    min-height: 0;
  }

  .quiz-options {
    height: auto;
  }

  .quiz-option {
    height: 112px;
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .tool-dialog {
    width: min(860px, calc(100vw - 20px));
  }

  .quiz-dialog {
    width: min(820px, calc(100vw - 20px));
  }

  .tool-form-layout {
    grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.1fr);
    gap: 10px;
  }

  .image-preview {
    min-height: 136px;
  }

  .tool-form-detail textarea {
    min-height: 104px;
  }

  .tool-form-detail label:first-child textarea {
    min-height: 132px;
  }

  .quiz-board {
    min-height: 284px;
  }

  .quiz-prompt,
  .quiz-options {
    height: 258px;
  }

  .quiz-option {
    height: 124px;
  }
}

@media (min-width: 761px) and (max-width: 1050px) {
  .tool-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-card h2 {
    font-size: 17px;
  }

  .tool-card-body {
    padding: 10px;
  }
}
