body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--hvn-bg-alt);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--hvn-surface);
  border-bottom: 1px solid var(--hvn-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 700 18px var(--hvn-font-heading);
}

.brand img {
  border-radius: 6px;
}

.sync-button {
  min-height: 44px;
  font-size: 14px;
}

.sync-button[data-busy='true'] .qev-icon {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.app {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.welcome {
  background: var(--hvn-surface);
  border-top: 4px solid var(--hvn-red);
  border-radius: var(--hvn-radius);
  padding: 24px 20px;
  margin-top: 8px;
}

.welcome h1 {
  font-size: 26px;
}

.big {
  min-height: 52px;
  font-size: 17px;
  padding: 12px 20px;
}

.welcome .big {
  width: 100%;
  margin: 8px 0 12px;
}

.sync-status {
  font-size: 14px;
  color: var(--hvn-muted);
  margin: 0 0 12px;
}

.sync-status[data-kind='error'] {
  color: var(--hvn-text);
  background: var(--hvn-warning-bg);
  border-left: 3px solid var(--hvn-warning);
  padding: 8px 12px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--hvn-surface);
  border: 1px solid var(--hvn-border);
  border-radius: var(--hvn-radius);
  padding: 4px;
  margin-bottom: 16px;
}

.tabs button {
  border: none;
  min-height: 44px;
  color: var(--hvn-muted);
}

.tabs button[aria-selected='true'] {
  background: var(--hvn-red-light);
  color: var(--hvn-link);
}

.flashcard,
.message {
  background: var(--hvn-surface);
  border: 1px solid var(--hvn-border);
  border-top: 4px solid var(--hvn-red);
  border-radius: var(--hvn-radius);
  padding: 24px 20px;
}

.flashcard {
  min-height: 260px;
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.flashcard.dragging {
  transition: none;
}

.flashcard[data-swipe='remember'] {
  box-shadow: 0 0 0 3px var(--hvn-success);
}

.flashcard[data-swipe='forgot'] {
  box-shadow: 0 0 0 3px var(--hvn-primary);
}

.direction {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--hvn-muted);
  margin-bottom: 12px;
}

.front {
  font: 700 30px var(--hvn-font-heading);
  overflow-wrap: anywhere;
}

.front-sub,
.back-sub {
  color: var(--hvn-muted);
  margin-top: 4px;
}

.front-sub:empty,
.back-sub:empty {
  display: none;
}

.back {
  border-top: 1px dashed var(--hvn-border);
  margin-top: 16px;
  padding-top: 16px;
}

.back-main {
  font-size: 21px;
  font-weight: 500;
}

.example {
  background: var(--hvn-bg-alt);
  border-left: 3px solid var(--hvn-red);
  padding: 8px 12px;
  margin-top: 12px;
}

.hint {
  text-align: center;
  font-size: 13px;
  color: var(--hvn-muted);
  margin: 16px 0 0;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

#search {
  width: 100%;
  min-height: 44px;
}

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

.word-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  background: var(--hvn-surface);
  border: 1px solid var(--hvn-border);
  border-radius: var(--hvn-radius);
  padding: 12px 14px;
}

.word-item .word {
  font-weight: 700;
}

.word-item .meta,
.word-item .level {
  font-size: 13px;
  color: var(--hvn-muted);
}

.word-item .meaning {
  grid-column: 1;
}

.speak {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.app-footer {
  text-align: center;
  font-size: 13px;
  color: var(--hvn-muted);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.app-footer p {
  margin: 4px 0;
}

.account {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

button.link {
  border: none;
  min-height: 44px;
  padding: 0 8px;
  font-size: 13px;
}

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