:root {
  /* Same Weglot values as competitor-research. */
  --royal-blue: #473ae0;
  --dark-blue: #18164c;
  --light-blue: #edebfc;
  --extra-light-grey: #f6f7f9;
  --light-gray: #ebecef;
  --medium-gray: #9ca3af;
  --text-secondary: #6b7280;
  --white: #fff;
  --orange: #ff7a1a;
  --orange-bg: #fff1e6;
  --orange-text: #b4480a;
  --pink-bg: #fde8f1;
  --pink-text: #b0185a;
  --grey-bg: #eef0f3;
  --grey-text: #4b5563;
  --error: #b3261e;
  --error-bg: #fdecea;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 8px 24px rgba(24, 22, 76, 0.12);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

/* Author `display` values below would otherwise beat the UA [hidden] rule. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 24px 16px;
  background: var(--white);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--dark-blue);
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  max-width: 1216px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- form */

.tool-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 14px;
  color: var(--dark-blue);
}

input[type="text"],
select {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font: inherit;
  font-size: 16px;
  color: var(--dark-blue);
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input[type="text"]:focus,
select:focus {
  border-color: var(--royal-blue);
  box-shadow: 0 0 0 3px var(--light-blue);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--error);
}

.select-wrap {
  position: relative;
  display: block;
}

select {
  padding-right: 44px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 16px;
  margin-top: -4px;
  pointer-events: none;
  color: var(--dark-blue);
}

.field-error {
  margin: 0;
  font-size: 13px;
  color: var(--error);
}

.form-error {
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--error);
  background: var(--error-bg);
  border-radius: var(--radius);
}

/* ----------------------------------------------------------------- CTA */

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 58px;
  margin-top: 8px;
  padding: 0 24px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  background: var(--royal-blue);
  border: 1px solid var(--royal-blue);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.cta:hover {
  background: #3a2ec4;
}

.cta:active {
  transform: translateY(1px);
}

.cta:disabled {
  opacity: 0.6;
  cursor: wait;
}

.cta-small {
  height: 40px;
  margin-top: 0;
  padding: 0 18px;
  font-size: 14px;
}

.cta-white {
  color: var(--dark-blue);
  background: var(--white);
  border-color: var(--light-gray);
}

.cta-white:hover {
  background: var(--extra-light-grey);
}

/* ------------------------------------------------------------- loading */

.loading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 32px;
  background: var(--extra-light-grey);
  border-radius: var(--radius);
}

.spinner {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 3px solid var(--light-blue);
  border-top-color: var(--royal-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin: 0;
  font-size: 15px;
}

/* ------------------------------------------------------------- results */

.results {
  overflow: hidden;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  padding: 24px 32px;
  background: var(--extra-light-grey);
}

.summary-count {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.summary-number {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--royal-blue);
}

.summary-text {
  font-size: 18px;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  padding: 6px 12px;
  font-size: 14px;
  background: var(--white);
  border-radius: var(--radius-sm);
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 32px;
}

.results-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.results-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
}

.results-actions {
  display: flex;
  gap: 12px;
}

/* --------------------------------------------------------------- table */

.table {
  padding: 0 32px 32px;
}

.row {
  display: grid;
  grid-template-columns: 180px 230px 300px 130px 1fr;
  align-items: stretch;
  border-top: 1px solid var(--light-gray);
}

.row-head {
  align-items: end;
  border-top: 0;
}

.row-head .cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 10px 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.row-head .cell-searched {
  padding: 10px 16px;
  color: var(--white);
  background: var(--royal-blue);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.row-head .cell-gap {
  justify-content: flex-end;
  padding: 10px 12px;
}

.row-head .cell-why {
  padding-left: 20px;
}

.row.is-optimal {
  background: var(--extra-light-grey);
}

.cell-keyword {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 16px 0;
}

.edge {
  width: 3px;
  align-self: stretch;
  flex-shrink: 0;
  background: transparent;
}

.row.is-top .edge {
  background: var(--orange);
}

.cell-literal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 12px 16px 0;
}

.row:not(.is-optimal) .cell-literal .term {
  color: var(--medium-gray);
  text-decoration: line-through;
}

.volume {
  font-size: 12px;
}

.cell-searched-term {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-left: 1px solid var(--light-gray);
  border-right: 1px solid var(--light-gray);
}

.searched-term {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.copy-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  color: var(--royal-blue);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.copy-button:hover {
  background: var(--extra-light-grey);
}

.cell-gap-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  font-size: 14px;
  color: var(--royal-blue);
  white-space: nowrap;
}

.row.is-optimal .cell-gap-value {
  color: var(--dark-blue);
}

.bar {
  width: 64px;
  height: 4px;
  overflow: hidden;
  background: var(--light-gray);
}

.bar span {
  display: block;
  height: 4px;
  background: var(--royal-blue);
}

.cell-why-value {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 16px 20px;
  font-size: 12px;
}

.label {
  display: inline-flex;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 3px;
}

.label-literal {
  color: var(--orange-text);
  background: var(--orange-bg);
}

.label-foreign {
  color: var(--pink-text);
  background: var(--pink-bg);
}

.label-optimal {
  color: var(--grey-text);
  background: var(--grey-bg);
}

/* ------------------------------------------------------------- tooltip */

.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--royal-blue);
  cursor: help;
  outline: none;
}

.cell-searched .tip {
  color: var(--white);
}

.tip-box {
  position: absolute;
  bottom: 24px;
  left: -8px;
  z-index: 5;
  display: none;
  width: 260px;
  padding: 12px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--dark-blue);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tip:hover .tip-box,
.tip:focus .tip-box {
  display: block;
}

/* ------------------------------------------------------------- mobile */

@media (max-width: 1100px) {
  .table {
    padding: 0 16px 16px;
  }

  .row-head {
    display: none;
  }

  .row {
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
    padding: 16px 0;
  }

  .cell-keyword {
    grid-column: 1 / -1;
    padding: 0 0 8px;
    font-weight: 600;
  }

  .edge {
    display: none;
  }

  .cell-literal,
  .cell-searched-term,
  .cell-gap-value {
    padding: 8px 0;
    border: 0;
  }

  .cell-literal::before,
  .cell-searched-term::before {
    font-size: 12px;
    color: var(--text-secondary);
  }

  .cell-literal::before {
    content: "Literal translation";
  }

  .cell-searched-term {
    padding: 8px 12px;
    background: var(--light-blue);
    border-radius: var(--radius-sm);
  }

  .cell-gap-value {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }

  .cell-why-value {
    grid-column: 1 / -1;
    padding: 0;
  }

  .row.is-top {
    border-left: 3px solid var(--orange);
    padding-left: 12px;
  }

  .summary,
  .results-head {
    padding: 20px 16px;
  }
}
