:root {
  --bg: #f3f0e9;
  --bg-deep: #ebe6dc;
  --card: rgba(255, 255, 255, 0.92);
  --text: #181816;
  --muted: #6d6b64;
  --line: #ded9ce;
  --line-strong: #cbc4b6;
  --input: #fbfaf7;
  --accent: #263f36;
  --accent-hover: #1e332b;
  --accent-soft: #edf2ef;
  --good: #176c46;
  --good-bg: #edf7f1;
  --good-line: #c8e5d4;
  --poor: #8a6500;
  --poor-bg: #fff8dc;
  --poor-line: #ead68a;
  --bad: #9a3a32;
  --bad-bg: #fbefed;
  --bad-line: #ebcbc6;
  --shadow: 0 30px 80px rgba(51, 45, 34, 0.12), 0 2px 8px rgba(51, 45, 34, 0.04);
  --radius-xl: 30px;
  --radius-lg: 20px;
  --radius-md: 15px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, rgba(255,255,255,.95) 0, rgba(255,255,255,0) 27rem),
    radial-gradient(circle at 90% 86%, rgba(209, 221, 214, .48) 0, rgba(209, 221, 214, 0) 28rem),
    linear-gradient(145deg, var(--bg), var(--bg-deep));
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding:
    max(34px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.checker-card {
  position: relative;
  width: min(100%, 790px);
  background: var(--card);
  border: 1px solid rgba(210, 204, 191, .88);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: clamp(26px, 5vw, 48px);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.checker-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), #6f8d80 55%, #b7c7bd);
}

.header { margin-bottom: 34px; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: .95rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 650px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 7vw, 4.35rem);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -0.045em;
}

.subtitle {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(.98rem, 2vw, 1.06rem);
  line-height: 1.55;
}

.mode-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 10px;
  width: fit-content;
  margin-top: 18px;
  padding: 8px 11px;
  border: 1px solid #dbe4df;
  border-radius: 999px;
  background: #f6f9f7;
  color: #41544c;
  font-size: .76rem;
  font-weight: 700;
}

.mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b8169;
  box-shadow: 0 0 0 4px rgba(75,129,105,.11);
}

.mode-detail {
  color: #738078;
  font-weight: 600;
}

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(251,250,247,.72);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field:focus-within {
  border-color: #9aaea4;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(38,63,54,.075);
}

.field-number {
  position: absolute;
  top: 14px;
  right: 14px;
  color: #aaa59a;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.field-label {
  padding-right: 36px;
  color: #4e504b;
  font-size: .77rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.field input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 3px 0 1px;
  outline: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.2;
}

.field input::placeholder {
  color: #b3afa6;
  opacity: 1;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  margin-top: 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  padding: 0 18px 0 21px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(38,63,54,.16);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.primary-button:hover {
  background: var(--accent-hover);
  box-shadow: 0 12px 30px rgba(38,63,54,.22);
}

.primary-button:active { transform: translateY(1px); }

.button-arrow {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  font-size: 1rem;
}

.form-error {
  margin: 10px 3px 0;
  color: var(--bad);
  font-size: .84rem;
  font-weight: 650;
}

.result {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  animation: result-in 260ms ease-out;
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.verdict {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.verdict.good {
  background: var(--good-bg);
  border-color: var(--good-line);
  color: var(--good);
}

.verdict.poor {
  background: var(--poor-bg);
  border-color: var(--poor-line);
  color: var(--poor);
}

.verdict.bad {
  background: var(--bad-bg);
  border-color: var(--bad-line);
  color: var(--bad);
}

.verdict-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.72);
  border: 1px solid currentColor;
  font-size: 1.2rem;
  font-weight: 900;
}

.verdict-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.verdict-text {
  display: block;
  font-size: clamp(1.08rem, 3vw, 1.28rem);
  line-height: 1.2;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 19px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 9px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 5.5vw, 2.45rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

.metric-value-small { font-size: clamp(1.25rem, 4vw, 1.8rem); }

.span-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-size: .86rem;
  font-weight: 800;
}

.section-hint {
  color: var(--muted);
  font-size: .75rem;
}

.span-list {
  display: grid;
  gap: 9px;
}

.span-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 13px;
  background: #f7f6f2;
}

.span-word {
  min-width: 0;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.span-match {
  min-width: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.no-span {
  color: var(--muted);
  font-size: .88rem;
}

.page-footer {
  color: #77736b;
  font-size: .72rem;
  letter-spacing: .03em;
}

@media (max-width: 640px) {
  .page-shell {
    place-items: start center;
    align-content: start;
    gap: 0;
    padding: 0;
  }

  .checker-card {
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding:
      calc(28px + env(safe-area-inset-top))
      18px
      calc(28px + env(safe-area-inset-bottom));
  }

  .checker-card::before { height: 4px; }
  .header { margin-bottom: 28px; }
  .brand-row { margin-bottom: 22px; }
  h1 { max-width: 340px; }
  .mode-note { border-radius: 16px; }
  .inputs-grid { grid-template-columns: 1fr; }
  .field { padding: 13px 14px; }
  .primary-button { min-height: 56px; }
  .result { margin-top: 26px; padding-top: 26px; }
  .metric { padding: 16px; }
  .span-row { grid-template-columns: minmax(0, 1fr) auto; }
  .detail-row { grid-template-columns: 1fr; gap: 6px; }
  .page-footer { display: none; }
}

@media (max-width: 390px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .span-row { align-items: start; grid-template-columns: 1fr; gap: 7px; }
  .span-match { width: fit-content; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Hiztegi-egiaztapena */
.dictionary-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.78);
  padding: 15px 17px;
}

.dictionary-status.loading {
  color: var(--muted);
}

.dictionary-status.warning {
  border-color: var(--poor-line);
  background: var(--poor-bg);
  color: var(--poor);
}

.dictionary-status.unavailable {
  color: var(--muted);
  background: #f7f6f2;
}

.dictionary-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(255,255,255,.66);
  font-size: .9rem;
  font-weight: 900;
}

.dictionary-copy {
  min-width: 0;
}

.dictionary-title {
  display: block;
  color: currentColor;
  font-size: .86rem;
  line-height: 1.35;
}

.dictionary-message {
  margin-top: 4px;
  color: #6d675b;
  font-size: .78rem;
  line-height: 1.5;
}

.dictionary-word {
  font-weight: 800;
  color: var(--text);
}

.dictionary-sources {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .72rem;
}

/* Hiztegietako definizioetarako estekak */
.dictionary-links {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 18px;
}

.dictionary-links-heading {
  margin-bottom: 12px;
}

.dictionary-link-list {
  display: grid;
  gap: 10px;
}

.dictionary-link-row {
  display: grid;
  grid-template-columns: minmax(110px, .75fr) minmax(0, 1.5fr);
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 13px;
  background: #f7f6f2;
}

.dictionary-link-word {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 8px;
  min-width: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.dictionary-lemma {
  color: var(--muted);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: .72rem;
  font-weight: 750;
}

.dictionary-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.dictionary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  padding: 7px 11px;
  text-decoration: none;
  font-size: .73rem;
  font-weight: 800;
  line-height: 1;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.dictionary-button:hover {
  border-color: #9aaea4;
  background: var(--accent-soft);
}

.dictionary-button:active {
  transform: translateY(1px);
}

.dictionary-button:focus-visible {
  outline: 3px solid rgba(38,63,54,.16);
  outline-offset: 2px;
}

@media (max-width: 540px) {
  .dictionary-link-row {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .dictionary-buttons {
    justify-content: flex-start;
  }
}
