:root {
  --black: #111;
  --white: #fff;
  --grey-100: #f4f4f4;
  --grey-200: #e0e0e0;
  --grey-400: #b0b0b0;
  --grey-600: #707070;
  --grey-800: #333;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
}

* {
  box-sizing: border-box;
}

/* Browsers give <p> a default 1em top/bottom margin. Left in place, that
   default silently reappears on any <p> that forgets to override it — which
   is exactly what happened to .result-line .lang-name, throwing off the
   vertical centering next to its sibling .translation (which did zero its
   margin). Resetting it globally here means spacing is always intentional. */
p {
  margin: 0;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0 var(--space-2) var(--space-4);
  background: var(--white);
  color: var(--black);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}


header {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-4) 0 var(--space-1);
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--grey-600);
  margin: var(--space-1) 0 0;
  font-size: 0.95rem;
}

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.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;
}

/* Named grid areas so the visual order can differ between mobile (stacked:
   input, then results, then languages) and desktop (two columns) without
   duplicating markup. */
.translate-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "input" "results" "languages";
  gap: var(--space-4);
  margin-top: var(--space-4);
}

@media (min-width: 640px) {
  .translate-layout {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    grid-template-areas: "input results" "languages results";
  }
}

.input-group {
  grid-area: input;
}

.results-column {
  grid-area: results;
}

.languages-group {
  grid-area: languages;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--grey-800);
  margin: 0 0 var(--space-1);
}

#input-text {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--grey-400);
  border-radius: 8px;
  background: var(--white);
  color: var(--black);
  font-size: 1.05rem;
  font-family: inherit;
  resize: vertical;
}

#input-text:focus {
  outline: none;
  border-color: var(--black);
}

#translate-btn {
  margin-top: var(--space-2);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--grey-800);
  margin-bottom: var(--space-1);
}

input[type="email"],
#feedback-message {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--grey-400);
  border-radius: 6px;
  background: var(--white);
  color: var(--black);
  font-size: 1rem;
  font-family: inherit;
}

#feedback-message {
  resize: vertical;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.chip {
  padding: 6px 12px;
  border: 1px solid var(--grey-400);
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font-size: 0.85rem;
  cursor: pointer;
}

.chip.selected {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.chip.detected {
  background: var(--white);
  color: var(--black);
  border: 2px dashed var(--black);
}

.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Overrides the generic button:hover rule below, which would otherwise
   darken the background here while leaving the black text unchanged —
   unreadable. Unselected/detected chips keep black text, so their hover
   state lightens instead of darkens; the selected (already dark) chip is
   the one case where darkening further is still readable. */
.chip:hover:not(:disabled) {
  background: var(--grey-100);
  color: var(--black);
}

.chip.selected:hover:not(:disabled) {
  background: var(--grey-800);
  color: var(--white);
}

button {
  padding: 10px 20px;
  border: 1px solid var(--black);
  border-radius: 6px;
  background: var(--black);
  color: var(--white);
  font-size: 0.95rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--grey-800);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.text-btn {
  padding: var(--space-1) 0;
  border: none;
  background: none;
  color: var(--grey-600);
  font-size: 0.8rem;
  text-decoration: underline;
}

.text-btn:hover:not(:disabled) {
  background: none;
  color: var(--black);
}

#feedback-form button[type="submit"] {
  background: var(--black);
  color: var(--white);
}

#status-message,
#feedback-status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--grey-600);
  margin-top: var(--space-1);
}

.results-column {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.results-empty {
  width: 100%;
  margin: 0;
  /* Matches #input-text's border (1px) + padding so the text lines up with
     the text inside the box on the left. */
  padding-top: 17px;
  color: var(--grey-400);
  font-size: 1.05rem;
  text-align: left;
}

.results-list {
  width: 100%;
}

#copy-all-btn {
  margin-top: var(--space-2);
}

.result-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--grey-200);
}

.result-line .lang-name {
  flex: 0 0 auto;
  width: 90px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--grey-600);
}

.result-line.original .lang-name {
  color: var(--black);
  font-weight: 600;
}

.result-line .translation {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.05rem;
  word-wrap: break-word;
  user-select: all;
  /* Multiple senses of an ambiguous word are joined with "\n" in JS —
     this makes that render as an actual line break instead of being
     collapsed, while still wrapping/collapsing other whitespace normally. */
  white-space: pre-line;
}

footer {
  max-width: 900px;
  margin: var(--space-4) auto 0;
  padding-top: var(--space-2);
}

.privacy-note {
  font-size: 0.75rem;
  color: var(--grey-600);
  text-align: center;
}

#feedback-widget {
  position: fixed;
  bottom: var(--space-2);
  right: var(--space-2);
  text-align: right;
  z-index: 20;
  transition: bottom 0.15s ease;
}

/* Lifted above the consent banner while it's showing, so the two never overlap. */
#feedback-widget.above-banner {
  bottom: 90px;
}

#feedback-toggle {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 999px;
}

#feedback-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: var(--space-1);
  width: 260px;
  padding: var(--space-2);
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  text-align: left;
}

#feedback-panel:not([hidden]) {
  display: block;
}

#feedback-panel .field {
  margin-top: var(--space-2);
}

#feedback-panel .field:first-child {
  margin-top: 0;
}

.consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--black);
  color: var(--white);
  padding: 14px var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  z-index: 30;
}

.consent-banner:not([hidden]) {
  display: flex;
}

.consent-banner p {
  margin: 0;
  font-size: 0.85rem;
  max-width: 480px;
}

.consent-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.consent-actions button {
  border-radius: 6px;
  padding: var(--space-1) var(--space-2);
}

#consent-accept {
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--white);
}

/* Same fix as .chip above: this button has black text on white, so the
   generic button:hover rule (which only darkens the background) would
   otherwise make it unreadable on hover. */
#consent-accept:hover:not(:disabled) {
  background: var(--grey-200);
  color: var(--black);
}

#consent-decline {
  background: transparent;
  color: var(--white);
  border: 1px solid var(--grey-400);
}
