@font-face {
  font-family: 'LinzklarRounded';
  src: url('https://yasusho.github.io/linmarn_font_project/fonts/rounded/linzklar_rounded.woff') format('woff');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  font-size: 15px;
  color: #222;
  background: #f5f5f5;
}

/* ── Header ── */
header {
  background: #2c3e50;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 1.3rem; flex: 1; }

.header-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.font-toggle-btn { font-family: 'LinzklarRounded', serif; font-size: 1rem; min-width: 2rem; }

/* When script font is disabled, suppress LinzklarRounded everywhere */
.no-script-font .script,
.no-script-font .token-script,
.no-script-font .font-toggle-btn { font-family: serif !important; }

.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.8);
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.tab.active {
  background: white;
  color: #2c3e50;
  border-color: white;
}
a.tab { text-decoration: none; }

/* ── Layout ── */
main {
  padding: 20px 24px;
  max-width: 900px;
  margin: 0 auto;
}

/* ── Search controls ── */
.search-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-controls input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
.search-controls select {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

/* ── Dictionary entries ── */
.entry {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.entry.highlighted {
  border-color: #3498db;
  background: #eaf4fc;
}
.entry.missing-frequent {
  background: #fdf0f0;
  border-color: #e8b4b8;
  cursor: pointer;
}
.entry.missing-frequent:hover {
  background: #fde3e3;
  border-color: #d98a90;
}
.missing-section-heading {
  font-size: 0.85rem;
  font-weight: bold;
  color: #c0392b;
  margin-bottom: 8px;
}
.entry-list-heading {
  font-size: 0.85rem;
  font-weight: bold;
  color: #555;
  margin-bottom: 8px;
  margin-top: 16px;
}

.entry-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.lemma {
  font-size: 1.2rem;
  font-weight: bold;
}
.lemma-stem {
  font-size: 1rem;
  font-weight: normal;
  color: #888;
}
.script {
  font-size: 1.4rem;
  font-family: 'LinzklarRounded', serif !important;
}
.pos {
  font-size: 0.8rem;
  color: #777;
  font-style: italic;
  background: #f0f0f0;
  padding: 2px 7px;
  border-radius: 3px;
}
.conjugation-class {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 6px;
}
.definitions {
  padding-left: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.notes {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
}

.cognates {
  border-left: 3px double #666;
  padding-left: 3px;
}

.entry-components {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.components-label {
  font-size: 0.8rem;
  color: #888;
}

.corpus-link {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #3498db;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Entry filter banner ── */
#entry-filter-banner[hidden] { display: none; }
#entry-filter-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: hsl(124, 71%, 91%);
  border: 1px solid hsl(124, 70%, 53%);
  border-radius: 4px;
  font-size: 0.85rem;
  color: hsl(124, 64%, 39%);
  white-space: nowrap;
}
#entry-filter-clear {
  background: none;
  border: none;
  color: hsl(124, 64%, 39%);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 2px;
}
#entry-filter-clear:hover { background: hsla(124, 70%, 53%, 0.2); }

/* ── Corpus sentences ── */
.sentence {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 14px;
}
.sentence.highlighted {
  border-color: #3498db;
  background: #eaf4fc;
}
.source {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 8px;
}

/* Interlinear gloss: each token is a small column */
.interlinear {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  font-family: 'Menlo', 'Arial', monospace;
}
.token {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.token.mismatch {
  background: hsl(321, 100%, 75%);
  border-radius: 4px;
  outline: 2px solid hsl(306, 95%, 56%);
  padding: 2px 4px;
}
.entry-links {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.entry-link {
  font-size: 0.7rem;
  font-family: 'Menlo', 'Arial', monospace;
  padding: 1px 5px;
  border-radius: 3px;
}
.entry-link.found { background: #d6eaf8; color: #2471a3; cursor: pointer; }
.entry-link.found:hover { background: #aed6f1; }
.entry-link.missing { background: #fadbd8; color: #c0392b; font-weight: bold; cursor: pointer; }

.token-script { font-size: 1.2rem; font-family: 'LinzklarRounded', serif; }
.token-form   { font-size: 1rem; font-family: 'Menlo', 'Arial', monospace; }
.token-gloss  { font-size: 0.8rem; color: #888; }

.sentence-copy-row {
  margin-top: 8px;
}
.sentence-copy-row button {
  margin: 0 3px 0 0;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
}
.sentence-copy-row button:hover {
  background: #e4e4e4;
  border-color: #bbb;
  color: #444;
}

ruby rt { font-size: 70%;}

/* ── Entry modal ── */
dialog#entry-modal {
  border: none;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  padding: 0;
  margin: auto;
  max-width: 820px;
  width: 92vw;
}
dialog#entry-modal::backdrop { background: rgba(0,0,0,0.45); }

.modal-header {
  background: #2c3e50;
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px 8px 0 0;
}
.modal-header h2 { font-size: 1rem; font-weight: normal; }
.modal-header button {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}
.modal-header button:hover { background: rgba(255,255,255,0.2); }

.modal-body {
  display: flex;
  gap: 16px;
  padding: 16px;
}
.modal-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.modal-form label, .field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #555;
}
.modal-form small { font-weight: normal; color: #aaa; }
.modal-form input, .modal-form select {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
.def-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}
.def-gloss { width: 90px; flex-shrink: 0; }
.def-definition { flex: 1; min-width: 0; }
.def-row button {
  background: none;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
  padding: 4px 7px;
  color: #aaa;
  flex-shrink: 0;
}
.def-row button:hover { color: #c0392b; border-color: #c0392b; }
#field-conjugation:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
#add-def-btn {
  margin-top: 2px;
  background: none;
  border: 1px dashed #aaa;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #777;
  align-self: flex-start;
}
#add-def-btn:hover { border-color: #2c3e50; color: #2c3e50; }

.modal-output {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.output-header .field-label { flex-direction: row; align-items: center; }
#copy-json-btn {
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}
#copy-json-btn:hover { background: #3d5166; }
#json-output {
  flex: 1;
  font-family: 'Menlo', 'Arial', monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  background: #f8f8f8;
  resize: none;
  min-height: 200px;
}

.translation {
  font-style: italic;
  color: #555;
  font-size: 0.95rem;
}

.references-list {
  padding: 1rem 1rem 1rem 2.5rem;
  line-height: 1.8;
}

.references-list li {
  word-break: break-all;
}

.references-list a {
  color: #2471a3;
}

.source a {
  text-decoration: none;
  font-weight: normal;
}

.source a:hover {
  text-decoration: underline;
}

@keyframes ref-flash {
  0%   { background-color: #fef08a; }
  100% { background-color: transparent; }
}

.ref-highlight {
  animation: ref-flash 1.8s ease-out;
}

.source-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#source-stats {
  font-size: 0.8rem;
  color: #555;
}

.register-switcher {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.register-btn {
  padding: 2px 8px;
  font-size: 0.75rem;
  background: #f0f0f0;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
}

.register-btn:hover {
  background: #e4e4e4;
  border-color: #bbb;
  color: #444;
}

.register-btn.active {
  background: #2c3e50;
  color: white;
  border-color: #2c3e50;
}
