:root {
  --ink: #1d1a16;
  --muted: #686057;
  --paper: #fbf8f2;
  --panel: #fffdf8;
  --line: #ddd3c4;
  --accent: #256f68;
  --accent-strong: #174b46;
  --warm: #b85f3f;
  --shadow: 0 18px 45px rgba(62, 45, 28, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  background:
    linear-gradient(135deg, rgba(37, 111, 104, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(184, 95, 63, 0.16), transparent 34%),
    repeating-linear-gradient(90deg, rgba(29, 26, 22, 0.035) 0 1px, transparent 1px 18px),
    var(--paper);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 16px;
  display: flex;
  align-items: flex-start;
}

.search-panel {
  width: 100%;
  padding: clamp(22px, 5vw, 44px);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.masthead {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-family: Candara, Optima, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 7vw, 3.35rem);
  line-height: 1;
  letter-spacing: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: Candara, Optima, sans-serif;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(270px, 0.52fr);
  align-items: flex-start;
  gap: 12px;
}

.search-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 8px;
}

input[type="search"] {
  min-width: 0;
  flex: 1 1 auto;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 111, 104, 0.18);
}

button {
  min-height: 46px;
  padding: 0 15px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  color: var(--accent-strong);
  background: rgba(37, 111, 104, 0.18);
  opacity: 1;
}

.status {
  min-height: 24px;
  margin: 12px 0;
  color: var(--muted);
}

.status.error {
  color: #9f351f;
}

.results-panel {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.count {
  min-width: 3ch;
  padding: 4px 9px;
  color: var(--accent-strong);
  font-family: Candara, Optima, sans-serif;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  border: 1px solid rgba(37, 111, 104, 0.28);
  border-radius: 999px;
}

.query-result {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(37, 111, 104, 0.08);
  border: 1px solid rgba(37, 111, 104, 0.32);
  border-radius: 6px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}


.filter-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid rgba(37, 111, 104, 0.32);
  border-radius: 999px;
}

.filter-button:hover,
.filter-button:focus-visible,
.filter-button.active {
  color: #fff;
  background: var(--accent);
}

.results-list {
  display: block;
  max-height: min(52vh, 460px);
  overflow-y: auto;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.result-row {
  min-height: 38px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow-wrap: anywhere;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.result-row-clickable {
  cursor: pointer;
}

.result-row-clickable:hover {
  background: rgba(37, 111, 104, 0.08);
}

.result-row-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(37, 111, 104, 0.12);
}

.results-list li:first-child {
  border-top: 1px solid var(--line);
}

.result-word {
  min-width: 0;
  font-weight: 700;
}

.result-annotations {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 4px;
  font-family: Candara, Optima, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.annotation {
  min-width: 2.4ch;
  padding: 2px 4px;
  color: var(--muted);
  text-align: center;
  border-radius: 4px;
}

.annotation-acennog {
  color: var(--accent-strong);
}

.annotation-diacen {
  color: var(--muted);
}

.annotation-trwm {
  color: #8f3d24;
}

.annotation-ysgafn {
  color: #4f6f8f;
}

.relation {
  padding: 2px 6px;
  font-size: 0.72rem;
  border-radius: 99px;
  background: var(--paper);
}

.relation-odl {
  color: var(--accent);
  border: 1px solid rgba(37, 111, 104, 0.28);
}

.relation-proest {
  color: var(--warm);
  border: 1px solid rgba(184, 95, 63, 0.28);
}

.query-result .result-row {
  min-height: 34px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.footer-actions {
  margin-top: 28px;
  font-family: Candara, Optima, sans-serif;
}

.footer-actions a {
  color: var(--warm);
  font-weight: 700;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

@media (max-width: 560px) {
  .app-shell {
    align-items: stretch;
    padding: 12px;
  }

  .search-panel {
    min-height: calc(100vh - 24px);
  }

  .search-row {
    display: block;
  }

  .search-actions {
    margin-top: 12px;
  }

  button {
    width: 100%;
  }

  .filter-button {
    flex: 1 1 auto;
    width: auto;
  }
}

.search-actions button {
  min-height: 0;
  height: 23px;
  padding: 0 10px;
  font-size: 0.86rem;
  line-height: 1;
}

/* Modal Overlay & Disclaimer */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(29, 26, 22, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(90%, 560px);
  max-height: 85vh;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 5vw, 32px);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-content h2 {
  font-size: 1.5rem;
  color: var(--accent-strong);
  margin-top: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 12px;
  font-family: Georgia, "Palatino Linotype", serif;
}

.modal-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  overflow-y: auto;
  margin-bottom: 24px;
  padding-right: 8px;
}

.modal-body p {
  margin-bottom: 14px;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 14px;
}

.modal-body li {
  margin-bottom: 10px;
}

.modal-body a {
  color: var(--warm);
  font-weight: 700;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.modal-footer button {
  min-width: 160px;
  font-weight: 700;
}

/* About Page & Info Section */
.about-content {
  margin-top: 24px;
}

.about-section {
  margin-bottom: 32px;
}

.about-section h2 {
  font-size: 1.25rem;
  color: var(--accent-strong);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.about-section p {
  line-height: 1.6;
  margin-bottom: 12px;
}

.about-section ul {
  padding-left: 20px;
  line-height: 1.6;
}

.about-section li {
  margin-bottom: 8px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.license-block {
  background: rgba(29, 26, 22, 0.03);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}

.license-block h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-family: Candara, Optima, sans-serif;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.license-block pre {
  margin: 0;
  font-family: monospace, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  line-height: 1.4;
}

.footer-about-link {
  margin-right: 12px;
}