.cefr-profiler-root,
.cefr-profiler-root * {
  box-sizing: border-box;
}

.cefr-profiler {
  --cefr-bg: #f7f9fc;
  --cefr-surface: #ffffff;
  --cefr-surface-strong: #f0f4f8;
  --cefr-text: #12202f;
  --cefr-muted: #5b6877;
  --cefr-border: #d8e0ea;
  --cefr-shadow: 0 18px 45px rgba(22, 34, 49, 0.08);
  --cefr-focus: #315fbc;
  --cefr-pre: #64748b;
  --cefr-a1: #16a34a;
  --cefr-a2: #0284c7;
  --cefr-b1: #286ecb;
  --cefr-b2: #b96b00;
  --cefr-c1: #c24155;
  --cefr-c2: #7c3aed;
  --cefr-off: #394150;
  --cefr-ignore: #929aa5;
  color: var(--cefr-text);
  background: var(--cefr-bg);
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  box-shadow: var(--cefr-shadow);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  margin: 24px auto;
  max-width: 1180px;
  overflow: hidden;
}

.cefr-profiler button,
.cefr-profiler textarea,
.cefr-profiler select {
  font: inherit;
}

.cefr-profiler button {
  cursor: pointer;
}

.cefr-profiler button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.cefr-profiler button:focus-visible,
.cefr-profiler textarea:focus-visible,
.cefr-profiler select:focus-visible {
  outline: 3px solid rgba(49, 95, 188, 0.28);
  outline-offset: 2px;
}

.cefr-profiler__header {
  align-items: center;
  background: var(--cefr-surface);
  border-bottom: 1px solid var(--cefr-border);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 22px 24px;
}

.cefr-profiler__brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.cefr-profiler__mark {
  align-items: center;
  background: #12202f;
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  flex: 0 0 42px;
  font-size: 16px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  letter-spacing: 0;
  width: 42px;
}

.cefr-profiler__title {
  color: var(--cefr-text);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0;
}

.cefr-profiler__subtitle {
  color: var(--cefr-muted);
  font-size: 14px;
  margin: 3px 0 0;
}

.cefr-profiler__credit {
  color: var(--cefr-muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.cefr-profiler__credit-link {
  color: var(--cefr-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cefr-profiler__credit-link:hover {
  color: var(--cefr-text);
}

.cefr-profiler__cefr-key {
  background: var(--cefr-surface-strong);
  border-top: 1px solid var(--cefr-border);
  color: var(--cefr-muted);
  font-size: 12px;
  padding: 10px 24px;
  text-align: center;
}

.cefr-profiler__cefr-key-label {
  font-weight: 600;
  margin-right: 6px;
}

.cefr-profiler__cefr-key-note {
  display: block;
  font-style: italic;
  margin-top: 3px;
}

.cefr-profiler__print-footer {
  display: none;
}

.cefr-profiler__status {
  align-items: center;
  background: var(--cefr-surface-strong);
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  color: var(--cefr-muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  padding: 9px 12px;
  white-space: nowrap;
}

.cefr-profiler__status-dot {
  background: var(--cefr-b2);
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.cefr-profiler.is-ready .cefr-profiler__status-dot {
  background: var(--cefr-a1);
}

.cefr-profiler.has-error .cefr-profiler__status-dot {
  background: var(--cefr-c1);
}

.cefr-profiler__main {
  padding: 18px;
}

.cefr-profiler__panel {
  background: var(--cefr-surface);
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  min-width: 0;
}

.cefr-profiler__panel-head {
  align-items: center;
  border-bottom: 1px solid var(--cefr-border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 18px;
}

.cefr-profiler__panel-title {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

.cefr-profiler__counter {
  color: var(--cefr-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.cefr-profiler__counter.is-over {
  color: var(--cefr-c1);
}

.cefr-profiler__editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.cefr-profiler__textarea {
  background: #fbfdff;
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  color: var(--cefr-text);
  min-height: 315px;
  padding: 16px;
  resize: vertical;
  width: 100%;
}

.cefr-profiler__textarea::placeholder {
  color: #8490a0;
}

.cefr-profiler__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.cefr-profiler__action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cefr-profiler__button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.cefr-profiler__button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.cefr-profiler__button--primary {
  background: #12202f;
  color: #ffffff;
}

.cefr-profiler__button--primary:hover:not(:disabled) {
  background: #203349;
}

.cefr-profiler__button--secondary {
  background: var(--cefr-surface);
  border-color: var(--cefr-border);
  color: var(--cefr-text);
}

.cefr-profiler__button--secondary:hover:not(:disabled) {
  background: var(--cefr-surface-strong);
}

.cefr-profiler__button-icon {
  display: inline-flex;
  height: 18px;
  width: 18px;
}

.cefr-profiler__button-icon svg {
  height: 18px;
  stroke-width: 2.2;
  width: 18px;
}

.cefr-profiler__helper {
  color: var(--cefr-muted);
  font-size: 13px;
  margin: 0;
}

.cefr-profiler__summary {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.cefr-profiler__level-card {
  background: #12202f;
  border-radius: 8px;
  color: #ffffff;
  padding: 18px;
}

.cefr-profiler__label {
  color: rgba(255, 255, 255, 0.72);
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.cefr-profiler__level-value {
  font-size: 34px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.05;
}

.cefr-profiler__level-note {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  margin: 8px 0 0;
}

.cefr-profiler__metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.cefr-profiler__metric {
  background: var(--cefr-surface-strong);
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  padding: 13px;
}

.cefr-profiler__metric-label {
  color: var(--cefr-muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.cefr-profiler__metric-value {
  color: var(--cefr-text);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.15;
}

.cefr-profiler__metric-note {
  color: var(--cefr-muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.cefr-profiler__notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #8a4b12;
  display: none;
  font-size: 13px;
  font-weight: 700;
  padding: 12px;
}

.cefr-profiler__notice.is-visible {
  display: block;
}

.cefr-profiler__results {
  display: grid;
  gap: 18px;
  padding: 0 18px 18px;
}

.cefr-profiler__wide-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
}

.cefr-profiler__section {
  background: var(--cefr-surface);
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  min-width: 0;
}

.cefr-profiler__section-head {
  align-items: center;
  border-bottom: 1px solid var(--cefr-border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 15px 18px;
}

.cefr-profiler__section-title {
  font-size: 15px;
  font-weight: 850;
  margin: 0;
}

.cefr-profiler__section-body {
  padding: 18px;
}

.cefr-profiler__distribution {
  display: grid;
  gap: 10px;
}

.cefr-profiler__bar-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 86px minmax(0, 1fr) 54px;
}

.cefr-profiler__bar-label {
  color: var(--cefr-text);
  font-size: 13px;
  font-weight: 850;
}

.cefr-profiler__bar-track {
  background: #e9eef5;
  border-radius: 999px;
  height: 11px;
  overflow: hidden;
}

.cefr-profiler__bar {
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 0;
  transition: width 220ms ease;
}

.cefr-profiler__bar-count {
  color: var(--cefr-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.cefr-profiler__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cefr-profiler__legend-item {
  align-items: center;
  background: var(--cefr-surface-strong);
  border: 1px solid var(--cefr-border);
  border-radius: 999px;
  color: var(--cefr-text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  padding: 6px 9px;
}

.cefr-profiler__legend-swatch {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.cefr-profiler__highlight {
  background: #fbfdff;
  border: 1px solid var(--cefr-border);
  border-radius: 8px;
  color: var(--cefr-text);
  font-size: 16px;
  line-height: 1.85;
  max-height: 340px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.cefr-profiler__token {
  border-radius: 5px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  font-weight: 750;
  margin: 0 1px;
  padding: 2px 4px;
}

.cefr-profiler__token--ignore {
  color: #687384;
  font-weight: 500;
}

.cefr-profiler__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cefr-profiler__filter {
  background: var(--cefr-surface);
  border: 1px solid var(--cefr-border);
  border-radius: 999px;
  color: var(--cefr-muted);
  font-size: 12px;
  font-weight: 850;
  min-height: 32px;
  padding: 6px 10px;
}

.cefr-profiler__filter.is-active {
  background: #12202f;
  border-color: #12202f;
  color: #ffffff;
}

.cefr-profiler__table-wrap {
  overflow: auto;
}

.cefr-profiler__table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.cefr-profiler__table th,
.cefr-profiler__table td {
  border-bottom: 1px solid var(--cefr-border);
  padding: 12px 11px;
  text-align: left;
  vertical-align: top;
}

.cefr-profiler__table th {
  background: #fbfdff;
  color: var(--cefr-muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.cefr-profiler__table td {
  color: var(--cefr-text);
  font-size: 13px;
}

.cefr-profiler__term {
  font-size: 14px;
  font-weight: 850;
}

.cefr-profiler__subtext {
  color: var(--cefr-muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.cefr-profiler__senses {
  color: var(--cefr-text);
  font-style: italic;
  max-width: 26ch;
  white-space: normal;
}

.cefr-profiler__pill {
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  padding: 6px 8px;
}

.cefr-profiler__empty {
  color: var(--cefr-muted);
  font-size: 14px;
  margin: 0;
}

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

.cefr-profiler__grammar-list li {
  align-items: flex-start;
  color: var(--cefr-text);
  display: flex;
  font-size: 13px;
  gap: 8px;
}

.cefr-profiler__grammar-list li::before {
  background: var(--cefr-b1);
  border-radius: 999px;
  content: "";
  flex: 0 0 7px;
  height: 7px;
  margin-top: 7px;
  width: 7px;
}

.cefr-level-pre-a1 {
  background: rgba(100, 116, 139, 0.16);
  color: #334155;
}

.cefr-level-a1 {
  background: rgba(22, 163, 74, 0.22);
  color: #14532d;
}

.cefr-level-a2 {
  background: rgba(2, 132, 199, 0.22);
  color: #0c4a6e;
}

.cefr-level-b1 {
  background: rgba(40, 110, 203, 0.16);
  color: #1e55a1;
}

.cefr-level-b2 {
  background: rgba(185, 107, 0, 0.18);
  color: #8a4b00;
}

.cefr-level-c1 {
  background: rgba(194, 65, 85, 0.16);
  color: #9a2f41;
}

.cefr-level-c2 {
  background: rgba(124, 58, 237, 0.16);
  color: #6025c9;
}

.cefr-level-off {
  background: rgba(57, 65, 80, 0.16);
  color: #293241;
}

.cefr-level-ignore {
  background: rgba(146, 154, 165, 0.15);
  color: #687384;
}

[data-level-color="Pre-A1"] {
  background-color: var(--cefr-pre);
}

[data-level-color="A1"] {
  background-color: var(--cefr-a1);
}

[data-level-color="A2"] {
  background-color: var(--cefr-a2);
}

[data-level-color="B1"] {
  background-color: var(--cefr-b1);
}

[data-level-color="B2"] {
  background-color: var(--cefr-b2);
}

[data-level-color="C1"] {
  background-color: var(--cefr-c1);
}

[data-level-color="C2"] {
  background-color: var(--cefr-c2);
}

[data-level-color="Off-list"] {
  background-color: var(--cefr-off);
}

[data-level-color="Ignored"] {
  background-color: var(--cefr-ignore);
}

@media (max-width: 960px) {
  .cefr-profiler__wide-grid {
    grid-template-columns: 1fr;
  }

  .cefr-profiler__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .cefr-profiler__status {
    white-space: normal;
  }
}

@media (max-width: 620px) {
  .cefr-profiler {
    border-left: 0;
    border-radius: 0;
    border-right: 0;
    margin-left: -16px;
    margin-right: -16px;
  }

  .cefr-profiler__header,
  .cefr-profiler__main,
  .cefr-profiler__results {
    padding-left: 12px;
    padding-right: 12px;
  }

  .cefr-profiler__title {
    font-size: 22px;
  }

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

  .cefr-profiler__actions,
  .cefr-profiler__panel-head,
  .cefr-profiler__section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cefr-profiler__action-group,
  .cefr-profiler__button {
    width: 100%;
  }

  .cefr-profiler__bar-row {
    grid-template-columns: 72px minmax(0, 1fr) 46px;
  }

  .cefr-profiler__target-selector {
    flex-wrap: wrap;
  }
}

/* ── Target level selector ─────────────────────────────────────────────────── */

.cefr-profiler__target-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cefr-profiler__target-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cefr-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.cefr-profiler__target-btn {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--cefr-border);
  border-radius: 20px;
  background: var(--cefr-surface);
  color: var(--cefr-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cefr-profiler__target-btn:hover {
  border-color: var(--cefr-focus);
  color: var(--cefr-focus);
}

.cefr-profiler__target-btn.is-active {
  background: var(--cefr-focus);
  border-color: var(--cefr-focus);
  color: #fff;
}

.cefr-profiler__target-btn--none {
  color: var(--cefr-muted);
  font-weight: 400;
}

/* ── AWL badge ─────────────────────────────────────────────────────────────── */

.cefr-profiler__awl-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 3px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  vertical-align: middle;
  line-height: 1.4;
}

/* ── Above-target highlighting ─────────────────────────────────────────────── */

.cefr-above-target {
  outline: 2px solid #ef4444;
  outline-offset: 1px;
  border-radius: 2px;
}

.cefr-row-above-target td {
  background: rgba(239, 68, 68, 0.06);
}

.cefr-row-above-target td:first-child {
  border-left: 3px solid #ef4444;
}

/* ── Sentence hardness tag ─────────────────────────────────────────────────── */

.cefr-sentence-tag {
  display: inline-block;
  margin: 0 4px 0 2px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  vertical-align: middle;
  opacity: 0.75;
  line-height: 1.6;
  cursor: default;
}

/* ── AWL token underline ───────────────────────────────────────────────────── */

.cefr-awl-token {
  text-decoration: underline dotted 1px;
  text-underline-offset: 3px;
}

/* ── Pre-teach section ─────────────────────────────────────────────────────── */

.cefr-profiler__pretaach-hint {
  font-size: 13px;
  color: var(--cefr-muted);
  margin: 0 0 12px;
}

.cefr-profiler__pretaach-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cefr-profiler__pretaach-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--cefr-surface);
  border: 1px solid var(--cefr-border);
  border-radius: 6px;
  font-size: 13px;
}

/* ── Print view ────────────────────────────────────────────────────────────── */

@media print {
  .cefr-profiler {
    box-shadow: none;
    border: none;
    margin: 0;
    max-width: 100%;
  }

  .cefr-profiler__header,
  .cefr-profiler__actions,
  .cefr-profiler__target-selector,
  .cefr-profiler__helper,
  .cefr-profiler__filters,
  [data-analyze],
  [data-sample],
  [data-clear],
  [data-print],
  [data-export],
  [data-copy],
  [data-copy-pretaach],
  .cefr-profiler__status {
    display: none !important;
  }

  .cefr-profiler__table-wrap {
    overflow: visible;
  }

  .cefr-profiler__section {
    break-inside: avoid;
  }

  .cefr-profiler__cefr-key {
    background: none;
    border-top: 1px solid #ccc;
    font-size: 11px;
    padding: 8px 0;
  }

  .cefr-profiler__print-footer {
    border-top: 1px solid #ccc;
    color: #555;
    display: block;
    font-size: 11px;
    margin-top: 8px;
    padding-top: 8px;
    text-align: center;
  }

  .cefr-profiler__print-footer a {
    color: #555;
    text-decoration: none;
  }
}
