/*
  日语动词变形自学手册样式
  作者：伤感咩吖
*/

:root {
  --bg: #f8f5ec;
  --panel: #fffdf6;
  --panel-2: #f1eadb;
  --ink: #202522;
  --muted: #6a685f;
  --line: #ddd3bf;
  --line-strong: #c9bda7;
  --red: #a83228;
  --red-soft: #f5ddd8;
  --green: #315e49;
  --green-soft: #dfe9de;
  --gold: #986d22;
  --blue: #2f5871;
  --shadow: 0 24px 70px rgba(48, 40, 26, 0.08);
  --sans: "Source Han Sans SC", "Noto Sans CJK SC", "思源黑体", "Microsoft YaHei", sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif CJK SC", "思源宋体", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(32, 37, 34, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 37, 34, 0.026) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.75;
  overflow-x: hidden;
}

ruby {
  ruby-align: center;
}

rt {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.56em;
  font-weight: 700;
}

p,
li,
dd,
.class-card,
.flow-card,
.rule-card,
.usage-card,
.verb-form-card,
.special-card,
.bonus-item {
  overflow-wrap: anywhere;
  line-break: loose;
}

button,
input,
select {
  font: inherit;
}

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

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

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

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 245, 236, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--serif);
  font-size: 25px;
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand h1 {
  font-family: var(--serif);
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-nav a {
  padding: 8px 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  background: var(--panel);
  color: var(--ink);
  outline: 1px solid var(--line);
}

.layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 30px) 54px;
  overflow: hidden;
}

.explain-panel,
.flow-card,
.class-card,
.form-card,
.bonus-card {
  border: 1px solid var(--line);
  background: rgba(255, 253, 246, 0.82);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.search-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.content {
  min-width: 0;
}

.hero {
  min-width: 0;
  min-height: 420px;
  display: grid;
  align-content: center;
  padding: clamp(36px, 6vw, 76px);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 253, 246, 0.95), rgba(241, 234, 219, 0.76)),
    radial-gradient(circle at 85% 20%, rgba(49, 94, 73, 0.12), transparent 30%);
}

.hero h2,
.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hero h2 {
  max-width: 900px;
  font-size: clamp(44px, 7vw, 96px);
}

.hero p:not(.eyebrow) {
  max-width: 920px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.5vw, 19px);
  overflow-wrap: anywhere;
}

.hero-actions,
.panel-actions,
.row-actions,
.search-row,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hero-actions {
  margin-top: 24px;
}

button,
.solid,
.ghost {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  padding: 7px 11px;
  cursor: pointer;
  font-weight: 800;
}

.solid {
  background: var(--ink);
  color: var(--bg);
}

.ghost {
  background: var(--panel);
  color: var(--ink);
}

button:hover,
.solid:hover,
.ghost:hover,
button:focus-visible,
.solid:focus-visible,
.ghost:focus-visible {
  border-color: var(--ink);
  outline: 0;
}

.section {
  padding-top: 44px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2 {
  font-size: clamp(30px, 4vw, 58px);
}

.section-heading p:not(.eyebrow) {
  max-width: 880px;
  margin: 10px 0 0;
  color: var(--muted);
}

.class-stack,
.forms-list,
.bonus-stack {
  display: grid;
  gap: 14px;
}

.class-card {
  display: grid;
  grid-template-columns: 0.55fr 1fr;
  gap: 20px;
  padding: 22px;
  min-width: 0;
}

.class-card h3,
.flow-card h3,
.form-title h3,
.bonus-card h3 {
  margin: 0;
  font-family: var(--serif);
  line-height: 1.22;
}

.class-card h3 {
  font-size: clamp(24px, 2.5vw, 36px);
}

.class-card p,
.flow-card li,
.form-summary,
.form-card p,
.bonus-card p {
  color: var(--muted);
}

.pattern-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.pattern-row span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid rgba(168, 50, 40, 0.24);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 900;
  text-align: center;
}

.class-card:nth-child(2) .pattern-row span {
  border-color: rgba(49, 94, 73, 0.24);
  background: var(--green-soft);
  color: var(--green);
}

.class-card:nth-child(3) .pattern-row span {
  border-color: rgba(152, 109, 34, 0.26);
  background: #f6ead3;
  color: var(--gold);
}

.class-notes {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.class-notes li,
.memory-list li {
  position: relative;
  padding-left: 16px;
}

.class-notes li::before,
.memory-list li::before {
  content: "";
  position: absolute;
  top: 0.82em;
  left: 0;
  width: 7px;
  height: 7px;
  background: var(--red);
}

.flow-card {
  margin-top: 14px;
  padding: 22px;
}

.flow-card ol {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 22px;
}

.form-card {
  overflow: hidden;
  min-width: 0;
}

.form-card summary {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.form-card summary::-webkit-details-marker {
  display: none;
}

.form-card[open] summary {
  border-bottom: 1px solid var(--line);
  background: rgba(241, 234, 219, 0.56);
}

.form-index {
  color: var(--red);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 900;
}

.form-title h3 {
  font-size: clamp(22px, 2.2vw, 34px);
}

.form-summary {
  margin: 4px 0 0;
}

.open-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.form-card[open] .open-label {
  color: var(--red);
}

.form-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

.rule-box {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  min-width: 0;
}

.rule-box strong {
  display: block;
  color: var(--green);
  margin-bottom: 5px;
}

.rule-box p {
  margin: 0;
}

.rule-matrix,
.use-matrix {
  border: 1px solid var(--line);
  background: rgba(255, 253, 246, 0.78);
  padding: 16px;
}

.matrix-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.matrix-title strong {
  color: var(--red);
  font-size: 16px;
}

.matrix-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 9px;
}

.matrix-row {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.matrix-key {
  width: fit-content;
  border-left: 4px solid var(--green);
  padding-left: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.matrix-row b {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
}

.matrix-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.use-matrix ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.use-matrix li {
  border-left: 4px solid var(--gold);
  background: var(--panel);
  padding: 10px 12px;
  color: var(--muted);
}

.deep-guide {
  display: grid;
  gap: 10px;
}

.deep-guide section {
  border-left: 4px solid var(--red);
  background: rgba(255, 253, 246, 0.72);
  padding: 13px 15px;
}

.deep-guide h4 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 17px;
}

.deep-guide p {
  margin: 0;
  color: var(--muted);
}

.table-shell {
  border: 1px solid var(--line);
  background: var(--panel);
}

.verb-card-grid,
.special-grid,
.bonus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 10px;
}

.verb-form-card,
.special-card,
.bonus-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
}

.verb-form-card:hover,
.special-card:hover,
.bonus-item:hover {
  background: rgba(223, 233, 222, 0.26);
}

.verb-card-head,
.special-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.verb-kind {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
}

.verb-name,
.bonus-term {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 900;
  line-height: 1.3;
}

.bonus-term {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bonus-special {
  border-color: rgba(168, 50, 40, 0.42);
  background: linear-gradient(180deg, rgba(245, 221, 216, 0.46), rgba(255, 253, 246, 0.94));
}

.special-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(168, 50, 40, 0.45);
  background: var(--red-soft);
  color: var(--red);
  padding: 2px 7px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.result-pill {
  color: var(--green);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 2px;
}

.field b {
  color: var(--ink);
  font-size: 13px;
}

.field span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.verb-form-card .ghost,
.bonus-card .solid {
  justify-self: start;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--ink);
  color: var(--bg);
  font-weight: 900;
}

tbody tr:hover {
  background: rgba(223, 233, 222, 0.36);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.kana-cell,
.result-cell {
  font-weight: 900;
}

.kana-cell {
  color: var(--red);
  white-space: nowrap;
}

.result-cell {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.85;
}

.jp {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.cn,
.hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.memory-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-row {
  margin-bottom: 12px;
}

.search-row input {
  flex: 1 1 320px;
}

.special-key {
  border-left: 5px solid var(--red);
}

.bonus-card {
  padding: 20px;
}

.bonus-card h3 {
  font-size: clamp(23px, 2vw, 32px);
}

.bonus-card > p {
  margin: 8px 0 14px;
}

.explain-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: min(430px, calc(100vw - 44px));
  max-height: min(72vh, 720px);
  overflow: auto;
  transform: translateY(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
  padding: 18px;
}

.explain-panel.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

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

.panel-head button {
  min-width: 34px;
  padding: 0;
  background: var(--panel);
}

.explain-panel h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.2;
}

.explain-panel p {
  color: var(--muted);
  white-space: pre-line;
}

#lessonAudio {
  width: 100%;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  transform: translateY(140%);
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 13px;
  transition: transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 1220px) {
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-nav a {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

  .layout {
    padding-inline: 12px;
  }

  .class-card,
  .rule-band {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding: 28px 18px;
  }

  .hero h2 {
    font-size: 32px;
    max-width: 7.5em;
    word-break: break-all;
  }

  .hero p:not(.eyebrow) {
    font-size: 15px;
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .section-heading h2 {
    font-size: 30px;
    word-break: break-all;
  }

  .form-card summary {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .pattern-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .verb-card-grid,
  .special-grid,
  .bonus-grid {
    grid-template-columns: 1fr;
  }

  .explain-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 70vh;
  }
}

@media print {
  .app-header,
  .explain-panel,
  .row-actions,
  .hero-actions,
  .search-row {
    display: none;
  }

  body {
    background: #fff;
  }

  .layout {
    display: block;
  }

  .form-card {
    break-inside: avoid;
  }
}
