:root {
  --ink: #20141e;
  --muted: #766a75;
  --line: #ded4dd;
  --surface: #ffffff;
  --wash: #f7f2f6;
  --header: #321425;
  --header-soft: #4a1d36;
  --plum: #6d214f;
  --burgundy: #8f2446;
  --gold: #b8822b;
  --rose: #c43d62;
  --blue: #3867d6;
  --cyan: #297c91;
  --violet: #7c4dcc;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #efe4ed 0, var(--wash) 260px),
    var(--wash);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

.app-shell {
  flex: 1 0 auto;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 0 28px;
  color: white;
  background: linear-gradient(90deg, var(--header), var(--header-soft));
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(50, 20, 37, 0.22);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #321425;
  background: linear-gradient(135deg, #fff7e7, #e7c36f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 8px 20px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 900;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

nav a.active,
nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.13);
}

.app-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.site-footer {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: 18px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
  background: linear-gradient(90deg, var(--header), var(--header-soft));
  font-size: 13px;
  text-align: center;
}

.site-footer p {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.analyser-panel,
.results-panel,
.login-panel,
.setup-band,
.table-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(50, 20, 37, 0.08);
}

.tool-tabs {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 32px rgba(50, 20, 37, 0.07);
}

.section-switcher {
  justify-self: stretch;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 7px;
  border: 1px solid #d4a9be;
  border-radius: 8px;
  background: #3a172a;
  box-shadow: none;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.admin-tabs a {
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--plum);
  font-weight: 900;
}

.admin-tabs a.active,
.admin-tabs a:hover {
  color: white;
  background: linear-gradient(135deg, var(--burgundy), var(--plum));
}

.admin-image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffcf8;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-image-preview img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #f0d28a;
  box-shadow: 0 8px 20px rgba(50, 20, 37, 0.12);
}

.section-switcher a {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  place-items: center;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 18px;
  font-weight: 900;
}

.section-switcher a.active,
.section-switcher a:hover {
  color: var(--header);
  background: linear-gradient(135deg, #fff7e7, #e7c36f);
}

.tab-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tool-tab {
  flex: 0 0 min(220px, 68vw);
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
}

.tool-tab strong {
  font-size: 15px;
}

.tool-tab span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tool-tab.active,
.tool-tab:hover {
  border-color: #d9afc4;
  background: #fbf1f6;
  color: var(--plum);
}

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

.home-intro {
  max-width: 980px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.home-panel .panel-heading {
  max-width: 980px;
}

.home-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  column-gap: 26px;
  align-items: start;
  justify-items: start;
}

.home-panel .panel-heading,
.home-panel .home-intro {
  grid-column: 1;
}

.home-visual {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  align-self: start;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 8px solid #f0d28a;
  background: #f0d28a;
  box-shadow: 0 18px 42px rgba(50, 20, 37, 0.14);
}

.home-visual img,
.home-avatar-placeholder {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}

.home-avatar-placeholder {
  display: grid;
  place-items: center;
  color: #321425;
  background: linear-gradient(135deg, #fbf1f6, #ffffff);
  font-size: 64px;
  font-weight: 900;
}

.home-panel .section-overview {
  grid-column: 1 / -1;
  width: min(100%, 1120px);
}

.home-sections .overview-card {
  min-height: 144px;
}

.overview-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffcf8;
}

.overview-card:hover {
  border-color: #d9afc4;
  background: #fbf1f6;
}

.overview-card strong {
  color: var(--plum);
  font-size: 20px;
}

.overview-card span {
  color: var(--muted);
  line-height: 1.45;
}

.tool-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.tool-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tool-card.selected,
.tool-card:hover {
  border-color: #d9afc4;
  background: #fbf1f6;
}

.analyser-panel,
.results-panel {
  padding: 22px;
}

.analyser-panel {
  border-top: 4px solid var(--burgundy);
}

.results-panel {
  grid-column: 1 / -1;
  border-top: 4px solid var(--gold);
}

.panel-heading,
.page-heading {
  margin-bottom: 18px;
}

.eyebrow,
.label,
.microcopy {
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.analysis-form,
.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfcfd;
  font: inherit;
  font-weight: 500;
  line-height: 1.45;
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid #ead0df;
  border-color: var(--burgundy);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--plum) 50%), linear-gradient(135deg, var(--plum) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

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

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

.result-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.word-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid #d9afc4;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7ea, #fbf1f6);
}

.daily-word-card {
  position: relative;
  margin-bottom: 18px;
  padding: 20px;
  border-color: #cf9cb8;
  box-shadow: 0 14px 34px rgba(50, 20, 37, 0.1);
}

.daily-word-card::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: -10px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--burgundy), var(--gold), transparent);
}

.daily-word-card h1 {
  margin-bottom: 10px;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.02;
}

.daily-word-card .word-title-row h2 {
  font-size: clamp(30px, 4vw, 46px);
  color: var(--plum);
}

.word-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.word-title-row h2 {
  margin-bottom: 0;
  font-size: 30px;
}

.word-meaning,
.word-bm,
.word-example {
  margin-bottom: 8px;
}

.word-bm {
  color: var(--plum);
  font-weight: 800;
}

.word-example {
  font-style: italic;
}

.synonym-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.synonym-row span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--plum);
  background: white;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.guess-game {
  display: grid;
  gap: 16px;
}

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

.game-status span,
.game-status strong {
  padding: 7px 10px;
  border-radius: 999px;
  background: #fbf1f6;
  color: var(--plum);
  font-size: 13px;
}

.guess-word {
  padding: 18px;
  border-radius: 8px;
  background: #fffcf8;
  border: 1px solid var(--line);
  color: var(--plum);
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.08em;
}

.game-clues {
  display: grid;
  gap: 8px;
}

.game-clues p {
  margin-bottom: 0;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 6px;
}

.letter-btn {
  min-height: 38px;
  padding: 0;
  background: white;
  border-color: var(--line);
  color: var(--plum);
}

.letter-btn:disabled {
  color: #b5aab3;
  background: #f3edf2;
}

.game-message {
  min-height: 24px;
  color: var(--muted);
  font-weight: 800;
}

.game-message.success {
  color: #166534;
}

.game-message.error {
  color: #9f1239;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

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

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--burgundy), var(--plum));
}

.ghost-btn {
  color: var(--ink);
  background: white;
  border-color: var(--line);
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 220px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.result-summary,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.result-summary > div,
.metric-grid article {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.result-summary strong,
.metric-grid strong {
  font-size: 22px;
}

.big-level {
  font-size: 42px;
  line-height: 1;
}

.teacher-note {
  padding: 14px;
  border-radius: 8px;
  background: #fff7ea;
  border: 1px solid #edcf94;
  margin-bottom: 18px;
}

.teacher-note ul {
  margin-bottom: 0;
  padding-left: 20px;
}

.generated-passage {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffcf8;
}

.generated-passage p {
  margin-bottom: 14px;
  line-height: 1.7;
}

.generated-passage p:last-child {
  margin-bottom: 0;
}

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

.section-title h2 {
  margin-bottom: 0;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
}

.two-column-result {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.lexis-section {
  margin-bottom: 18px;
}

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

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

.lexis-stack {
  display: grid;
  gap: 12px;
}

.lexis-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffcf8;
}

.lexis-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.lexis-card strong {
  display: block;
  color: var(--plum);
  font-size: 18px;
  margin-bottom: 8px;
}

.lexis-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

.bars {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.bar-row {
  display: grid;
  grid-template-columns: 34px 1fr 84px;
  gap: 8px;
  align-items: center;
}

.bar-row strong {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
}

.bar-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bar-track {
  overflow: hidden;
  height: 10px;
  background: #e9edf2;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.level-pill {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  min-height: 26px;
  border-radius: 999px;
  color: white;
  font-weight: 800;
  font-size: 12px;
}

.level-A1 { background: var(--blue); }
.level-A2 { background: var(--cyan); }
.level-B1 { background: var(--violet); }
.level-B2 { background: var(--gold); }
.level-C1 { background: var(--rose); }
.level-C2 { background: var(--plum); }
.level-text-A1 { color: var(--blue); }
.level-text-A2 { color: var(--cyan); }
.level-text-B1 { color: var(--violet); }
.level-text-B2 { color: var(--gold); }
.level-text-C1 { color: var(--rose); }
.level-text-C2 { color: var(--plum); }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
}

.notice.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.notice.success {
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.setup-band,
.table-section {
  padding: 18px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .results-panel {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }

  .brand-mark {
    justify-content: center;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  nav a {
    display: grid;
    place-items: center;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 13px;
  }

  .app-shell {
    width: min(100vw - 18px, 1220px);
    padding-top: 14px;
  }

  .daily-word-card {
    padding: 16px;
  }

  .daily-word-card h1 {
    font-size: 26px;
  }

  .daily-word-card .word-title-row h2 {
    font-size: 34px;
  }

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

  .home-panel .panel-heading,
  .home-panel .home-intro,
  .home-visual,
  .home-panel .section-overview {
    grid-column: 1;
  }

  .home-visual {
    grid-row: auto;
    justify-self: center;
    width: min(180px, 58vw);
    height: min(180px, 58vw);
    margin-bottom: 18px;
  }

  .section-switcher {
    justify-self: stretch;
  }

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

  .admin-tabs a {
    text-align: center;
  }

  .section-switcher a {
    min-height: 40px;
    padding: 0 8px;
  }

  .tab-list {
    display: grid;
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .tool-tab {
    flex-basis: auto;
  }

  .analyser-panel,
  .results-panel,
  .login-panel,
  .setup-band,
  .table-section {
    padding: 16px;
  }

  textarea {
    min-height: 180px;
  }

  .form-actions,
  .result-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .result-summary,
  .metric-grid,
  .section-overview,
  .control-grid,
  .two-column-result,
  .lexis-columns,
  .lexis-grid,
  .word-card {
    grid-template-columns: 1fr;
  }

  .letter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
  }

  .letter-btn {
    min-height: 42px;
  }

  .guess-word {
    padding: 14px 8px;
    font-size: clamp(28px, 12vw, 42px);
    overflow-wrap: anywhere;
  }

  .game-status {
    align-items: stretch;
    flex-direction: column;
  }

  .bar-row {
    grid-template-columns: 30px 1fr 76px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 32px;
  }

  table {
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

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