.tool-main {
  min-height: 100vh;
  padding-top: 4rem;
  background:
    linear-gradient(180deg, rgba(239,246,255,.86), rgba(255,255,255,1) 28rem),
    var(--clr-bg);
}

.tool-header {
  border-bottom-color: var(--clr-border);
  box-shadow: var(--shadow-sm);
}

.tool-hero {
  padding: 4.5rem 0 3rem;
  background:
    radial-gradient(circle at 88% 18%, rgba(79,110,247,.12), transparent 24rem),
    linear-gradient(135deg, #f8fafc 0%, #eef4ff 100%);
  border-bottom: 1px solid var(--clr-border);
}

.tool-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem);
  gap: 2rem;
  align-items: end;
}

.tool-title {
  max-width: 46rem;
  font-family: var(--ff-display);
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1.05;
  color: var(--clr-text);
  margin-bottom: 1rem;
}

.tool-lead {
  max-width: 42rem;
  color: var(--clr-muted);
  font-size: 1.1rem;
}

.tool-sample {
  display: grid;
  gap: .45rem;
  padding: 1.25rem;
  border: 1px solid rgba(29,78,216,.16);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-md);
}

.tool-sample span {
  color: var(--clr-muted);
  font-weight: 600;
}

.tool-sample strong,
.ipa,
.ipa-output {
  font-family: "Gentium Plus", "Charis SIL", "Noto Sans", serif;
}

.tool-sample strong {
  color: var(--clr-primary);
  font-size: 1.5rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tool-section {
  padding-block: 3rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(19rem, .95fr);
  gap: 1.35rem;
  align-items: start;
}

.tool-panel {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  background: var(--clr-bg);
  box-shadow: var(--shadow-md);
  padding: 1.35rem;
}

.tool-panel__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tool-panel__head h2 {
  font-family: var(--ff-display);
  font-size: 1.45rem;
  line-height: 1.2;
  margin-bottom: .25rem;
}

.tool-panel__head p,
.tool-note {
  color: var(--clr-muted);
  font-size: .94rem;
}

.word-count {
  flex: 0 0 auto;
  min-width: 4.8rem;
  text-align: center;
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  border: 1px solid rgba(29,78,216,.12);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: .82rem;
  font-weight: 800;
}

.tool-textarea {
  width: 100%;
  min-height: 13rem;
  resize: vertical;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font: inherit;
  color: var(--clr-text);
  background: #fff;
  line-height: 1.65;
  transition: var(--transition);
}

.tool-textarea:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 4px rgba(29,78,216,.12);
}

.tool-input,
.tool-select {
  width: 100%;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  font: inherit;
  color: var(--clr-text);
  background: #fff;
  transition: var(--transition);
}

.tool-select {
  margin-top: .75rem;
}

.tool-input:focus,
.tool-select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 4px rgba(29,78,216,.12);
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 1rem 0 .8rem;
}

.result-panel {
  position: sticky;
  top: 5.2rem;
}

.copy-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(29,78,216,.18);
  border-radius: var(--radius-sm);
  background: var(--clr-primary-lt);
  color: var(--clr-primary);
  cursor: pointer;
  font-weight: 800;
  padding: .45rem .8rem;
  transition: var(--transition);
}

.copy-btn:hover {
  border-color: var(--clr-primary);
}

.ipa-output {
  display: block;
  min-height: 6.8rem;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(29,78,216,.14);
  background: #f8fbff;
  color: var(--clr-primary-dk);
  padding: 1rem;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.syllable-output {
  font-family: var(--ff-body);
  font-weight: 800;
  letter-spacing: 0;
}

.syllable-chip span {
  font-family: var(--ff-body);
  font-weight: 800;
}

.conjugation-output {
  display: grid;
  gap: 1rem;
}

.conjugation-card {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.conjugation-card h3 {
  margin: 0;
  padding: .85rem 1rem;
  font-family: var(--ff-display);
  font-size: 1.15rem;
  background: var(--clr-primary-lt);
  color: var(--clr-primary-dk);
  border-bottom: 1px solid rgba(29,78,216,.12);
}

.conjugation-table {
  width: 100%;
  border-collapse: collapse;
}

.conjugation-table th,
.conjugation-table td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--clr-border);
  text-align: left;
  vertical-align: top;
}

.conjugation-table tr:last-child th,
.conjugation-table tr:last-child td {
  border-bottom: 0;
}

.conjugation-table th {
  width: 6.5rem;
  color: var(--clr-muted);
  font-weight: 800;
}

.conjugation-invariable {
  padding: .85rem 1rem;
  color: var(--clr-text);
  font-weight: 700;
  font-size: 1.1rem;
}

.conjugation-table td {
  color: var(--clr-text);
  font-weight: 700;
}

.detail-box {
  margin-top: 1rem;
}

.detail-box h3 {
  font-size: .95rem;
  margin-bottom: .65rem;
  color: var(--clr-muted);
}

.word-detail {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.word-chip {
  display: inline-grid;
  gap: .1rem;
  max-width: 100%;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-bg-alt);
  padding: .5rem .65rem;
}

.word-chip b {
  font-size: .82rem;
  color: var(--clr-text);
}

.word-chip span {
  color: var(--clr-primary);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.empty-detail {
  color: var(--clr-muted);
  font-size: .92rem;
}

.tool-rules {
  padding: 3rem 0 4.5rem;
  background: var(--clr-bg-alt);
  border-top: 1px solid var(--clr-border);
}

.rules-grid {
  display: grid;
  grid-template-columns: minmax(16rem, .65fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.rules-list {
  display: grid;
  gap: .7rem;
  list-style: none;
  color: var(--clr-text);
}

.rules-list li {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: .9rem 1rem;
}

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

/* ---- Lexique bilingue (traduction) ---- */
.lex-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .9rem 0 .2rem;
}

.lex-chip {
  border: 1px solid var(--clr-border);
  border-radius: 999px;
  background: #fff;
  color: var(--clr-muted);
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  padding: .4rem .9rem;
  transition: var(--transition);
}

.lex-chip:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.lex-chip.is-active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

.lex-list {
  display: grid;
  gap: .55rem;
  margin-top: 1.1rem;
}

.lex-entry {
  display: grid;
  gap: .4rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: .75rem 1rem;
  transition: var(--transition);
}

.lex-entry:hover {
  border-color: var(--clr-primary);
  box-shadow: var(--shadow-sm);
}

.lex-entry.is-copied {
  border-color: var(--clr-primary);
  background: var(--clr-primary-lt);
}

.lex-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.lex-search {
  justify-self: start;
  font-size: .8rem;
  font-weight: 700;
  color: var(--clr-primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(29,78,216,.4);
  padding-bottom: 1px;
}

.lex-search:hover {
  color: var(--clr-primary-dk);
  border-bottom-style: solid;
}

.lex-fr {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  color: var(--clr-text);
  font-weight: 700;
}

.lex-tag {
  color: var(--clr-primary);
  background: var(--clr-primary-lt);
  border: 1px solid rgba(29,78,216,.12);
  border-radius: 999px;
  padding: .1rem .55rem;
  font-size: .72rem;
  font-weight: 800;
}

.lex-ar {
  font-family: "Tajawal", "Cairo", "Segoe UI", "Noto Naskh Arabic", serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--clr-primary-dk);
  text-align: right;
  direction: rtl;
  white-space: nowrap;
}

.lex-empty {
  padding: 1rem 0;
}

@media (max-width: 560px) {
  .lex-main {
    flex-direction: column;
    align-items: stretch;
    gap: .35rem;
  }

  .lex-ar {
    text-align: right;
    white-space: normal;
  }
}

@media (max-width: 900px) {
  .tool-hero__inner,
  .tool-grid,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .tool-main {
    padding-top: 3.75rem;
  }

  .tool-hero {
    padding: 3rem 0 2rem;
  }

  .tool-panel {
    padding: 1rem;
  }

  .tool-panel__head {
    display: grid;
  }

  .tool-actions .btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }
}

/* ---- Dark mode ---- */
html[data-theme="dark"] .tool-main {
  background:
    linear-gradient(180deg, rgba(23,32,51,.86), rgba(15,23,42,1) 28rem),
    var(--clr-bg);
}

html[data-theme="dark"] .tool-hero {
  background:
    radial-gradient(circle at 88% 18%, rgba(96,165,250,.14), transparent 24rem),
    linear-gradient(135deg, #0f172a 0%, #172033 100%);
}

html[data-theme="dark"] .tool-sample {
  background: rgba(26,37,64,.86);
  border-color: rgba(96,165,250,.2);
}

html[data-theme="dark"] .tool-textarea,
html[data-theme="dark"] .tool-input,
html[data-theme="dark"] .tool-select,
html[data-theme="dark"] .conjugation-card,
html[data-theme="dark"] .rules-list li,
html[data-theme="dark"] .lex-chip,
html[data-theme="dark"] .lex-entry {
  background: var(--clr-surface);
}

html[data-theme="dark"] .ipa-output {
  background: var(--clr-surface);
  border-color: rgba(96,165,250,.2);
}

html[data-theme="dark"] .lex-chip.is-active {
  color: #172033;
}
