:root {
  color-scheme: light;
  --bg: #edf2f4;
  --ink: #111827;
  --muted: #657282;
  --panel: #ffffff;
  --line: #d8e0e7;
  --accent: #0f766e;
  --accent-2: #e0a100;
  --danger: #c2410c;
  --ok: #15803d;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(32, 58, 67, 0.10), transparent 280px),
    var(--bg);
}

.entry-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(32, 58, 67, 0.08), transparent 48%),
    var(--bg);
  animation: entryScreenOut 1.45s ease forwards;
}

.entry-content {
  display: grid;
  place-items: center;
  gap: 14px;
  color: #203a43;
  font-size: 24px;
  font-weight: 800;
  animation: entryContentIn 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.entry-content img {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  box-shadow: 0 18px 38px rgba(15, 118, 110, 0.25);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button:disabled {
  opacity: 1;
  cursor: wait;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(70px, calc(env(safe-area-inset-top) + 58px)) 14px 24px;
  animation: appShellIn 0.8s ease 0.28s both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 2px 18px;
}

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

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.25);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.status span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent-2);
}

.status.online span {
  background: var(--ok);
}

.panel,
.quiz-card,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

.result-panel:not(.hidden):not(.grading) {
  animation: resultAutoHide 3s forwards;
  overflow: hidden;
}

.result-panel.ai-review:not(.hidden):not(.grading) {
  animation-duration: 3s;
}

.result-panel.grading {
  animation: none;
  opacity: 1;
  max-height: 240px;
  overflow: hidden;
}

.hidden,
.result-panel.hidden {
  display: none !important;
}

@keyframes resultAutoHide {
  0%,
  88% {
    opacity: 1;
    max-height: 240px;
    margin-top: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  100% {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
  }
}

@keyframes entryScreenOut {
  0%,
  72% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes entryContentIn {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  45%,
  78% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(1.02);
  }
}

@keyframes appShellIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-panel {
  margin-top: 64px;
  padding: 28px;
}

.language-panel {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.language-actions {
  display: grid;
  width: min(420px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.language-actions button {
  min-height: 76px;
  border-color: rgba(15, 118, 110, 0.26);
  background: rgba(255, 255, 255, 0.88);
  color: #203a43;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

.language-actions button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.lock-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 14px;
  background: #203a43;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.auth-panel h2 {
  font-size: 24px;
  margin-bottom: 18px;
}

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

.login-form {
  display: flex;
  gap: 10px;
}

.login-form input,
.answer-form input,
.field-label input,
.field-label select,
.admin-search input,
.admin-secret-input-wrap input,
.study-goal-field input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  outline: none;
}

.login-form input,
.answer-form input,
.field-label input,
.field-label select {
  min-height: 48px;
  padding: 0 14px;
}

.field-label select {
  appearance: none;
}

textarea {
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  line-height: 1.7;
}

.workspace.hidden,
.auth-panel.hidden,
.view {
  display: none;
}

.view.active,
.workspace {
  display: block;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button {
  background: rgba(255, 255, 255, 0.72);
}

.tabs button.active {
  border-color: #203a43;
  background: #203a43;
  color: #fff;
}

.panel {
  padding: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px 130px;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-suggest-section {
  margin: 2px 0 14px;
  padding: 16px 0;
  border-top: 1px solid rgba(96, 196, 242, 0.18);
  border-bottom: 1px solid rgba(96, 196, 242, 0.18);
}

.ai-suggest-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ai-suggest-heading h3 {
  margin: 0;
  font-size: 16px;
}

.ai-suggest-heading span {
  color: #9edfff;
  font-size: 13px;
  font-weight: 700;
}

.ai-suggest-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 112px 132px 150px;
  align-items: end;
  gap: 10px;
}

.ai-search-field {
  grid-column: 1 / -1;
}

.ai-search-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ai-search-results button {
  min-height: 36px;
  padding: 6px 11px;
  border-color: rgba(95, 199, 250, 0.32);
  border-radius: 999px;
  background: rgba(21, 82, 115, 0.24);
}

.ai-suggest-button {
  min-height: 48px;
}

.ai-suggest-message {
  min-height: 20px;
  margin-top: 10px;
}

.ai-suggest-message.error {
  color: #ff9c8f;
}

.field-label {
  display: grid;
  gap: 6px;
}

.field-label span,
.meta-line {
  color: var(--muted);
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.action-row button {
  flex: 1;
}

.action-row.compact {
  margin-top: 10px;
  flex-wrap: wrap;
}

.action-row.compact button {
  flex: 1 1 100px;
}

.secondary-row button {
  min-height: 40px;
  color: #203a43;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.stats-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.stats-grid strong {
  display: block;
  font-size: 24px;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.study-panel {
  display: grid;
  gap: 22px;
}

.study-heading,
.study-section-heading,
.study-progress > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.study-heading h2,
.study-section-heading h3 {
  margin: 0;
}

.study-heading .meta-line {
  margin: 6px 0 0;
}

.study-goal-field {
  display: grid;
  flex: 0 0 auto;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.study-goal-field > span:last-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

.study-goal-field input {
  width: 76px;
  min-height: 40px;
  padding: 7px 9px;
}

.study-progress {
  display: grid;
  gap: 9px;
}

.study-progress span,
.study-section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.study-progress progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: rgba(108, 211, 255, 0.12);
}

.study-progress progress::-webkit-progress-bar {
  border-radius: 5px;
  background: rgba(108, 211, 255, 0.12);
}

.study-progress progress::-webkit-progress-value {
  border-radius: 5px;
  background: #54c7f4;
}

.study-progress progress::-moz-progress-bar {
  border-radius: 5px;
  background: #54c7f4;
}

.study-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.study-metrics div {
  padding: 18px 12px;
  text-align: center;
}

.study-metrics div + div {
  border-left: 1px solid var(--line);
}

.study-metrics strong,
.study-metrics span {
  display: block;
}

.study-metrics strong {
  color: var(--ink);
  font-size: 24px;
}

.study-metrics span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.study-section {
  display: grid;
  gap: 13px;
}

.study-week-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(36px, 1fr));
  gap: 8px;
  min-height: 160px;
  padding-top: 6px;
}

.study-day {
  display: grid;
  grid-template-rows: 20px 1fr 20px;
  gap: 5px;
  min-width: 0;
  text-align: center;
}

.study-day-count,
.study-day-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.study-day-track {
  position: relative;
  min-height: 108px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(108, 211, 255, 0.08);
}

.study-day-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: #3aaedf;
  box-shadow: 0 0 12px rgba(72, 192, 241, 0.18);
}

.study-day.is-empty .study-day-bar {
  min-height: 0;
}

.study-history {
  display: grid;
  border-top: 1px solid var(--line);
}

.study-history-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
}

.study-history-main,
.study-history-facts {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.study-history-main {
  justify-content: space-between;
}

.study-history-main strong {
  min-width: 0;
}

.study-history-main span,
.study-history-facts span {
  color: var(--muted);
  font-size: 12px;
}

.study-history-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, auto));
  text-align: right;
}

.study-history-facts .study-history-accuracy {
  color: #8fe1ff;
  font-weight: 700;
}

.study-empty {
  margin: 0;
  padding: 22px 0;
  color: var(--muted);
  text-align: center;
}

.quiz-card {
  padding: 16px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.word-display {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 16px;
  font-size: clamp(42px, 15vw, 86px);
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.word-primary {
  line-height: 1.04;
}

.word-reading {
  color: #8fdcff;
  font-size: 28px;
  font-weight: 650;
  line-height: 1.2;
  text-shadow: 0 0 18px rgba(80, 190, 240, 0.18);
}

.word-display.has-reading {
  padding-block: 24px;
}

.word-display.dictation-display {
  color: #203a43;
  font-size: clamp(36px, 11vw, 64px);
  letter-spacing: 0;
}

.word-display.dictation-display .word-reading {
  display: none;
}

.answer-form {
  display: flex;
  gap: 10px;
}

.answer-form button {
  flex: 0 0 104px;
}

.answer-validation {
  margin: 8px 2px 0;
  color: #ffb09f;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.answer-validation.hidden {
  display: none;
}

#answerInput.input-invalid {
  border-color: rgba(255, 122, 101, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 122, 101, 0.13);
}

.result-panel {
  margin-top: 12px;
  padding: 14px;
}

.result-title {
  font-weight: 800;
  font-size: 20px;
}

.result-title.ok {
  color: var(--ok);
}

.result-title.bad {
  color: var(--danger);
}

.result-gloss {
  margin-top: 8px;
  line-height: 1.55;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chips span {
  border: 1px solid #bfd4d1;
  border-radius: 999px;
  background: #eef9f7;
  color: #115e59;
  padding: 6px 10px;
  font-size: 13px;
}

.wrong-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.scope-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.scope-tabs button.active {
  border-color: #203a43;
  background: #203a43;
  color: #fff;
}

.meta-line {
  margin-top: 2px;
}

.wrong-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.wrong-item h3 {
  font-size: 18px;
}

.wrong-item p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.wrong-item strong {
  white-space: nowrap;
  color: var(--danger);
}

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

.achievement-head h2 {
  margin: 0;
  font-size: 20px;
}

.achievement-head .meta-line {
  margin: 5px 0 0;
}

.achievement-head > strong {
  color: #8fe1ff;
  font-size: 18px;
}

.achievement-panel {
  display: grid;
  gap: 16px;
}

.achievement-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.achievement-overview div {
  padding: 14px 10px;
  text-align: center;
}

.achievement-overview div + div {
  border-left: 1px solid var(--line);
}

.achievement-overview strong,
.achievement-overview span {
  display: block;
}

.achievement-overview strong {
  color: var(--ink);
  font-size: 22px;
}

.achievement-overview span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.achievement-total-progress,
.achievement-card-progress progress {
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: rgba(108, 211, 255, 0.12);
}

.achievement-total-progress {
  height: 9px;
}

.achievement-card-progress progress {
  height: 7px;
}

.achievement-total-progress::-webkit-progress-bar,
.achievement-card-progress progress::-webkit-progress-bar {
  border-radius: 4px;
  background: rgba(108, 211, 255, 0.12);
}

.achievement-total-progress::-webkit-progress-value,
.achievement-card-progress progress::-webkit-progress-value {
  border-radius: 4px;
  background: #45bce9;
}

.achievement-total-progress::-moz-progress-bar,
.achievement-card-progress progress::-moz-progress-bar {
  border-radius: 4px;
  background: #45bce9;
}

.achievement-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.achievement-filters button.active {
  border-color: #64cbf8;
  background: #113f59;
  color: #fff;
  box-shadow: inset 0 -2px 0 #6cd3ff;
}

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

.achievement-item {
  display: flex;
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  background: #fbfdff;
  flex-direction: column;
}

.achievement-item.unlocked {
  border-color: rgba(15, 118, 110, 0.38);
  background: #eef9f7;
}

.achievement-item h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 17px;
}

.achievement-item.tier-bronze { border-left-color: #6aa9c8; }
.achievement-item.tier-silver { border-left-color: #b7cbd6; }
.achievement-item.tier-gold { border-left-color: #d9b64f; }
.achievement-item.tier-platinum { border-left-color: #74e1d0; }

.achievement-item p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.achievement-item span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.achievement-tier {
  color: #8bbdd3 !important;
  font-size: 11px !important;
}

.achievement-card-progress {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding-top: 16px;
}

.achievement-card-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.achievement-card-progress span {
  color: var(--muted);
  font-size: 11px;
}

.achievement-status {
  margin-top: 9px !important;
  font-size: 11px;
}

.achievement-item.unlocked .achievement-status {
  color: #79dfaa;
}

.achievement-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 30px 0;
  color: var(--muted);
  text-align: center;
}

.achievement-toast {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12000;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 16px;
  border: 1px solid rgba(103, 213, 255, 0.54);
  border-radius: 7px;
  background: rgba(4, 18, 31, 0.96);
  color: #eaf9ff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38), 0 0 18px rgba(66, 184, 235, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.achievement-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.achievement-toast.is-leaving {
  opacity: 0;
  transform: translateY(5px);
}

.error {
  min-height: 24px;
  margin-top: 10px;
  color: var(--danger);
}

@media (max-width: 560px) {
  .login-form,
  .answer-form {
    flex-direction: column;
    align-items: stretch;
  }

  .answer-form button {
    flex-basis: auto;
  }

  .language-actions {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .tabs button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .achievement-head { align-items: flex-start; }
  .achievement-head > strong { font-size: 15px; }
  .achievement-toast {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    max-width: none;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .ai-suggest-grid {
    grid-template-columns: 1fr;
  }

  .ai-suggest-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-screen {
    display: none;
  }

  .app-shell,
  .entry-content,
  .result-panel:not(.hidden):not(.grading),
  .result-panel.ai-review:not(.hidden):not(.grading) {
    animation: none;
  }

  .achievement-toast {
    transition: none;
  }
}

.module-picker,
.tools-panel,
.share-viewer {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: calc(92px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.module-picker {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 34px;
}

.module-picker.hidden {
  display: none;
}

.module-picker .project-brand {
  grid-template-columns: 96px minmax(0, 1fr);
  justify-items: start;
  text-align: left;
}

.module-picker .project-brand img {
  width: 96px;
  height: 96px;
}

.module-picker .project-brand h1,
.tools-header h1,
.share-viewer h1 {
  margin: 3px 0 5px;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

#moduleMembershipStatus,
.tools-header p:last-child {
  margin: 0;
  color: #9eb2c7;
}

.module-access-message {
  max-width: 44rem;
  margin: 0.7rem 0 0;
  color: #ffd18c;
  line-height: 1.55;
}

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

.module-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  min-height: 184px;
  padding: 26px;
  text-align: left;
  border-color: rgba(96, 187, 238, 0.32);
  background: rgba(8, 21, 37, 0.86);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.module-card:hover,
.module-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(111, 212, 255, 0.72);
  box-shadow: 0 20px 46px rgba(4, 91, 145, 0.22);
}

.module-card:active {
  transform: scale(0.99);
}

.module-card > span:nth-child(2) {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.module-card strong {
  font-size: 25px;
  color: #edf8ff;
}

.module-card small {
  line-height: 1.55;
  color: #9db2c6;
}

.module-card em {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 4px 8px;
  border: 1px solid rgba(126, 216, 255, 0.4);
  border-radius: 5px;
  color: #9bddff;
  font-size: 12px;
  font-style: normal;
}

.module-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(126, 216, 255, 0.55);
  border-radius: 8px;
  color: #c8efff;
  background: #102b40;
  font-size: 24px;
  font-weight: 800;
}

.picker-back {
  justify-self: center;
}

.tools-panel {
  min-height: 100vh;
}

.tools-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(105, 174, 219, 0.24);
}

.tools-dashboard {
  padding-top: 24px;
}

.tool-search {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.tool-search span,
.tool-form label > span {
  color: #a8bbce;
  font-size: 13px;
}

.tool-search input {
  min-height: 54px;
  width: 100%;
}

.local-processing-note {
  margin: 10px 0 24px;
  color: #87a6bc;
}

.tool-category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 30px;
}

.tool-category-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  min-height: 142px;
  padding: 16px;
  text-align: left;
  border-color: rgba(101, 168, 210, 0.28);
  background: rgba(8, 20, 35, 0.78);
}

.tool-category-card.active,
.tool-category-card:hover {
  border-color: #4f9ccc;
  background: rgba(15, 47, 72, 0.86);
}

.tool-category-card > span:last-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tool-category-card strong,
.tool-card strong {
  color: #e9f6ff;
}

.tool-category-card small,
.tool-category-card em,
.tool-card small {
  color: #8fa9bd;
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.tool-category-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #376b8e;
  border-radius: 6px;
  color: #aee6ff;
  font-weight: 800;
}

.tool-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.tool-section-title h2 {
  margin: 0;
  font-size: 19px;
}

.tool-section-title span {
  color: #8fa9bd;
}

.tool-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-chip-list button {
  min-height: 36px;
  padding: 0 12px;
}

.tool-catalog {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tool-card {
  position: relative;
  min-height: 148px;
  border: 1px solid rgba(101, 168, 210, 0.24);
  border-radius: 8px;
  background: rgba(7, 18, 31, 0.72);
}

.tool-open {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto minmax(38px, auto) auto;
  gap: 4px 9px;
  width: 100%;
  min-height: 146px;
  padding: 16px 42px 16px 14px;
  text-align: left;
  border: 0;
  background: transparent;
}

.tool-open > span {
  grid-row: 1 / 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #356b8c;
  border-radius: 5px;
  color: #9bddff;
  font-weight: 800;
}

.tool-open small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-open em {
  color: #6f91aa;
  font-size: 11px;
  font-style: normal;
}

.tool-card:hover {
  border-color: rgba(111, 212, 255, 0.65);
}

.tool-card-favorite {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  color: #8ba4b8;
  background: transparent;
  font-size: 20px;
}

.tool-card-favorite.active {
  color: #ffd66e;
}

.tool-empty {
  grid-column: 1 / -1;
  color: #8fa9bd;
}

.tool-workbench {
  padding: 24px 0 40px;
}

.tool-workbench > header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(105, 174, 219, 0.24);
}

.tool-workbench > header p,
.tool-workbench > header h2 {
  margin: 0;
}

.tool-workbench > header p {
  color: #8fa9bd;
  font-size: 12px;
}

#toolWorkbenchDescription {
  max-width: 720px;
  margin-top: 5px;
  line-height: 1.5;
}

.tool-workbench > header h2 {
  margin-top: 3px;
  font-size: 23px;
}

.tool-workbench-actions {
  display: flex;
  gap: 8px;
}

.tool-form {
  display: grid;
  gap: 16px;
  padding-top: 22px;
}

.tool-form label {
  display: grid;
  gap: 7px;
}

.tool-form textarea {
  min-height: 170px;
  resize: vertical;
}

.text-tool-form > label:first-child textarea {
  min-height: 260px;
}

.tool-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tool-options .tool-wide,
.tool-wide {
  grid-column: 1 / -1;
}

.tool-command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.tool-config-box {
  padding-top: 18px;
  border-top: 1px solid rgba(105, 174, 219, 0.2);
}

.tool-config-box > div:first-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.saved-config-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.saved-config-list > span {
  display: inline-flex;
}

.saved-config-list > span button {
  min-height: 34px;
  border-radius: 0;
}

.saved-config-list > span button:first-child {
  border-radius: 6px 0 0 6px;
}

.saved-config-list > span button:last-child {
  width: 34px;
  padding: 0;
  border-radius: 0 6px 6px 0;
}

.random-result,
.file-result,
.share-output {
  display: block;
  min-height: 112px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(101, 168, 210, 0.3);
  border-radius: 8px;
  color: #dff5ff;
  background: #030b15;
}

.file-drop {
  min-height: 116px;
  place-content: center;
  padding: 18px;
  text-align: center;
  border: 1px dashed #3f7ba2;
  border-radius: 8px;
  background: rgba(8, 28, 45, 0.64);
}

.file-drop input {
  max-width: 100%;
}

.image-preview {
  display: grid;
  place-items: center;
  min-height: 80px;
}

.image-preview canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid rgba(101, 168, 210, 0.3);
}

.temporary-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.temporary-result code {
  overflow-wrap: anywhere;
  color: #b9e8ff;
}

.temporary-qr-output {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: 8px;
}

.temporary-qr-output img {
  width: min(260px, 100%);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
}

.temporary-qr-output a {
  color: #9bddff;
}


.upload-progress {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 30px;
}

.upload-progress progress {
  width: 100%;
  height: 10px;
  accent-color: #69c9ff;
}

.upload-progress span,
.room-sync-status {
  color: #9bb5c8;
  font-size: 13px;
}

.room-sync-status {
  margin: 2px 0 10px;
}

.room-sync-status.error {
  color: #ff9b7d;
}

.room-messages {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.room-messages article {
  padding: 12px;
  border-left: 2px solid #3b84b3;
  background: rgba(7, 18, 31, 0.72);
}

.room-messages strong,
.room-messages time {
  margin-right: 10px;
}

.room-messages time {
  color: #819bb0;
  font-size: 12px;
}

.room-messages p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.room-messages .room-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed rgba(101, 168, 210, 0.28);
  color: #819bb0;
  text-align: center;
}

.share-viewer {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.share-viewer.hidden {
  display: none;
}

.share-viewer-panel {
  width: min(760px, 100%);
  padding: 26px;
  border: 1px solid rgba(101, 168, 210, 0.35);
  border-radius: 8px;
  background: rgba(7, 18, 31, 0.96);
}

.share-viewer-panel textarea {
  min-height: 100px;
}

.membership-warning {
  padding: 12px;
  border-left: 3px solid #e5b34d;
  color: #f1d28e;
  background: rgba(107, 75, 13, 0.18);
}

.payment-order {
  padding: 14px;
  border: 1px solid rgba(101, 168, 210, 0.3);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.78);
}

.payment-order dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 9px 12px;
  margin: 0;
}

.payment-order dt {
  color: #8fa9bd;
}

.payment-order dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.payment-order button {
  min-height: 30px;
  padding: 0 8px;
}

.payment-method-field {
  min-width: 0;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid rgba(101, 207, 255, 0.24);
  border-radius: 8px;
}

.payment-method-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.payment-method-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.payment-method-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(101, 207, 255, 0.22);
  border-radius: 7px;
  cursor: pointer;
}

.payment-method-list label:has(input:checked) {
  border-color: rgba(128, 225, 255, 0.82);
  background: rgba(30, 116, 163, 0.24);
}

.payment-method-list input {
  width: auto;
  min-width: 18px;
  margin: 0;
}

.payment-qr-wrap {
  width: min(440px, 100%);
  margin: 16px auto 0;
  padding: 12px;
  overflow: hidden;
  border-radius: 10px;
  color: #1c2730;
  text-align: center;
  background: #fff;
}

.payment-qr-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  margin: 8px auto;
}

.payment-qr-wrap .meta-line {
  color: #586a77;
}

.payment-review-note {
  color: #f1d28e;
}

.plan-option:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.admin-current-memberships {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.admin-current-memberships > div,
.admin-current-memberships > article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid rgba(101, 168, 210, 0.25);
  border-radius: 6px;
}

.admin-current-memberships > article {
  grid-template-areas:
    "name expiry"
    "meta meta";
  align-items: center;
}

.admin-current-memberships > article strong { grid-area: name; min-width: 0; }
.admin-current-memberships > article span { grid-area: expiry; color: #b8cfdd; white-space: nowrap; }
.admin-current-memberships > article small { grid-area: meta; color: #86a9bb; }

.wrong-action-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: #9be7c4;
  line-height: 1.55;
}

.wrong-action-message.is-error { color: var(--danger); }

.admin-entitlement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-checkbox {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.admin-checkbox input {
  width: 18px;
  height: 18px;
}

@media (max-width: 980px) {
  .tool-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .module-picker,
  .tools-panel,
  .share-viewer {
    padding-top: calc(116px + env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .module-picker {
    align-content: start;
  }

  .module-picker .project-brand {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .module-picker .project-brand img {
    width: 72px;
    height: 72px;
  }

  .module-grid,
  .tool-category-grid,
  .tool-catalog,
  .tool-options {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: 150px;
  }

  .tools-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tools-header .action-row {
    width: 100%;
  }

  .tools-header .action-row button {
    flex: 1;
  }

  .tool-workbench > header {
    grid-template-columns: 1fr;
  }

  .tool-workbench-actions {
    width: 100%;
  }

  .tool-workbench-actions button {
    flex: 1;
  }

  .temporary-result,
  .payment-order dl {
    grid-template-columns: 1fr;
  }

  .tool-config-box > div:first-child {
    grid-template-columns: 1fr;
  }
}

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

.word-quality-hint {
  min-height: 20px;
  color: #91d8fa;
}

.word-quality-hint.has-warning {
  color: #ffd08a;
}

.wrong-search {
  display: block;
  margin: 10px 0 12px;
}

.wrong-search input {
  width: 100%;
  min-height: 44px;
}

.wrong-item > div:first-child {
  min-width: 0;
}

.wrong-item-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.wrong-item-actions button {
  min-height: 36px;
  padding: 6px 12px;
}

@media (max-width: 640px) {
  .wrong-item {
    align-items: stretch;
    flex-direction: column;
  }

  .wrong-item-actions {
    align-items: center;
    flex-direction: row;
  }
}

/* Account, membership and administration */
.account-bar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: calc(100vw - 28px);
}

.account-bar button,
.account-badge {
  min-height: 38px;
  border-color: rgba(94, 199, 255, 0.34);
  background: rgba(4, 15, 27, 0.88);
  color: #dff6ff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

.account-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(94, 199, 255, 0.24);
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.auth-panel,
.admin-panel,
.view.active {
  animation: accountPageIn 240ms ease-out both;
}

.auth-tabs,
.admin-tabs {
  display: flex;
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  border: 1px solid rgba(94, 199, 255, 0.18);
  border-radius: 7px;
  background: rgba(2, 10, 19, 0.56);
}

.auth-tabs button,
.admin-tabs button {
  flex: 1;
  border-color: transparent;
  background: transparent;
}

.auth-tabs button.active,
.admin-tabs button.active {
  border-color: rgba(108, 214, 255, 0.45);
  background: rgba(53, 157, 211, 0.16);
  color: #effbff;
}

.login-form,
.stack-form {
  display: grid;
  gap: 10px;
}

.login-form input,
.stack-form input {
  width: 100%;
}

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

.secret-input-row input { min-width: 0; }
.secret-input-row button {
  min-width: 76px;
  white-space: nowrap;
}

.account-secret-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr);
  gap: 10px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding:
    max(18px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  overflow-y: auto;
  background: rgba(0, 5, 12, 0.76);
  backdrop-filter: blur(9px);
  animation: modalBackdropIn 200ms ease-out both;
}

.modal-layer.is-closing {
  pointer-events: none;
  animation: modalBackdropOut 180ms ease-out both;
}

.modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  padding: 26px;
  border: 1px solid rgba(101, 207, 255, 0.32);
  border-radius: 8px;
  background: rgba(5, 17, 30, 0.97);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52), 0 0 32px rgba(50, 175, 235, 0.1);
  animation: modalPanelIn 220ms ease-out both;
}

.modal-layer.is-closing .modal-panel {
  animation: modalPanelOut 180ms ease-out both;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 25px;
}

.membership-panel {
  width: min(780px, 100%);
}

.membership-goal-field {
  min-width: 0;
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid rgba(101, 207, 255, 0.24);
  border-radius: 8px;
}

.membership-goal-field legend {
  padding: 0 6px;
  font-weight: 700;
}

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

.membership-goal-option {
  min-height: 86px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 5px;
  text-align: left;
}

.membership-goal-option small,
.membership-goal-hint {
  color: var(--muted);
}

.membership-goal-hint {
  margin: 10px 0 0;
  font-size: 13px;
}

.membership-plan-step {
  margin-top: 18px;
}

.membership-step-title {
  margin: 0;
  font-size: 16px;
}

.section-kicker {
  margin: 0 0 8px;
  color: #75d3ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.plan-loading,
.load-recovery {
  grid-column: 1 / -1;
  margin: 20px 0;
  padding: 18px;
  border: 1px dashed rgba(95, 199, 250, 0.32);
  border-radius: 7px;
  color: var(--muted);
  text-align: center;
  background: rgba(4, 17, 29, 0.66);
}

.load-recovery p {
  margin: 0 0 12px;
}

.plan-option {
  min-height: 132px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 7px;
  text-align: left;
  border-color: rgba(95, 199, 250, 0.25);
  background: rgba(6, 25, 42, 0.78);
}

.plan-option.selected {
  border-color: rgba(128, 225, 255, 0.82);
  background: rgba(30, 116, 163, 0.24);
  box-shadow: 0 0 22px rgba(72, 193, 245, 0.14);
}

.plan-option span { color: #dff7ff; }
.plan-option small { color: var(--muted); }

.purchase-summary,
.danger-note,
.danger-zone {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(101, 207, 255, 0.18);
  border-radius: 7px;
  background: rgba(2, 10, 18, 0.5);
}

.danger-note,
.danger-zone {
  border-color: rgba(255, 123, 104, 0.32);
  color: #ffd7d0;
  background: rgba(110, 34, 27, 0.18);
}

.danger-button,
.danger-zone button {
  border-color: rgba(255, 117, 99, 0.48);
  color: #ffd9d3;
  background: rgba(132, 40, 31, 0.28);
}

.account-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 18px 0;
}

.account-details dt { color: var(--muted); }
.account-details dd { margin: 0; overflow-wrap: anywhere; }

.admin-panel {
  width: min(1180px, 100%);
  margin: 70px auto 0;
  padding-bottom: 40px;
}

.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.admin-header h1 { margin: 0; }
.admin-view { display: none; }
.admin-view.active { display: block; animation: accountPageIn 220ms ease-out both; }

.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.admin-search {
  display: grid;
  flex: 1 1 420px;
  max-width: 560px;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.admin-search input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
}

.admin-toolbar > p {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.admin-empty-state {
  margin: 0;
  padding: 28px 16px;
  border: 1px dashed rgba(92, 195, 242, 0.28);
  color: var(--muted);
  text-align: center;
}

.admin-login-card .login-success { color: #8ce8bc; }
.admin-login-card .login-failed { color: #ff9c8f; }
.admin-login-card p { overflow-wrap: anywhere; }
.admin-login-location { color: #d7f3ff; }
.admin-login-agent {
  color: var(--muted);
  font-size: 12px;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.05fr) minmax(260px, 1.35fr) minmax(230px, 1.2fr) auto;
  align-items: center;
  gap: 14px;
  padding: 15px;
  border: 1px solid rgba(92, 195, 242, 0.2);
  border-radius: 7px;
  background: rgba(5, 20, 34, 0.82);
}

.admin-user-card p,
.admin-user-card h3 { margin: 3px 0; }
.admin-user-card .action-row { justify-content: flex-end; }
.admin-user-identity,
.admin-user-facts,
.admin-user-security { min-width: 0; }
.admin-user-id,
.admin-last-login {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.admin-user-facts p,
.admin-user-security > p,
.admin-request-status {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}
.admin-user-facts span,
.admin-field-name,
.admin-request-status span { color: var(--muted); font-size: 12px; }
.admin-user-facts strong,
.admin-request-status strong { color: #e9f8ff; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.admin-user-actions button { min-width: 72px; }
.secret-value { font-family: Consolas, monospace; overflow-wrap: anywhere; }
.account-state-bad { color: #ff9c8f; }
.account-state-good { color: #8ce8bc; }
.admin-editor {
  width: min(720px, 100%);
  padding: 30px;
}

.admin-editor > h2 {
  margin: 0 48px 4px 0;
  font-size: 24px;
}

.admin-editor-subtitle {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
}

.admin-editor-section {
  padding: 20px 0;
  border-top: 1px solid rgba(96, 196, 242, 0.18);
}

.admin-editor-section h3 {
  margin: 0 0 14px;
  color: #dff7ff;
  font-size: 16px;
}

.admin-membership-grid,
.admin-date-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-date-grid { margin-top: 14px; }

.admin-editor .field-label input,
.admin-editor .field-label select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
}

.admin-date-help {
  margin-top: 12px;
  color: #86a9bb;
  font-size: 13px;
  line-height: 1.7;
}

.admin-editor-save {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.admin-editor-save button { min-width: 168px; }

.admin-secret-control {
  display: grid;
  gap: 12px;
}

.admin-secret-field > label {
  color: var(--muted);
  font-size: 13px;
}

.admin-secret-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-secret-input-wrap input { min-width: 0; }
.admin-secret-input-wrap button {
  min-width: 76px;
  white-space: nowrap;
}

.admin-secret-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 10px;
}

.admin-secret-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(102, 210, 255, 0.36);
  border-radius: 8px;
  background: rgba(20, 80, 112, 0.16);
}

.admin-secret-result > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-secret-result span {
  color: #9ebccc;
  font-size: 12px;
}

.admin-secret-result code {
  color: #e9f8ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  overflow-wrap: anywhere;
  user-select: all;
}

.admin-secret-result button { white-space: nowrap; }

.admin-danger-section h3 { color: #ffd5ce; }

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

.field-disabled {
  opacity: 1;
}

.field-disabled input,
.field-disabled select { cursor: not-allowed; }

.confirm-panel { width: min(460px, 100%); }

.round-summary-panel {
  width: min(660px, 100%);
}

.round-summary-panel h2 {
  margin: 2px 0 6px;
}

.round-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.round-summary-grid div {
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(8, 24, 40, 0.72);
  text-align: center;
}

.round-summary-grid strong,
.round-summary-grid span {
  display: block;
}

.round-summary-grid div:last-child strong {
  font-size: 18px;
}

.round-summary-grid strong {
  color: #f3fbff;
  font-size: 26px;
}

.round-summary-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.round-accuracy {
  margin: 16px 0 0;
  color: #bdefff;
  font-weight: 700;
  text-align: center;
}

.round-summary-actions {
  margin-top: 22px;
}

.limit-exceeded {
  border-color: rgba(255, 137, 96, 0.65) !important;
  box-shadow: 0 0 0 2px rgba(255, 111, 77, 0.12);
}

button:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(1.08);
}

@keyframes accountPageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modalBackdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalBackdropOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalPanelIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalPanelOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(5px) scale(0.99); }
}

@media (max-width: 760px) {
  .account-bar {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    overflow: visible;
    justify-content: stretch;
    gap: 4px;
  }

  .account-bar button {
    flex: 1 1 52px;
    min-width: 48px;
    min-height: 44px;
    padding: 0 5px;
    font-size: 11px;
    white-space: nowrap;
  }

  .account-badge {
    display: inline-flex;
    flex: 0 1 78px;
    min-width: 52px;
    min-height: 44px;
    max-width: 78px;
    padding: 0 7px;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .plan-grid,
  .membership-goal-list { grid-template-columns: 1fr; }
  .plan-option { min-height: 104px; }
  .admin-panel { margin-top: 64px; }
  .admin-header { align-items: start; flex-direction: column; }
  .admin-toolbar { align-items: stretch; flex-direction: column; gap: 6px; }
  .admin-search { flex-basis: auto; max-width: none; }
  .admin-toolbar > p { margin: 0; }
  .admin-user-card { grid-template-columns: 1fr; }
  .admin-user-card .action-row { justify-content: flex-start; }
  .admin-user-facts p,
  .admin-user-security > p,
  .admin-request-status { grid-template-columns: 74px minmax(0, 1fr); }
  .admin-user-actions button { min-width: 112px; }
  .account-details { grid-template-columns: 1fr; gap: 3px; }
  .account-details dd { margin-bottom: 8px; }
  .payment-method-list { grid-template-columns: 1fr; }
  .admin-editor { padding: 24px 18px; }
  .admin-membership-grid,
  .admin-date-grid,
  .admin-secret-actions,
  .admin-secret-result,
  .admin-danger-actions { grid-template-columns: 1fr; }
  .admin-secret-input-wrap { grid-template-columns: minmax(0, 1fr) auto; }
  .admin-current-memberships > article {
    grid-template-columns: 1fr;
    grid-template-areas: "name" "expiry" "meta";
  }
  .admin-current-memberships > article span { white-space: normal; }
  .admin-editor-save button,
  .admin-secret-actions button,
  .admin-secret-result button { width: 100%; }
  .account-secret-actions { grid-template-columns: 1fr; }

  .study-heading { align-items: stretch; flex-direction: column; }
  .study-goal-field { align-self: flex-start; }
  .study-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-metrics div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .study-metrics div:nth-child(4) { border-top: 1px solid var(--line); }
  .study-history-row { grid-template-columns: 1fr; gap: 8px; }
  .study-history-facts { grid-template-columns: repeat(3, 1fr); text-align: left; }
  .study-history-facts span:nth-child(2) { text-align: center; }
  .study-history-facts span:last-child { text-align: right; }
  .study-actions { display: grid; grid-template-columns: 1fr; }
  .round-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .round-summary-grid div:last-child { grid-column: 1 / -1; }
  .round-summary-actions { display: grid; grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-panel,
  .admin-panel,
  .admin-view.active,
  .view.active,
  .modal-layer,
  .modal-panel,
  .modal-layer.is-closing,
  .modal-layer.is-closing .modal-panel {
    animation: none;
  }
}

/* WYJ brand refresh and project shell */
:root {
  color-scheme: dark;
  --bg: #050a12;
  --ink: #edf7ff;
  --muted: #91a8ba;
  --panel: rgba(9, 20, 34, 0.9);
  --line: rgba(119, 203, 255, 0.22);
  --accent: #55c7ff;
  --accent-strong: #198fca;
  --accent-2: #e2b93d;
  --danger: #ff8069;
  --ok: #5bdd9a;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #050a12;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background: #050a12;
}

.entry-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  isolation: isolate;
  background: transparent;
  animation: splashBackdropIn 420ms ease-out both;
}

.entry-screen.is-hidden {
  display: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.splash-door {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: calc(50% + 1px);
  overflow: hidden;
  background: #030b16;
  transition: transform 1.15s cubic-bezier(0.72, 0, 0.18, 1);
  backface-visibility: hidden;
  will-change: transform;
}

.splash-door-left {
  left: 0;
  transform-origin: left center;
}

.splash-door-right {
  right: 0;
  transform-origin: right center;
}

.splash-door-scene {
  position: absolute;
  top: 0;
  width: 100vw;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 48%, #0a1c30 0%, #030b16 48%, #01050b 100%);
}

.splash-door-left .splash-door-scene {
  left: 0;
}

.splash-door-right .splash-door-scene {
  right: 0;
}

.splash-art {
  width: min(82vmin, 720px);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  display: block;
  animation: splashImageIn 2s cubic-bezier(0.2, 0.75, 0.2, 1) both;
  -webkit-mask-image: radial-gradient(
    ellipse 50% 50% at center,
    #000 0%,
    #000 64%,
    rgba(0, 0, 0, 0.96) 72%,
    rgba(0, 0, 0, 0.58) 82%,
    rgba(0, 0, 0, 0.18) 88%,
    transparent 94%
  );
  mask-image: radial-gradient(
    ellipse 50% 50% at center,
    #000 0%,
    #000 64%,
    rgba(0, 0, 0, 0.96) 72%,
    rgba(0, 0, 0, 0.58) 82%,
    rgba(0, 0, 0, 0.18) 88%,
    transparent 94%
  );
}

.splash-fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  transform: translate(-50%, -50%);
  display: none;
  color: #dff5ff;
  font-size: clamp(28px, 7vw, 66px);
  font-weight: 500;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(80, 199, 255, 0.7);
}

.entry-screen.image-failed .splash-art {
  display: none;
}

.entry-screen.image-failed .splash-fallback {
  display: block;
}

.splash-seam {
  position: absolute;
  left: 50%;
  top: 7%;
  bottom: 7%;
  z-index: 3;
  width: 1px;
  opacity: 0;
  transform: translateX(-50%) scaleY(0.18);
  background: linear-gradient(180deg, transparent, rgba(211, 247, 255, 0.88) 24%, #eefcff 50%, rgba(92, 199, 255, 0.78) 76%, transparent);
  box-shadow: 0 0 8px rgba(76, 192, 255, 0.52);
  pointer-events: none;
}

.entry-screen.is-opening .splash-door-left {
  transform: perspective(1400px) translateX(-102%) rotateY(6deg);
}

.entry-screen.is-opening .splash-door-right {
  transform: perspective(1400px) translateX(102%) rotateY(-6deg);
}

.entry-screen.is-opening .splash-seam {
  animation: splashSeamOpen 1.15s ease-out both;
}

.app-shell {
  width: min(1240px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(70px, calc(env(safe-area-inset-top) + 58px))
    max(14px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  animation: none;
}

.app-shell.app-shell-pending {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-shell.app-shell-ready {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  animation: appShellIn 520ms ease-out both;
}

.project-picker {
  min-height: calc(100vh - 46px);
  min-height: calc(100dvh - 46px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: grid;
  align-content: center;
  gap: 44px;
  width: min(780px, 100%);
  margin: 0 auto;
}

.project-brand {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.project-brand img {
  width: clamp(112px, 20vw, 168px);
  height: clamp(112px, 20vw, 168px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 26px rgba(92, 197, 255, 0.24));
}

.project-brand h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  color: #f4fbff;
  text-shadow: 0 0 24px rgba(80, 189, 244, 0.2);
}

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

.project-card {
  position: relative;
  min-height: 178px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(99, 203, 255, 0.38);
  border-radius: 8px;
  background: rgba(8, 19, 32, 0.88);
  color: #effaff;
  box-shadow: inset 0 0 30px rgba(56, 164, 220, 0.06), 0 18px 46px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.project-card::before,
.project-card::after {
  content: "";
  position: absolute;
  width: 30px;
  height: 30px;
  pointer-events: none;
}

.project-card::before {
  top: 10px;
  left: 10px;
  border-top: 1px solid rgba(123, 220, 255, 0.64);
  border-left: 1px solid rgba(123, 220, 255, 0.64);
}

.project-card::after {
  right: 10px;
  bottom: 10px;
  border-right: 1px solid rgba(123, 220, 255, 0.64);
  border-bottom: 1px solid rgba(123, 220, 255, 0.64);
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: rgba(128, 221, 255, 0.78);
  background: rgba(10, 27, 46, 0.96);
  box-shadow: inset 0 0 36px rgba(71, 187, 245, 0.1), 0 18px 46px rgba(0, 0, 0, 0.32), 0 0 22px rgba(69, 178, 232, 0.14);
}

.project-card:active {
  transform: translateY(-1px) scale(0.985);
}

.project-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(125, 220, 255, 0.56);
  border-radius: 50%;
  color: #bcecff;
  background: rgba(35, 126, 174, 0.12);
  font-size: 22px;
  font-weight: 700;
}

.project-card strong {
  font-size: 24px;
}

.project-app {
  width: min(900px, 100%);
  margin: 0 auto;
}

.topbar {
  padding: 4px 0 16px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
  filter: drop-shadow(0 0 13px rgba(85, 196, 247, 0.24));
}

.brand h1 {
  color: #f0f9ff;
  font-size: 21px;
}

.brand p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-project-button {
  min-height: 40px;
  white-space: nowrap;
  color: #d9f3ff;
}

.project-context {
  min-height: 28px;
  display: flex;
  align-items: center;
  margin: 0 0 10px;
  color: #9edfff;
  font-size: 14px;
  font-weight: 700;
}

.language-panel,
.language-field-hidden {
  display: none !important;
}

button {
  border-color: var(--line);
  background: rgba(11, 27, 44, 0.9);
  color: var(--ink);
  box-shadow: none;
}

button:hover {
  border-color: rgba(109, 210, 255, 0.55);
  background: rgba(16, 40, 63, 0.96);
}

button.primary {
  border-color: #35aee7;
  background: #126d9c;
  color: #ffffff;
}

button.primary:hover {
  border-color: #79d8ff;
  background: #1883b8;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #7bdcff;
  outline-offset: 3px;
}

button:disabled {
  opacity: 1;
}

.status {
  border-color: var(--line);
  background: rgba(9, 22, 37, 0.9);
}

.panel,
.quiz-card,
.result-panel {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.auth-panel {
  width: min(620px, 100%);
  margin: 56px auto 0;
}

.lock-mark {
  border: 1px solid rgba(102, 210, 255, 0.42);
  background: rgba(27, 105, 145, 0.18);
  color: #c8efff;
  box-shadow: 0 0 18px rgba(65, 179, 232, 0.12);
}

.login-form input,
.answer-form input,
.field-label input,
.field-label select,
.admin-search input,
.admin-secret-input-wrap input,
.study-goal-field input,
textarea {
  border-color: var(--line);
  background: rgba(3, 12, 22, 0.76);
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #6f8799;
}

.tabs button {
  background: rgba(8, 21, 35, 0.84);
}

.tabs button.active,
.scope-tabs button.active {
  border-color: #64cbf8;
  background: #113f59;
  color: #ffffff;
  box-shadow: inset 0 -2px 0 #6cd3ff;
}

.secondary-row button {
  color: #d8eff9;
}

.stats-grid div {
  border-color: var(--line);
  background: rgba(8, 21, 35, 0.78);
}

.stats-grid strong,
.word-display {
  color: #f5fbff;
}

.word-display {
  min-height: 188px;
  text-shadow: 0 0 26px rgba(74, 181, 234, 0.11);
}

.word-display.dictation-display {
  color: #dff6ff;
}

.chips span {
  border-color: rgba(91, 202, 245, 0.34);
  background: rgba(18, 93, 119, 0.18);
  color: #bcf0ff;
}

.wrong-item,
.achievement-item {
  border-color: var(--line);
  background: rgba(5, 16, 28, 0.74);
}

.achievement-item.unlocked {
  border-color: rgba(91, 221, 154, 0.42);
  background: rgba(21, 105, 72, 0.15);
}

.achievement-item.unlocked .achievement-tier {
  color: #7fe8b0 !important;
}

.field-label span,
.meta-line,
.quiz-meta,
.stats-grid span,
.wrong-item p,
.achievement-item p {
  color: var(--muted);
}

.result-title.ok {
  color: var(--ok);
}

.result-title.bad,
.error,
.wrong-item strong {
  color: var(--danger);
}

@keyframes splashBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes splashImageIn {
  0% { opacity: 0; transform: scale(0.96); }
  22% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes splashSeamOpen {
  0% { opacity: 0; transform: translateX(-50%) scaleY(0.18); }
  12% { opacity: 0.82; transform: translateX(-50%) scaleY(1); }
  58% { opacity: 0.64; transform: translateX(-50%) scaleY(1); }
  100% { opacity: 0; transform: translateX(-50%) scaleY(0.92); }
}

@media (max-width: 640px) {
  .entry-screen.is-opening .splash-door-left {
    transform: translateX(-102%);
  }

  .entry-screen.is-opening .splash-door-right {
    transform: translateX(102%);
  }

  .project-picker {
    gap: 32px;
    align-content: center;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .project-card {
    min-height: 132px;
    grid-template-columns: 52px 1fr;
    justify-items: start;
    align-content: center;
    gap: 18px;
    text-align: left;
  }

  .project-mark {
    width: 50px;
    height: 50px;
    font-size: 19px;
  }

  .project-card strong {
    font-size: 21px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    gap: 7px;
  }

  .status {
    width: 40px;
    height: 40px;
  }

  .back-project-button {
    min-height: 40px;
    padding: 0 11px;
    font-size: 13px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .quiz-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quiz-meta span:nth-child(even) {
    text-align: right;
  }

  .word-display {
    min-height: 160px;
  }

  .word-reading {
    font-size: 22px;
  }
}

@media (max-width: 420px) {
  .account-badge {
    display: none;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .project-picker {
    align-content: start;
    gap: 18px;
  }

  .project-brand {
    grid-template-columns: 76px 1fr;
    align-items: center;
    justify-items: start;
    text-align: left;
  }

  .project-brand img {
    width: 76px;
    height: 76px;
  }

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

  .project-card {
    min-height: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-screen {
    animation-duration: 100ms;
  }

  .splash-door {
    transition-duration: 260ms;
    transition-timing-function: ease-out;
  }

  .entry-screen.is-opening .splash-door-left {
    transform: translateX(-102%);
  }

  .entry-screen.is-opening .splash-door-right {
    transform: translateX(102%);
  }

  .entry-screen.is-opening .splash-seam {
    animation-duration: 260ms;
  }

  .splash-art,
  .app-shell.app-shell-ready,
  .project-card {
    animation: none;
    transition-duration: 100ms;
  }
}
