/* AnkiWords screens on m4 tokens. Tabbar отсутствует в DS — добавляем по тем же правилам. */

:root {
  --aw-phone: 430px;
  --tabbar-height: 56px;
}

html,
body {
  min-height: 100%;
}

.aw-shell {
  max-width: var(--aw-phone);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-primary);
  box-shadow: 0 0 0 0.5px var(--separator);
}

.aw-main {
  width: 100%;
  max-width: none;
  padding: 16px 16px calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + 24px);
}

.aw-hero {
  padding: 24px 0 20px;
  max-width: none;
}

.aw-hero-actions,
.aw-dict-actions {
  justify-content: center;
  margin-top: 16px;
}

.aw-filters {
  margin: 16px 0;
  overflow-x: auto;
}

.m4-tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--aw-phone);
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  z-index: 120;
}

.m4-tabbar__item {
  flex: 1;
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.m4-tabbar__item.is-active {
  color: var(--accent-blue);
}

.m4-tabbar__badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 28px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

/* Toast над tabbar, в ширине phone-shell */
.m4-toast-container {
  left: 50%;
  right: auto;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--aw-phone);
  align-items: stretch;
  padding: 0 16px;
  box-sizing: border-box;
}

.aw-deck {
  align-items: flex-start;
}

.aw-deck__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.aw-deck__icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.aw-session {
  position: fixed;
  inset: 0;
  max-width: var(--aw-phone);
  margin: 0 auto;
  background: var(--bg-primary);
  z-index: 150;
  display: flex;
  flex-direction: column;
}

/* display:flex иначе перебивает HTML hidden — чёрный экран поверх UI */
.aw-session[hidden],
.m4-overlay[hidden] {
  display: none !important;
}

.aw-session__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 8px;
  border-bottom: 0.5px solid var(--separator);
}

.aw-session__bar > div {
  flex: 1;
  text-align: center;
}

.aw-session__body {
  flex: 1;
  overflow: auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
}

.aw-session__actions {
  justify-content: center;
  margin-top: 12px;
}

.aw-flash {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 240px;
  cursor: pointer;
}

.aw-flash__word {
  font-family: var(--font-ui);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: center;
  line-height: 1.2;
  color: var(--text-primary);
}

.aw-flash__phonetic {
  text-align: center;
  margin-top: 8px;
  color: var(--text-secondary);
}

.aw-flash__hint {
  text-align: center;
  margin-top: 12px;
}

.aw-flash__def {
  margin-top: 16px;
}

.aw-flash__example {
  margin-top: 12px;
}

.aw-flash__notes {
  margin-top: 12px;
}

.aw-rate {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.aw-rate__btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 6px;
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-ui), transform var(--transition-ui);
}

.aw-rate__btn:active {
  transform: scale(0.95);
}

.aw-rate__btn small {
  opacity: 0.85;
  font-size: 11px;
  font-weight: 500;
}

.aw-rate__again {
  background: var(--tint-red);
  color: var(--accent-red);
}

.aw-rate__hard {
  background: var(--tint-orange);
  color: var(--accent-orange);
}

.aw-rate__good {
  background: var(--tint-blue);
  color: var(--accent-blue);
}

.aw-rate__easy {
  background: var(--tint-green);
  color: var(--accent-green);
}

.aw-done {
  text-align: center;
  padding-top: 48px;
}

.aw-done__mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--tint-green);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  animation: fadeSlideIn 0.45s var(--ease-spring) both;
}

.aw-done__cta {
  margin-top: 20px;
}

.aw-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.aw-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition-ui), box-shadow var(--transition-ui);
}

.aw-color.is-active {
  border-color: var(--accent-blue);
  box-shadow: var(--focus-ring);
}

.aw-shell.is-session .m4-nav,
.aw-shell.is-session .m4-tabbar,
.aw-shell.is-session .aw-main {
  display: none;
}

.m4-bar.is-today .m4-bar__fill {
  background: linear-gradient(180deg, var(--accent-green) 0%, rgba(48, 209, 88, 0.35) 100%);
}

.m4-bar.is-today .m4-bar__label {
  color: var(--accent-green);
  font-weight: 600;
}

.m4-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.aw-history {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.aw-history__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 0.5px solid var(--separator);
}

.aw-history__rating {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.aw-history__meta {
  font-size: 12px;
  color: var(--text-secondary);
}
