:root {
  --surface: #faf9f6;
  --paper-white: #f9f8f6;
  --surface-lowest: #ffffff;
  --surface-low: #f4f3f1;
  --surface-container: #efeeeb;
  --surface-high: #e9e8e5;
  --surface-highest: #e3e2e0;
  --surface-dim: #dadad7;
  --veil-cream: #e8e6e1;
  --primary: #173124;
  --forest-ink: #2d4739;
  --secondary: #5e5e5d;
  --slate-gray: #666666;
  --on-surface: #1a1c1b;
  --on-surface-variant: #424844;
  --on-primary: #ffffff;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --outline-variant: #c2c8c2;
  --margin-edge: 24px;
  --hero-padding: 64px;
  --section-gap: 40px;
  --stack-sm: 8px;
  --stack-md: 16px;
  --stack-lg: 24px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--surface);
}

body {
  margin: 0;
  min-height: max(884px, 100dvh);
  background: var(--paper-white);
  color: var(--on-surface);
  font-family: Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  color: currentColor;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
}

.app-icon {
  width: 24px;
  height: 24px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: min(100%, 600px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  background: var(--paper-white);
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.03);
}

.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  height: 52px;
  padding: 0 var(--margin-edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(250, 249, 246, 0.94);
  backdrop-filter: blur(10px);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  background: var(--surface-low);
  opacity: 0.88;
}

.icon-button:active {
  transform: scale(0.96);
}

.bar-spacer {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
}

.bar-title {
  margin: 0;
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24px;
  line-height: 30px;
  font-weight: 650;
  letter-spacing: 0;
}

.home-main {
  padding: 18px var(--margin-edge) 104px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.search-panel {
  position: relative;
  width: 100%;
}

.search {
  width: 100%;
  height: 44px;
  padding: 0 34px 0 0;
  border: 0;
  border-bottom: 1px solid var(--surface-highest);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--primary);
  font-size: 16px;
  line-height: 24px;
}

.search::placeholder {
  color: #b7b6b2;
}

.search:focus {
  border-bottom-color: var(--forest-ink);
}

.search-close {
  position: absolute;
  right: 0;
  top: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  color: var(--slate-gray);
  transform: translateY(-50%);
  font-size: 24px;
  line-height: 1;
}

.search-close:hover {
  color: var(--primary);
  background: var(--surface-low);
}

.word-list {
  display: flex;
  flex-direction: column;
}

.word-card {
  width: 100%;
  padding: 10px 0;
  display: block;
  background: transparent;
  color: inherit;
  text-align: left;
  border-bottom: 1px solid rgba(218, 218, 215, 0.58);
}

.word-card:first-child {
  padding-top: 0;
}

.word-card:last-child {
  border-bottom: 0;
}

.word-card:hover .word-name {
  opacity: 0.82;
}

.word-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) clamp(148px, 48%, 260px);
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.index {
  color: var(--secondary);
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

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

.word-name {
  margin: 0;
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 26px;
  line-height: 30px;
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.phonetic {
  display: block;
  margin-top: 1px;
  color: var(--slate-gray);
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.part {
  color: var(--secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meaning-area {
  position: relative;
  display: block;
  min-height: 34px;
  cursor: pointer;
}

.veil {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-high);
  border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(90deg, var(--veil-cream) 0%, #f5f3ef 50%, var(--veil-cream) 100%);
  background-size: 200% 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  animation: shimmer 3s infinite linear;
  color: var(--slate-gray);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 220ms ease;
}

.meaning {
  min-height: 52px;
  margin: 0;
  padding: 6px 9px;
  display: block;
  border: 1px solid var(--surface-high);
  border-radius: 4px;
  background: rgba(244, 243, 241, 0.72);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.015);
  color: var(--on-surface-variant);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.meaning-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meaning-short {
  color: var(--on-surface);
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
}

.meaning-core {
  color: var(--on-surface-variant);
  font-size: 11px;
  line-height: 15px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.meaning-revealed:hover {
  border-color: var(--outline-variant);
  background: var(--surface-low);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.025);
}

.fab {
  position: fixed;
  right: max(var(--margin-edge), calc((100vw - 600px) / 2 + var(--margin-edge)));
  bottom: 76px;
  z-index: 30;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--forest-ink);
  color: var(--on-primary);
  box-shadow: 0 12px 26px rgba(45, 71, 57, 0.22);
  transition: opacity 160ms ease, transform 160ms ease;
}

.fab:hover {
  opacity: 0.9;
}

.fab:active {
  transform: scale(0.96);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  width: min(100%, 600px);
  margin: 0 auto;
  min-height: 60px;
  padding: 7px var(--margin-edge) 9px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(250, 249, 246, 0.96);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.02);
  backdrop-filter: blur(12px);
}

.nav-item {
  min-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  color: var(--secondary);
  opacity: 0.6;
  transition: color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.nav-item.active {
  color: var(--primary);
  opacity: 1;
  font-weight: 700;
  transform: translateY(-1px);
}

.nav-item .app-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.nav-item span:last-child {
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.empty-state,
.error-state,
.deep-empty {
  padding: var(--section-gap) 0;
  color: var(--slate-gray);
  text-align: center;
}

.empty-state p,
.error-state p,
.deep-empty p {
  max-width: 360px;
  margin: 0 auto var(--stack-lg);
  color: var(--on-surface-variant);
  font-size: 16px;
  line-height: 24px;
}

.btn {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--surface-highest);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.btn.primary {
  border-color: var(--forest-ink);
  background: var(--forest-ink);
  color: var(--on-primary);
  box-shadow: 0 4px 14px rgba(45, 71, 57, 0.2);
}

.btn.danger {
  border-color: transparent;
  color: var(--secondary);
}

.btn.danger:hover {
  color: var(--error);
  background: rgba(255, 218, 214, 0.3);
}

.btn.text {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.detail-shell {
  min-height: 100vh;
  background: var(--paper-white);
}

.detail-main {
  padding: 0 var(--margin-edge) 104px;
}

.detail-hero {
  position: relative;
  padding: var(--hero-padding) 0 var(--section-gap);
  text-align: center;
}

.detail-title {
  margin: 0 0 var(--stack-sm);
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 48px;
  line-height: 52px;
  font-weight: 500;
  letter-spacing: 0;
}

.detail-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--surface-low);
  color: var(--secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.section {
  display: flex;
  flex-direction: column;
  gap: var(--stack-md);
}

.section-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  display: inline-block;
  border-radius: 999px;
  background: var(--forest-ink);
}

.quick-card {
  padding: var(--stack-lg);
  display: flex;
  flex-direction: column;
  gap: var(--stack-lg);
  border: 1px solid rgba(227, 226, 224, 0.65);
  border-radius: 8px;
  background: var(--surface-lowest);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.lead-zh {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 18px;
  line-height: 28px;
  font-weight: 500;
}

.body-copy {
  margin: 0;
  color: var(--slate-gray);
  font-size: 16px;
  line-height: 24px;
}

.english-def {
  padding-top: var(--stack-md);
  border-top: 1px solid rgba(218, 218, 215, 0.5);
}

.english-def p {
  margin: 0;
  color: var(--on-surface-variant);
  font-size: 16px;
  line-height: 24px;
  font-style: italic;
}

.example {
  position: relative;
  padding: var(--stack-md);
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-low);
}

.example::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: rgba(45, 71, 57, 0.2);
  transition: background 160ms ease;
}

.example:hover::before {
  background: var(--forest-ink);
}

.example p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 18px;
  line-height: 28px;
}

.example .translation {
  margin: 0;
  color: var(--slate-gray);
  font-size: 16px;
  line-height: 24px;
}

.section-separator {
  border: 0;
  border-top: 1px solid var(--surface-dim);
  margin: 0;
}

.deep-action {
  padding: var(--stack-lg) 0;
  text-align: center;
}

.deep-action .section-title {
  justify-content: center;
}

.deep-action .section-title::before {
  display: none;
}

.deep-grid {
  display: flex;
  flex-direction: column;
  gap: var(--stack-lg);
}

.deep-block {
  padding: var(--stack-lg);
  border-radius: 8px;
  background: var(--surface-lowest);
  border: 1px solid rgba(227, 226, 224, 0.65);
}

.deep-block h3 {
  margin: 0 0 8px;
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.deep-block p,
.deep-block li {
  color: var(--on-surface-variant);
  font-size: 16px;
  line-height: 24px;
}

.deep-block p {
  margin: 0;
}

.deep-block ul {
  margin: 0;
  padding-left: 18px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.chip-list li {
  padding: 8px 12px;
  border-radius: 4px;
  background: var(--surface-container);
}

.danger-zone {
  margin-top: var(--section-gap);
  padding-top: var(--stack-lg);
  border-top: 1px solid rgba(218, 218, 215, 0.3);
  display: flex;
  justify-content: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--margin-edge);
  background: rgba(249, 248, 246, 0.8);
  backdrop-filter: blur(8px);
  animation: fadeIn 160ms ease both;
}

.modal {
  position: relative;
  width: min(100%, 500px);
  max-height: min(760px, 88vh);
  overflow: auto;
  padding: var(--stack-lg);
  border: 1px solid var(--surface-highest);
  border-radius: 8px;
  background: var(--surface-lowest);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  animation: liftIn 180ms ease both;
}

.modal-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--section-gap);
}

.modal-kicker {
  color: var(--secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.word-input {
  width: 100%;
  height: 58px;
  padding: var(--stack-sm) 0;
  border: 0;
  border-bottom: 1px solid var(--surface-highest);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 36px;
  line-height: 40px;
  font-weight: 500;
  letter-spacing: 0;
}

.word-input::placeholder {
  color: #c7c6c5;
}

.word-input:focus {
  border-bottom-color: var(--forest-ink);
}

.code-input {
  max-width: 220px;
  letter-spacing: 0.18em;
}

.hint,
.status-line,
.form-error {
  margin-top: 12px;
  color: var(--slate-gray);
  font-size: 13px;
  line-height: 18px;
}

.form-error {
  color: var(--error);
}

.account-panel {
  padding: 16px 0 4px;
}

.account-email {
  margin: 8px 0 0;
  color: var(--primary);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.preview {
  position: relative;
  margin-top: var(--stack-lg);
  padding: var(--stack-lg);
  display: flex;
  flex-direction: column;
  gap: var(--stack-md);
  border: 1px solid var(--surface-highest);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.preview::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--surface-high);
}

.preview-loading {
  min-height: 170px;
}

.preview-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.loading-lines {
  display: grid;
  gap: 10px;
}

.loading-lines span {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--veil-cream) 0%, #f5f3ef 50%, var(--veil-cream) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}

.loading-lines span:nth-child(1) {
  width: 82%;
}

.loading-lines span:nth-child(2) {
  width: 94%;
}

.loading-lines span:nth-child(3) {
  width: 58%;
}

.preview-word {
  margin: 0;
  color: var(--primary);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.preview-part {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-container);
  color: var(--secondary);
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-label {
  margin: 0;
  color: var(--secondary);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-example {
  padding: 12px 14px;
  border-radius: 4px;
  background: var(--surface-low);
}

.preview-example p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 15px;
  line-height: 22px;
}

.preview-example .translation {
  margin: 0;
  color: var(--slate-gray);
  font-size: 13px;
  line-height: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: var(--stack-lg);
}

.skeleton-list {
  display: grid;
  gap: var(--stack-lg);
}

.skeleton-item {
  height: 96px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--veil-cream) 0%, #f5f3ef 50%, var(--veil-cream) 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

.pulse {
  display: inline-block;
  color: var(--forest-ink);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (min-width: 601px) {
  .app-shell {
    border-left: 1px solid var(--surface-dim);
    border-right: 1px solid var(--surface-dim);
  }
}

@media (max-width: 420px) {
  :root {
    --margin-edge: 20px;
  }

  .word-row {
    grid-template-columns: auto minmax(0, 1fr) 148px;
    gap: 8px;
  }

  .word-name {
    font-size: 25px;
    line-height: 29px;
  }

  .word-input {
    font-size: 34px;
  }
}
