:root {
  color-scheme: light;
  --ink: #1f1d1a;
  --muted: #5c5347;
  --paper: #f9f4ea;
  --panel: #fffaf1;
  --accent: #b76b2b;
  --accent-2: #234c3f;
  --shadow: 0 20px 60px rgba(37, 24, 8, 0.12);
  --stroke: rgba(31, 29, 26, 0.12);

  --germanic: #8fbe73;
  --loan: #4f7cff;
  --unclear: #c9c3ba;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Palatino", "Book Antiqua", "Georgia", serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #f3e1c6 0%, #f6efe6 40%, #efe2d3 100%);
  min-height: 100vh;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.hero {
  position: relative;
  padding: 12px 20px;
  margin: 0 -24px 20px;
  border-radius: 0;
  background: linear-gradient(90deg, #fff4db 0%, #f6ddbf 100%);
  box-shadow: 0 8px 22px rgba(37, 24, 8, 0.1);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(35, 76, 63, 0.25), transparent 70%);
  border-radius: 50%;
  opacity: 0.7;
}

.hero__inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  margin: 0 0 12px;
  color: var(--accent-2);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}

.lede {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 520px;
}

.main {
  display: grid;
  gap: 20px;
  animation: fadeUp 0.7s ease-out;
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
}

textarea {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1rem;
  background: #fffdf8;
  resize: vertical;
  min-height: 120px;
}

.panel__actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 20px rgba(183, 107, 43, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid rgba(35, 76, 63, 0.25);
  box-shadow: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
}

.swatch {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.swatch.germanic {
  background: color-mix(in srgb, var(--germanic), white 65%);
}

.swatch.loan {
  background: color-mix(in srgb, var(--loan), white 65%);
}

.swatch.unclear {
  background: color-mix(in srgb, var(--unclear), white 65%);
}

.output {
  min-height: 110px;
  border-radius: 16px;
  border: 1px dashed rgba(31, 29, 26, 0.2);
  padding: 14px 16px;
  background: #fffdf8;
  line-height: 1.6;
}

.output--plain {
  white-space: pre-wrap;
}

.word {
  padding: 1px 3px;
  border-radius: 6px;
}

.word.germanic {
  background: color-mix(in srgb, var(--germanic), white 60%);
}

.word.loan {
  background: color-mix(in srgb, var(--loan), white 60%);
}

.word.unclear {
  background: color-mix(in srgb, var(--unclear), white 60%);
}

.tooltip {
  position: fixed;
  z-index: 999;
  background: rgba(31, 29, 26, 0.95);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  max-width: 240px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip strong {
  color: #f8d7a3;
  font-weight: 600;
}

.tooltip__label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  opacity: 0.7;
}

.note {
  background: #fdf1df;
  color: var(--muted);
  font-size: 0.9rem;
}

.note code {
  font-family: "Menlo", "Courier New", monospace;
  font-size: 0.85rem;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .hero {
    padding: 14px 18px;
    margin: 0 -18px 18px;
  }

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

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

  button {
    width: 100%;
  }

  .panel__actions {
    flex-direction: column;
  }
}
