:root {
  color-scheme: light;
  --bg-paper: #f5f5f7;
  --bg-card: rgba(255, 255, 255, 0.86);
  --text-primary: #1d1d1f;
  --text-secondary: #515154;
  --text-muted: #86868b;

  --accent-green: #007aff;
  --accent-green-light: #eaf3ff;
  --accent-ink: #0a84ff;
  --accent-brass: #6e8fbd;
  --accent-red: #9b4942;

  --border-color: rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --nav-height: 64px;
  --header-height: 0px;
  --paper-shadow: 0 12px 30px rgba(0, 0, 0, 0.07);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f7f7f9 100%),
    var(--bg-paper);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-top: 0;
  padding-bottom: calc(var(--nav-height) + 16px);
}

body.detail-open {
  overflow: hidden;
}

h1, h2, h3, .brand-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
}

.hanji-primary,
.result-hanji,
.word-card-hanji,
.ink-digital-hanji,
.home-feature-headword,
.recent-mini-hanji,
.topic-item-hanzi {
  font-family: 'Noto Serif', serif;
}

/* Header */
.top-app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-paper);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.9);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-green);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.88));
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 520;
  gap: 4px;
  width: 100%;
  padding: 8px 0;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item.active {
  color: var(--accent-green);
}

/* Main Content */
.app-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

/* Utility */
.loading-panel, .error-panel {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.spinner {
  position: relative;
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 1.5px solid rgba(81, 81, 84, 0.26);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(81, 81, 84, 0.28) 0 2px, transparent 2.5px);
  box-shadow: none;
  animation: compass-breathe 2.4s ease-in-out infinite;
}

.spinner::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 6px;
  width: 4px;
  height: 22px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(155, 73, 66, 0.74) 0 47%, rgba(0, 122, 255, 0.62) 53% 100%);
  transform-origin: 50% 50%;
  animation: compass-needle-sway 1.7s ease-in-out infinite;
}

.spinner::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border:
    1px solid rgba(81, 81, 84, 0.09);
}

@keyframes compass-breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.86;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

@keyframes compass-needle-sway {
  0%, 100% { transform: rotate(-18deg); }
  50% { transform: rotate(24deg); }
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--paper-shadow);
}

/* Home Tab */
.hero h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.hero p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* Search Controls (Sticky) */
.search-header-sticky {
  position: sticky;
  top: var(--header-height);
  z-index: 10;
  background: #ffffff;
  padding: 16px 16px 8px 16px;
  margin: -16px -16px 16px -16px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.search-input-wrapper {
  display: flex;
  gap: 8px;
}

.search-input-wrapper input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background-color: var(--bg-paper);
}

.search-input-wrapper button {
  padding: 0 20px;
  background-color: var(--accent-green);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
}

/* Search Tab */

.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.result-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s;
}

.result-card:active {
  transform: scale(0.98);
}

.result-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.hanji-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.result-hanji {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-green);
}

.ban-primary {
  font-size: 1.2rem;
}

.missing-hanji {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: normal;
}

.result-ban {
  font-size: 1rem;
  color: var(--text-secondary);
}

.result-spanish {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.result-english {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.clamped-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta-bottom {
  display: flex;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-top: 6px;
}

.status-dot-green {
  background-color: #2e7d32;
}

.status-dot-amber {
  background-color: #f57c00;
}

.status-dot-red {
  background-color: #d32f2f;
}

.status-dot-grey {
  background-color: #9e9e9e;
}

/* Word Card Styles */
.word-card-deck {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  perspective: 1000px;
  position: relative;
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.word-card-deck::before, .word-card-deck::after {
  content: "";
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  background: var(--bg-paper);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  pointer-events: none;
}

.word-card-deck::before {
  transform: translateY(8px) scale(0.95);
  z-index: -1;
  opacity: 0.8;
}

.word-card-deck::after {
  transform: translateY(16px) scale(0.90);
  z-index: -2;
  opacity: 0.6;
}

.word-card-wrapper {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  touch-action: pan-y;
  user-select: none;
  transform-origin: 50% 100%;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease-out;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  height: clamp(500px, 68dvh, 580px);
  overflow: hidden;
  z-index: 2;
}

.word-card-wrapper.dragging {
  transition: none;
}

.word-card-wrapper.behind {
  opacity: 0.95 !important;
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  z-index: 1 !important;
}

.word-card-wrapper.behind .word-card-ink-layout,
.word-card-wrapper.behind .word-card-text-layout {
  opacity: 0 !important;
}

.word-card-wrapper.behind.ready {
  opacity: 0.95 !important;
}

.word-card-wrapper.fly-out-left {
  transform: translateX(-150%) rotate(-15deg) !important;
  opacity: 0 !important;
}

.word-card-wrapper.fly-out-right {
  transform: translateX(150%) rotate(15deg) !important;
  opacity: 0 !important;
}

.word-card-wrapper.fly-out-fade {
  transform: scale(0.9) !important;
  opacity: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
  .word-card-wrapper {
    transition: opacity 0.2s ease-out !important;
  }
  .word-card-wrapper.fly-out-left,
  .word-card-wrapper.fly-out-right,
  .word-card-wrapper.fly-out-fade {
    transform: none !important;
    opacity: 0 !important;
  }
}

/* Word Card Ink-First Layout */
.word-card-ink-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: opacity 0.25s ease-out;
  opacity: 1;
}

.ink-evidence-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fbfaf8;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  position: relative;
}

.word-card-ink-layout.no-hero .ink-evidence-grid {
  flex: 0 0 auto;
  height: 100px;
  padding: 0;
}

.ink-spanish-strip {
  position: relative;
  height: 130px;
  width: 100%;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  background: #ffffff;
  flex-shrink: 0;
}

.ink-hero-feathered .ink-hero-bg {
  position: absolute;
  inset: -12px;
  z-index: 1;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  object-fit: cover;
  object-position: center;
  filter: blur(12px);
  opacity: 0.28;
  transform: scale(1.06);
  pointer-events: none;
}

.ink-hero-feathered .ink-hero-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  padding: 4px 0;
  box-sizing: border-box;
}

.ink-tiles-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  box-sizing: border-box;
  margin-top: auto;
  margin-bottom: auto;
}

.ink-tile {
  flex: 1;
  max-width: 100px;
  text-align: center;
}

.ink-tile img {
  width: 100%;
  height: 60px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #ffffff;
}

.ink-digital-footer {
  flex-shrink: 0;
  height: 190px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

.ink-digital-text-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}

.word-card-ink-layout.no-hero .ink-digital-footer {
  flex: 1;
  height: auto;
}

.ink-digital-headword-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.ink-digital-hanji {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
}

.ink-digital-ban {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-left: 8px;
  align-self: center;
}

.ink-digital-headword-row .status-dot {
  margin-left: auto;
}

.ink-digital-spanish {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.ink-digital-english {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ink-digital-action-row {
  margin-top: auto;
}

/* Word Card Text-First Layout */
.word-card-text-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: opacity 0.25s ease-out;
  opacity: 1;
}

.word-card-body {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.word-card-text-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  margin-top: 12px;
  margin-bottom: 16px;
}

.word-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.word-card-headwords {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.word-card-hanji-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.word-card-hanji {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-green);
  line-height: 1.1;
}

.word-card-ban {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.word-card-ban-primary {
  font-size: 1.8rem;
  color: var(--text-primary);
}

.word-card-spanish {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.word-card-english {
  font-size: 1rem;
  color: var(--text-secondary);
}

.word-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.word-card-pending {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.clamped-text, .word-card-spanish, .word-card-english, .ink-digital-spanish, .ink-digital-english {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.word-card-entry-link {
  background: none;
  border: none;
  color: var(--accent-green);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px;
}

.word-card-hanji-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ffffff;
  z-index: 2000;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  visibility: hidden;
}

.detail-overlay.active {
  transform: translateY(0);
  visibility: visible;
}

.detail-overlay-content {
  padding: 16px;
  padding-bottom: 80px;
  max-width: 800px;
  margin: 0 auto;
  background: #ffffff;
  min-height: 100dvh;
}

@media (prefers-reduced-motion: reduce) {
  .detail-overlay {
    transition: opacity 0.2s ease-out;
    transform: none;
    opacity: 0;
  }
  .detail-overlay.active {
    transform: none;
    opacity: 1;
  }
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 84px; /* Above bottom nav */
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--accent-green);
  font-size: 1.2rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.2s ease;
  padding: 0;
  margin: 0;
  outline: none;
  font-family: inherit;
  line-height: 1;
}

.back-to-top:hover {
  transform: translateY(-2px);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.draw-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}



.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--bg-paper);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.badge.ok { background-color: var(--accent-green-light); color: var(--accent-green); border-color: var(--accent-green-light); }

/* Entry Detail */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.entry-header {
  margin-bottom: 24px;
}

.hanji-primary {
  font-size: 2.5rem;
  line-height: 1.2;
  color: var(--accent-green);
  margin-bottom: 4px;
}

.spanish-primary {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.english-secondary {
  font-size: 1rem;
  color: var(--text-secondary);
}

.field-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.field-grid dt {
  color: var(--text-muted);
  font-weight: 500;
}

.field-grid dd {
  color: var(--text-primary);
}

.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
}

.manuscript-section {
  margin-bottom: 28px;
}

.manuscript-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.manuscript-section h3 {
  font-size: 1.1rem;
  margin-bottom: 0;
}

.manuscript-section-head span {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.manuscript-evidence-list {
  display: grid;
  gap: 12px;
}

.manuscript-crop-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.manuscript-crop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.manuscript-crop-short {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent-green-light);
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
  font-size: 0.95rem;
  line-height: 1;
}

.manuscript-crop-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #fbfaf7;
  cursor: zoom-in;
}

.manuscript-crop-button:focus-visible {
  outline: 3px solid var(--accent-green-light);
  outline-offset: 3px;
}

.crop-image {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-paper);
  display: block;
}

.manuscript-crop-action {
  color: var(--accent-green);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
  margin-top: 7px;
}

.manuscript-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.manuscript-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.72);
}

.manuscript-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.manuscript-lightbox-panel img {
  width: 100%;
  max-height: calc(100dvh - 126px);
  object-fit: contain;
  background: #fbfaf7;
  border-radius: 6px;
}

.manuscript-lightbox-panel figcaption {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

.manuscript-lightbox-close {
  align-self: flex-end;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-green);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 24px;
  background-color: var(--bg-paper);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Recent Mini Cards Tray */
#recent-cards-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.recent-mini-card {
  display: flex;
  flex-direction: column;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  padding: 12px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none !important;
  color: inherit !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  justify-content: center;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: transform 0.2s ease;
  box-sizing: border-box;
}

.recent-mini-card:hover {
  transform: translateY(-2px);
}

.recent-mini-hanji {
  font-family: 'Noto Serif', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-green);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.2;
}

.recent-mini-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.2;
}

/* Issue submission styles */
.issue-btn {
  background-color: transparent;
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.issue-btn:hover {
  background-color: var(--accent-green-light);
}

/* Issue Modal Overlay */
.issue-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(44, 42, 41, 0.6); /* --text-primary with opacity */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(4px);
}

.issue-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.issue-modal-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 92%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.issue-modal-overlay.active .issue-modal-container {
  transform: translateY(0);
}

/* Modal Header */
.issue-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.issue-modal-header h3 {
  color: var(--accent-green);
  font-size: 1.2rem;
  margin: 0;
  font-family: 'Noto Serif', serif;
}

.issue-modal-close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.issue-modal-close-btn:hover {
  color: var(--text-primary);
}

/* Modal Form */
.issue-modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.issue-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.issue-form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.issue-form-group input,
.issue-form-group select,
.issue-form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background-color: var(--bg-paper);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.issue-form-group input:focus,
.issue-form-group select:focus,
.issue-form-group textarea:focus {
  border-color: var(--accent-green);
}

.issue-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Actions */
.issue-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.issue-modal-actions button {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s, opacity 0.2s;
}

.issue-modal-cancel {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color) !important;
}

.issue-modal-cancel:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.issue-modal-submit {
  background-color: var(--accent-green);
  color: white;
}

.issue-modal-submit:hover {
  background-color: #1a453b;
}

.issue-modal-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Success/Error message */
.issue-form-feedback {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  display: none;
  line-height: 1.4;
}

.issue-form-feedback.success {
  display: block;
  background-color: var(--accent-green-light);
  color: var(--accent-green);
  border: 1px solid #c2ded6;
}

.issue-form-feedback.error {
  display: block;
  background-color: #fdf5f4;
  color: #c25c4c;
  border: 1px solid #f8d7d4;
}

/* Small helper text */
.issue-form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Phase 3.2 Mobile Layout Stabilization Overrides */
:root {
  --header-height: 0px;
}

html,
body {
  background-color: var(--bg-paper);
}

body {
  padding-top: 0;
  padding-bottom: calc(var(--nav-height) + 16px);
}

.top-app-bar {
  display: none !important;
}

.app-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-green);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.secondary-btn:hover,
.secondary-btn:focus-visible {
  border-color: var(--accent-green);
  outline: none;
}

/* Home */
.home-view .hero {
  margin: 24px 0 28px;
  text-align: center;
}

.home-view .hero h1 {
  color: var(--accent-green);
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.home-view .hero p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0;
}

.home-section {
  margin-bottom: 24px;
}

.home-section h3 {
  margin-bottom: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.featured-entry-section h3,
.home-actions {
  text-align: center;
}

.home-actions {
  margin-top: 12px;
}

.home-search-card {
  width: 100%;
  cursor: pointer;
  text-align: left;
  margin-bottom: 24px;
}

.home-search-preview {
  pointer-events: none;
}

.home-search-preview .secondary-btn {
  color: #ffffff;
  background: var(--accent-green);
  border-color: var(--accent-green);
  border-radius: 8px;
}

.home-hero {
  position: relative;
  overflow: hidden;
  margin: 0 -4px 22px;
  padding: 28px 18px 20px;
  border: 1px solid rgba(222, 211, 189, 0.88);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98), rgba(248, 241, 229, 0.92));
  box-shadow: var(--paper-shadow);
}

.home-hero > :not(.home-hero-image) {
  position: relative;
  z-index: 1;
}

.home-hero-image {
  position: absolute;
  right: -26px;
  top: 18px;
  width: min(62%, 320px);
  height: 58%;
  min-height: 170px;
  z-index: 0;
  border-radius: 10px;
  background-image: var(--home-manuscript-image);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  opacity: 0.26;
  filter: blur(4px) saturate(0.82);
  transform: perspective(520px) rotateY(-14deg) rotateZ(-5deg) scale(1.05);
  transform-origin: center right;
  box-shadow: 0 16px 40px rgba(47, 40, 30, 0.16);
}

.home-hero-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 253, 248, 0.92), rgba(255, 253, 248, 0.18));
}

.home-hero::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  height: 1px;
  background: linear-gradient(90deg, rgba(0, 122, 255, 0.36), rgba(0, 122, 255, 0.08), transparent);
}

.home-hero::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.05);
  transform: translate(36px, 36px);
}

.home-kicker {
  color: var(--accent-green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.home-hero h1 {
  color: #1f211b;
  font-size: 2rem;
  line-height: 1.08;
  margin-bottom: 10px;
}

.home-deck {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 18px;
  max-width: 42rem;
}

.home-era-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(222, 211, 189, 0.82);
}

.home-era-note {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.home-era-note span,
.home-era-note strong {
  display: block;
}

.home-era-note span {
  color: var(--accent-brass);
  font-size: 0.75rem;
  font-weight: 800;
}

.home-era-note strong {
  color: var(--accent-ink);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  line-height: 1.25;
  margin-top: 1px;
}

.home-search-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}

.home-search-form input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.96);
  color: var(--text-primary);
  font: inherit;
  font-size: 1rem;
}

.home-search-form input:focus {
  border-color: var(--accent-green);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-green-light);
}

.home-search-form button,
.home-section-head button {
  min-height: 40px;
  border: 1px solid var(--accent-green);
  border-radius: 8px;
  background: var(--accent-green);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.home-search-form button {
  padding: 0 18px;
}

.home-section-head button {
  min-height: 32px;
  padding: 5px 10px;
  background: rgba(255, 252, 244, 0.96);
  color: var(--accent-green);
}

.home-query-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: thin;
}

.home-query-row button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.92);
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.home-query-row button span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  margin-right: 6px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 26px;
}

.home-stat {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 252, 244, 0.96), rgba(248, 239, 219, 0.92));
  box-shadow: 0 8px 22px rgba(44, 31, 18, 0.08);
}

.home-stat strong {
  display: block;
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
  font-size: 1.35rem;
  line-height: 1.2;
}

.home-stat span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.25;
  margin-top: 4px;
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.home-section-head span {
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
}

.home-feature-card {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 252, 244, 0.98), rgba(247, 237, 216, 0.88));
  padding: 12px;
  box-shadow: var(--paper-shadow);
}

.home-feature-image {
  display: block;
  min-height: 180px;
  overflow: hidden;
  border-radius: 6px;
  background: #efe2c4;
}

.home-feature-image img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: contain;
  display: block;
}

.home-feature-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 2px;
}

.home-feature-headword {
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.home-feature-ban {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 3px;
}

.home-feature-copy p {
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.35;
  margin-top: 14px;
}

.home-feature-copy small {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 7px;
}

.home-feature-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.home-feature-meta span {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 4px 8px;
}

.home-note {
  margin: 6px 0 20px;
  padding: 14px;
  border: 1px solid rgba(205, 189, 155, 0.84);
  border-left: 4px solid var(--accent-brass);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.78);
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.home-note strong {
  color: var(--text-primary);
}

.mini-card-desc {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.3;
  margin: 4px 0 8px;
}

@media (max-width: 520px) {
  .home-era-strip {
    grid-template-columns: 1fr;
  }

  .home-era-note {
    min-height: 58px;
  }

  .home-hero-image {
    right: -58px;
    top: 34px;
    width: 78%;
    height: 36%;
    min-height: 138px;
    opacity: 0.24;
    filter: blur(5px) saturate(0.76);
  }
}

@media (max-width: 520px) {
  .home-hero h1 {
    font-size: 1.72rem;
  }

  .home-search-form {
    flex-direction: column;
  }

  .home-search-form button {
    min-height: 44px;
  }

  .home-feature-card {
    grid-template-columns: 1fr;
  }

  .home-feature-image,
  .home-feature-image img {
    min-height: 150px;
  }
}

@media (min-width: 760px) {
  .app-content {
    max-width: 760px;
  }

  .home-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Topics */
.section-header {
  margin: 18px 0 18px;
}

.section-header h1 {
  color: var(--accent-green);
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.topic-list {
  display: grid;
  gap: 14px;
}

.topic-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.topic-card h2,
.topic-detail-header h1 {
  color: var(--accent-green);
  font-size: 1.35rem;
  line-height: 1.25;
  margin-bottom: 6px;
}

.topic-card-label {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--accent-green-light);
  color: var(--accent-green);
  font-size: 0.8rem;
  font-weight: 700;
}

.topic-subtitle,
.topic-detail-header p,
.topic-description {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.topic-description {
  margin-top: 12px;
}

.topic-guide {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(27, 75, 66, 0.16);
  color: var(--text-secondary);
}

.topic-guide strong {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.topic-guide p {
  margin: 0;
  line-height: 1.55;
}

.topic-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.topic-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: thin;
}

.topic-mini-card {
  min-width: 220px;
  max-width: 260px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #ffffff;
  padding: 14px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.topic-mini-card span {
  display: inline-block;
  color: var(--accent-green);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.topic-mini-card strong {
  display: block;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 8px;
}

.topic-mini-card small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.topic-detail-header {
  margin-bottom: 14px;
}

.topic-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.topic-tools input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font: inherit;
  background: #ffffff;
}

.topic-count {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.topic-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.topic-load-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.topic-load-row [hidden] {
  display: none;
}

.topic-filter {
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.topic-filter.active {
  color: #ffffff;
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.topic-item {
  display: block;
  color: inherit;
  text-decoration: none;
}

.topic-item-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.topic-item-hanzi {
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

.topic-item-gloss {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.topic-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Search */
.search-header-sticky {
  position: static !important;
  top: auto !important;
  z-index: auto;
  background: #ffffff;
  padding: 0;
  margin: 0 0 16px;
  border-bottom: none;
  box-shadow: none;
}

.search-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-input-wrapper input {
  min-width: 0;
  background-color: #ffffff;
}

.search-options {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 0 2px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.35;
}

.search-options input {
  margin-top: 2px;
}

.results-container {
  display: block;
}

.pagination-controls {
  text-align: center;
  margin: 18px 0 32px;
}

.pagination-controls[hidden],
.load-more-btn[hidden],
.recent-cards-section[hidden] {
  display: none !important;
}

.results-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.load-more-btn {
  min-width: 128px;
}

.search-empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.search-empty-state h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.search-empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.search-example-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.search-example-row button {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--accent-green);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.result-meta-right {
  justify-content: flex-end;
}

/* Cards view */
.cards-view-header h2 {
  text-align: center;
  font-size: 1.25rem;
  margin: 10px 0 20px;
  color: var(--text-primary);
}

.loading-panel-compact {
  min-height: 200px;
}

.word-card-deck {
  max-width: 430px;
  margin-bottom: 22px;
}

.word-card-deck::before,
.word-card-deck::after {
  background: #ffffff;
  border-radius: 12px;
}

.word-card-wrapper {
  height: clamp(460px, calc(100dvh - var(--nav-height) - 132px), 560px);
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
}

.word-card-wrapper.behind {
  transform: translateY(10px) scale(0.98);
}

.word-card-ink-layout,
.word-card-text-layout {
  height: 100%;
}

.ink-evidence-grid {
  flex: 1 1 auto;
  min-height: 0;
  background: #ffffff;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ink-evidence-grid.no-tiles .ink-spanish-strip {
  flex: 1 1 auto;
  height: auto;
}

.word-card-ink-layout.no-hero .ink-evidence-grid {
  height: auto;
  min-height: 96px;
  flex: 1 1 auto;
}

.ink-spanish-strip {
  position: relative;
  width: 100%;
  height: 128px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: #ffffff;
  flex: 0 0 auto;
}

.ink-hero-bg {
  display: none !important;
}

.ink-hero-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  padding: 4px 0;
  background: #ffffff;
}

.ink-tiles-row {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  margin: 0;
  background: #ffffff;
}

.ink-tile {
  flex: 1 1 0;
  max-width: 124px;
  min-width: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.ink-tile img,
.ink-chip-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #ffffff;
  border: 0;
  border-radius: 0;
}

.ink-digital-footer {
  flex: 0 0 178px;
  height: 178px;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ink-digital-headword-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  min-height: 32px;
}

.ink-digital-hanji {
  font-size: 1.55rem;
  line-height: 1.1;
}

.ink-digital-ban {
  margin-left: 0;
  font-size: 1.05rem;
}

.ink-digital-headword-row .status-dot {
  margin-left: auto;
  align-self: center;
}

.ink-digital-text-area {
  flex: 1 1 auto;
  min-height: 0;
  justify-content: flex-start;
  overflow: hidden;
}

.ink-digital-spanish {
  font-size: 1.02rem;
  line-height: 1.32;
  margin: 0;
}

.ink-digital-english {
  font-size: 0.92rem;
  line-height: 1.32;
  margin: 0;
}

.ink-digital-action-row {
  flex: 0 0 auto;
  margin: 0;
}

.word-card-text-layout .word-card-body {
  padding: 24px;
}

.word-card-footer {
  flex: 0 0 auto;
}

.word-card-entry-link {
  appearance: none;
  background: none;
  border: 0;
  color: var(--accent-green);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 0;
}

.draw-hint {
  text-align: center;
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: normal;
}

/* Recently drawn */
.recent-cards-section {
  margin-top: 28px;
}

.recent-cards-section h3 {
  font-family: 'Noto Serif', serif;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

#recent-cards-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 0 12px;
  margin: 0;
  list-style: none;
  scrollbar-width: thin;
}

.recent-mini-card,
.recent-mini-card:visited,
.recent-mini-card:hover,
.recent-mini-card:active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 96px;
  height: 96px;
  min-width: 96px;
  padding: 10px 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: inherit !important;
  text-decoration: none !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
  box-sizing: border-box;
}

.recent-mini-hanji {
  width: 100%;
  color: var(--accent-green);
  font-family: 'Noto Serif', serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-mini-sub {
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail overlay */
.detail-overlay {
  background: #ffffff;
  z-index: 2000;
  overscroll-behavior: contain;
}

.detail-overlay-content {
  background: #ffffff;
  min-height: 100dvh;
}

.detail-back-button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent-green);
  font-family: inherit;
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
}

.entry-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.entry-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}



.badge-trusted,
.badge-slice {
  color: var(--accent-green);
  background: var(--accent-green-light);
  border-color: var(--accent-green-light);
}

.badge-review {
  color: #c25c4c;
  background: #fdf5f4;
  border-color: #f0c7c0;
}

/* Apple-like visual polish */
.search-header-sticky {
  background:
    linear-gradient(180deg, rgba(245, 245, 247, 0.96), rgba(245, 245, 247, 0.88));
  box-shadow: none;
}

.search-input-wrapper input,
.topic-tools input,
.home-search-form input {
  background-color: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.search-example-row button,
.topic-filter,
.home-query-row button,
.secondary-btn {
  background: rgba(255, 255, 255, 0.74);
  border-color: rgba(0, 0, 0, 0.12);
}

.result-card,
.topic-card,
.topic-mini-card,
.manuscript-crop-card,
.recent-mini-card,
.word-card-wrapper {
  border-color: rgba(0, 0, 0, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 250, 252, 0.82));
  box-shadow: var(--paper-shadow);
}

.topic-card,
.topic-mini-card,
.result-card {
  border-radius: 8px;
}

.word-card-deck::before,
.word-card-deck::after {
  background: rgba(255, 255, 255, 0.82);
}

.ink-evidence-grid,
.ink-spanish-strip,
.ink-hero-img,
.ink-tiles-row,
.ink-tile,
.ink-tile img,
.ink-chip-img {
  background: #f5f8ff;
}

.ink-digital-footer {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 250, 252, 0.96));
}

.detail-overlay {
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f7f7f9 100%);
}

.detail-overlay-content {
  background: transparent;
}

.home-hero {
  border-color: rgba(0, 0, 0, 0.08);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(248, 248, 250, 0.82));
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
}

.home-hero::before {
  background: linear-gradient(90deg, rgba(0, 122, 255, 0.42), rgba(0, 122, 255, 0.1), transparent);
}

.home-hero::after {
  background: rgba(0, 122, 255, 0.06);
}

.home-hero h1 {
  color: #1d1d1f;
  font-weight: 760;
  letter-spacing: 0;
}

.home-kicker {
  color: var(--accent-green);
  letter-spacing: 0;
  text-transform: none;
}

.home-deck,
.section-header p {
  color: #5f6368;
}

.home-era-strip {
  border-top-color: rgba(0, 0, 0, 0.08);
}

.home-era-note span {
  color: #7c7c80;
}

.home-era-note strong {
  color: #0066cc;
}

.home-search-form button,
.home-section-head button,
.topic-filter.active {
  border-color: transparent;
  background: #007aff;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.2);
}

.home-search-form button:active,
.home-section-head button:active {
  transform: scale(0.99);
}

.home-stat {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--paper-shadow);
}

.home-stat strong,
.home-feature-headword,
.result-hanji,
.ink-digital-hanji,
.topic-item-hanzi,
.recent-mini-hanji {
  color: #007aff;
}

.home-feature-card,
.home-note {
  border-color: rgba(0, 0, 0, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(250, 250, 252, 0.82));
}

.home-note {
  border-left-color: #007aff;
}

.home-feature-meta span,
.entry-badges .badge,
.badge-trusted,
.badge-slice {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 122, 255, 0.08);
}

/* Back-to-top is intentionally hidden on mobile until a full desktop/layout pass. */
.back-to-top {
  display: none !important;
}

@media (min-width: 720px) {
  .app-content {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  :root {
    --nav-height: 64px;
  }

  html {
    scroll-padding-top: 96px;
  }

  body {
    min-height: 100dvh;
    padding: 96px 0 48px;
    background:
      linear-gradient(180deg, #fbfbfd 0%, #f4f6f8 46%, #eef1f4 100%),
      var(--bg-paper);
  }

  .bottom-nav {
    top: 16px;
    bottom: auto;
    left: 50%;
    right: auto;
    width: min(1180px, calc(100% - 48px));
    height: var(--nav-height);
    padding: 8px;
    justify-content: flex-start;
    gap: 4px;
    transform: translateX(-50%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  }

  .nav-item {
    width: auto;
    min-width: 112px;
    height: 48px;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 0.9rem;
  }

  .nav-item svg {
    width: 19px;
    height: 19px;
  }

  .nav-item.active {
    background: rgba(0, 122, 255, 0.1);
  }

  .app-content {
    width: min(1180px, calc(100% - 48px));
    max-width: none;
    padding: 0;
  }

  .home-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .home-hero {
    min-height: 360px;
    margin: 0;
    padding: 42px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .home-hero::after {
    display: none;
  }

  .home-hero-image {
    top: 34px;
    right: 40px;
    width: min(42%, 440px);
    height: calc(100% - 68px);
    opacity: 0.34;
    filter: saturate(0.9);
    transform: perspective(760px) rotateY(-10deg) rotateZ(-3deg);
  }

  .home-hero h1 {
    max-width: 680px;
    font-size: clamp(2.45rem, 4vw, 4.2rem);
  }

  .home-deck {
    max-width: 650px;
    font-size: 1.08rem;
  }

  .home-search-form {
    max-width: 720px;
  }

  .home-query-row {
    max-width: 720px;
    overflow: visible;
    flex-wrap: wrap;
  }

  .home-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
  }

  .home-stat {
    min-height: 116px;
    padding: 20px;
  }

  .home-stat strong {
    font-size: 1.85rem;
  }

  .home-section {
    margin-bottom: 0;
  }

  .home-section-head {
    margin-bottom: 14px;
  }

  .home-feature-card {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: 22px;
    padding: 18px;
  }

  .home-feature-image,
  .home-feature-image img {
    min-height: 300px;
  }

  .home-feature-copy {
    padding: 20px 14px;
  }

  .home-feature-headword {
    font-size: clamp(2.4rem, 4vw, 4.8rem);
  }

  .topic-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    padding-bottom: 0;
  }

  .topic-mini-card {
    min-width: 0;
    max-width: none;
    min-height: 170px;
  }

  .home-note {
    margin: 0;
    padding: 18px 20px;
  }

  .search-view {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .search-header-sticky {
    position: sticky !important;
    top: 96px !important;
    padding: 18px;
    margin: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(150%) blur(18px);
    -webkit-backdrop-filter: saturate(150%) blur(18px);
    box-shadow: var(--paper-shadow);
  }

  .search-input-wrapper {
    flex-direction: column;
  }

  #search-field-select,
  .search-input-wrapper input,
  .search-input-wrapper button {
    width: 100%;
    margin-right: 0 !important;
  }

  .search-input-wrapper input,
  .search-input-wrapper button {
    min-height: 44px;
  }

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

  .result-card {
    min-height: 190px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
  }

  .result-spanish {
    margin-top: 8px;
  }

  .result-meta-bottom {
    margin-top: auto;
  }

  .pagination-controls {
    grid-column: 2;
  }

  .search-empty-state,
  .loading-panel,
  .error-panel {
    grid-column: 1 / -1;
  }

  .cards-view {
    display: grid;
    grid-template-columns: minmax(430px, 520px) minmax(0, 1fr);
    gap: 28px 36px;
    align-items: start;
  }

  .cards-view.cards-view-no-recent,
  .cards-view:has(.recent-cards-section[hidden]) {
    grid-template-columns: minmax(430px, 560px);
    justify-content: center;
  }

  .cards-view-header,
  #word-card-deck-container,
  .draw-hint {
    grid-column: 1;
  }

  .cards-view-header h2 {
    text-align: left;
    margin-top: 0;
  }

  .word-card-deck {
    max-width: none;
  }

  .word-card-wrapper {
    height: min(680px, calc(100dvh - 210px));
    min-height: 560px;
  }

  .draw-hint {
    text-align: left;
  }

  .recent-cards-section {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin-top: 0;
    padding: 18px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
  }

  #recent-cards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    overflow: visible;
    padding-bottom: 0;
  }

  .recent-mini-card,
  .recent-mini-card:visited,
  .recent-mini-card:hover,
  .recent-mini-card:active {
    width: 100%;
    min-width: 0;
    height: 116px;
  }

  .topic-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .topic-card {
    min-height: 280px;
  }

  .topic-detail-view {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px 24px;
    align-items: start;
  }

  .topic-detail-view > .back-link,
  .topic-hero-banner,
  .topic-intro-markdown {
    grid-column: 1 / -1;
  }

  .topic-detail-header,
  .topic-tools,
  .topic-filter-row {
    grid-column: 1;
  }

  .topic-detail-header {
    position: sticky;
    top: 96px;
  }

  .topic-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .topic-filter-row {
    flex-wrap: wrap;
    overflow: visible;
  }

  .topic-items {
    grid-column: 2;
    grid-row: 4 / span 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .topic-load-row {
    grid-column: 2;
  }

  .topic-item {
    margin-bottom: 0;
  }

  .detail-overlay {
    padding: 96px 32px 48px;
    background: rgba(244, 246, 248, 0.88);
  }

  .detail-overlay-content {
    width: min(1120px, 100%);
    min-height: auto;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 18px 24px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
  }

  .detail-back-button {
    grid-column: 1 / -1;
  }

  .entry-header,
  .field-grid {
    grid-column: 1;
    margin-bottom: 0;
  }

  .manuscript-section {
    grid-column: 2;
    grid-row: 2 / span 2;
    margin-bottom: 0;
  }

  .manuscript-evidence-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .back-to-top {
    display: flex !important;
    bottom: 28px;
    right: 28px;
  }
}

@media (min-width: 1320px) {
  .app-content,
  .bottom-nav {
    width: min(1280px, calc(100% - 64px));
  }

  .results-container,
  .topic-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
