:root {
  --bg: #f6f3ea;
  --paper: #fffef9;
  --ink: #1f2937;
  --muted: #637083;
  --line: #d7d2c5;
  --accent: #c44900;
  --accent-2: #0f766e;
  --accent-3: #204e8a;
  --shadow: 0 8px 30px rgba(20, 35, 60, 0.12);
  /* Part-of-speech colors (Hebrew/Greek interlinear) */
  --verb-primary:         #8B0000;
  --verb-secondary:       #FF9999;
  --noun-primary:         #006400;
  --noun-secondary:       #A4D3A2;
  --pronoun-primary:      #008080;
  --pronoun-secondary:    #B2DFDE;
  --adjective-primary:    #00008B;
  --adjective-secondary:  #B3D1FF;
  --adverb-primary:       #4B0082;
  --adverb-secondary:     #D1B3FF;
  --preposition-primary:  #FF8C00;
  --preposition-secondary:#FFD1A4;
  --conjunction-primary:  #9400D3;
  --conjunction-secondary:#E6B3FF;
  --particle-primary:     #B8860B;
  --particle-secondary:   #FFECB3;
  --suffix-primary:       #8B008B;
  --suffix-secondary:     #FFCCE6;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  background:
    radial-gradient(circle at 90% 10%, #ffe3c9 0, transparent 30%),
    radial-gradient(circle at 0% 100%, #d3efe9 0, transparent 35%),
    var(--bg);
}

h1, h2, h3 {
  font-family: 'Literata', serif;
  margin: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  backdrop-filter: blur(8px);
}

.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand h1 { font-size: clamp(1.1rem, 2.5vw, 1.6rem); }
.brand p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.88rem; }
.brand-dot {
  width: 14px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.top-actions { display: flex; gap: 0.5rem; }

.layout {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1.5fr 0.8fr;
  gap: 1rem;
}

.layout.search-only,
.layout.workspace-only {
  width: min(1050px, 100%);
  grid-template-columns: 1fr;
}

.search-panel, .workspace { min-width: 0; }

.search-card, .pane, .result {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.search-card { padding: 1rem; }
.label { display: block; font-weight: 700; margin-bottom: 0.6rem; }
.search-row { display: flex; gap: 0.6rem; }
.search-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 0.82rem;
  font-size: 1rem;
}
.hint { color: var(--muted); margin: 0.6rem 0 0; }

/* Book-scope selector */
.scope-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.65rem;
}
.scope-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-right: 0.1rem;
  white-space: nowrap;
}
.scope-btn {
  font-size: 0.74rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
  white-space: nowrap;
}
.scope-btn:hover { border-color: var(--accent-3); color: var(--accent-3); }
.scope-btn.active {
  background: var(--accent-3);
  border-color: var(--accent-3);
  color: #fff;
}
.scope-divider {
  display: block;
  width: 1px;
  height: 1.1em;
  background: var(--line);
  margin: 0 0.15rem;
}

/* Results head row */
.results-head {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.results-head h2 { margin: 0; }
.results-head-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.result-count-badge {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}
.per-page-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.per-page-select {
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

/* Pagination */
.search-pagination {
  margin-top: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}
.page-buttons {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
}
.page-btn {
  font-size: 0.78rem;
  padding: 0.22rem 0.55rem;
  min-width: 2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.page-btn:hover:not(:disabled) { background: var(--accent-3); color: #fff; border-color: var(--accent-3); }
.page-btn.active { background: var(--accent-3); color: #fff; border-color: var(--accent-3); font-weight: 700; }
.page-btn:disabled { opacity: 0.38; cursor: default; }
.page-btn.page-prev,
.page-btn.page-next { font-size: 0.82rem; padding: 0.22rem 0.65rem; }
.page-ellipsis { font-size: 0.82rem; color: var(--muted); padding: 0 0.15rem; }
.pagination-summary {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

/* Word-study bar — sits between search card and results */
.word-study-bar {
  margin-top: 0.75rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent-3) 30%, var(--line));
  background: color-mix(in srgb, var(--accent-3) 6%, var(--paper));
  padding: 0.6rem 0.9rem;
}

.ws-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.ws-bar-label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent-3);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.ws-bar-hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.ws-bar-link {
  font-size: 0.82rem;
  color: var(--accent-3);
  text-decoration: none;
  margin-left: auto;
}
.ws-bar-link:hover { text-decoration: underline; }

.ws-bar-secondary .ws-bar-label { color: var(--muted); font-weight: 500; }
.ws-bar-secondary .btn { margin-left: auto; }

.btn-sm {
  font-size: 0.74rem;
  padding: 0.2rem 0.5rem;
}

.results-wrap {
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.results { display: grid; gap: 0; }

.result {
  padding: 0.58rem 0.65rem;
  background: var(--paper);
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  transform: translateY(10px);
  opacity: 0;
  animation: rise 220ms ease forwards;
}

.result:last-child {
  border-bottom: none;
}

@keyframes rise {
  to { transform: translateY(0); opacity: 1; }
}

.ref {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--accent-3);
  cursor: pointer;
}

.text { margin-top: 0.35rem; line-height: 1.42; }
.text eng { cursor: pointer; }
.text .tmp-hl-red { background: lightcoral; }
.text .tmp-hl-tan { background: wheat; }
.text .tmp-hl-grn { background: lightgreen; }
.text .tmp-hl-pnk { background: pink; }
.text .tmp-hl-lav { background: lavender; }
.text .tmp-hl-blu {
  background: darkslateblue;
  color: #fff;
}
.text .tmp-hl-red,
.text .tmp-hl-tan,
.text .tmp-hl-grn,
.text .tmp-hl-pnk,
.text .tmp-hl-lav,
.text .tmp-hl-blu {
  border-radius: 3px;
}

.xref {
  margin-top: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.xref-body {
  padding: 0.3rem 0.45rem;
  overflow-x: auto;
}

.xref-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.xref-body td {
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  padding: 0.2rem 0.3rem;
}

.xref-body tr:last-child td { border-bottom: none; }

/* Phrase header rows (legacy .text-bg-primary) */
.xref-body .text-bg-primary td,
.xref-body td.text-bg-primary {
  background: var(--accent-3);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.18rem 0.35rem;
}

/* Summary refs row (top compact section) */
.xref-body tr:has(> td[width="150"]) td:first-child {
  font-weight: 600;
  color: var(--accent-3);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Note rows */
.xref-body .text-bg-warning td,
.xref-body td.text-bg-warning {
  background: #fff3cd;
  color: #664d03;
  font-size: 0.78rem;
  padding: 0.15rem 0.35rem;
}

.xref-body .table-group-divider td {
  border-top: 2px solid var(--accent-3);
}

.xref-body a {
  color: var(--accent-3);
  text-decoration: none;
}

.xref-body a:hover { text-decoration: underline; }

.word-study-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: #fff;
  color: var(--accent-3);
  margin: 0.2rem 0.2rem 0 0;
  cursor: pointer;
  font-weight: 600;
}

.word-study-chip.active {
  background: var(--accent-3);
  color: #fff;
}

.word-study-layout {
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  align-items: start;
}

.word-study-page-head h2 {
  font-size: 1.25rem;
}

.word-study-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 0.7rem;
}

.word-study-primary,
.word-study-right {
  min-width: 0;
}

.word-study-right {
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.word-study-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.ws-study-name-editor {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ws-study-name-editor input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.28rem 0.45rem;
  font-size: 0.8rem;
  min-width: 190px;
}

.word-study-header h4 {
  margin: 0;
  font-size: 1rem;
}

.word-study-stats-inline {
  font-size: 0.82rem;
  color: var(--muted);
}

.word-study-settings,
.word-study-categories,
.word-study-stats,
.word-study-observations {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  background: #fff;
}

.word-study-settings h5,
.word-study-categories h5,
.word-study-stats h5,
.word-study-observations h5 {
  margin: 0 0 0.4rem;
  font-size: 0.86rem;
}

.word-study-table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: auto;
}

.ws-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.ws-term-filter-bar {
  background: #f4f7f0;
}

.ws-bulk-assign {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.45rem;
  border-bottom: 1px solid var(--line);
  background: #fff8e9;
}

.ws-bulk-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #6a4e07;
}

.ws-bulk-assign select {
  font-size: 0.76rem;
  padding: 0.14rem 0.3rem;
}

.ws-filter-link {
  --ws-filter-bg: #fff;
  --ws-filter-border: var(--accent-3);
  --ws-filter-fg: var(--accent-3);
  border: 1px solid var(--ws-filter-border);
  background: var(--ws-filter-bg);
  color: var(--ws-filter-fg);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  line-height: 1.4;
  transition: filter 0.15s, box-shadow 0.15s;
}

.ws-filter-link:hover {
  filter: brightness(0.95);
}

.ws-filter-link.active {
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.ws-occ-table .btn + .btn {
  margin-left: 0.3rem;
}

.ws-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.ws-table th,
.ws-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.4rem;
  text-align: left;
  vertical-align: top;
}

.ws-table thead th {
  background: #f7fafc;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ws-table tr:last-child td {
  border-bottom: none;
}

.ws-table input,
.ws-table select,
.word-study-add-category input,
.word-study-add-term input,
.word-study-add-term select,
.ws-occ-table select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.42rem;
  font-size: 0.8rem;
}

.word-study-add-term,
.word-study-add-category {
  display: grid;
  grid-template-columns: 2.4fr 1fr auto;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.term-lock {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
}

.ws-category-list {
  margin: 0.45rem 0 0;
  padding-left: 1rem;
  font-size: 0.8rem;
}

.ws-category-table {
  margin-top: 0.45rem;
}

.ws-category-name-cell {
  width: 88%;
}

.ws-category-name-stack {
  display: grid;
  gap: 0.3rem;
}

.ws-category-inline-color {
  max-width: 128px;
}

.ws-category-actions-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.ws-color-dropdown {
  position: relative;
  display: inline-block;
}

.ws-color-dropdown-toggle {
  width: 112px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--swatch);
  position: relative;
  cursor: pointer;
}

.ws-color-dropdown-toggle::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-35%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.65);
}

.ws-color-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 112px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 20;
}

.ws-color-option {
  width: 100%;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: var(--swatch);
  margin: 0;
  cursor: pointer;
}

.ws-color-option + .ws-color-option {
  margin-top: 3px;
}

.ws-color-option.active {
  outline: 2px solid #111;
  outline-offset: -1px;
}

.word-study-canvas :disabled {
  opacity: 0.68;
  cursor: not-allowed;
}

.ws-type-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  border: 1px solid transparent;
  vertical-align: middle;
}

.ws-type-english { background: #eef2ff; color: #1e3a8a; border-color: #c7d2fe; }
.ws-type-phrase { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.ws-type-hebrew { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.ws-type-greek { background: #ecfeff; color: #155e75; border-color: #67e8f9; }
.ws-type-strongs_hebrew { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.ws-type-strongs_greek { background: #dcfce7; color: #166534; border-color: #86efac; }

.ws-occ-context td {
  background: #fbfdff;
}

/* Occurrence note */
.ws-occ-note-area {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--line);
}

.ws-occ-note-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font-size: 0.78rem;
  resize: vertical;
  font-family: inherit;
}

/* Study observations */
.word-study-observations {
  margin-top: 1rem;
}

.word-study-add-observation {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.word-study-add-observation textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  resize: vertical;
  font-family: inherit;
}

.ws-observations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ws-observation-card {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

.ws-observation-body {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  resize: vertical;
  font-family: inherit;
  background: #fff;
}

.ws-observation-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.ws-empty-note {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
}

.word-study-canvas {
  display: block;
  margin-top: 0.4rem;
}

.word-occurrence-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.77rem;
  color: var(--muted);
}

.occ-strongs {
  color: var(--accent-3);
  font-weight: 700;
}

.word-occurrence-token {
  font-weight: 700;
  margin-top: 0.2rem;
}

.word-occurrence-verse {
  font-size: 0.83rem;
  line-height: 1.35;
  margin-top: 0.15rem;
}

.word-occurrence-verse eng,
.word-occurrence-verse grk { cursor: pointer; }

/* Reference cell — hosts the suppress × */
.ws-occ-ref-cell {
  position: relative;
  padding-right: 1.6rem;
  white-space: nowrap;
}

/* Small red suppress × button */
.ws-suppress-x {
  position: absolute;
  top: 0.1rem;
  right: 0.2rem;
  background: none;
  border: none;
  color: #c00;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.ws-suppress-x:hover { opacity: 1; }

/* Verse text + chapter button side by side */
.ws-verse-and-chapter {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.ws-verse-and-chapter .word-occurrence-verse {
  margin-top: 0;
}
.ws-chapter-btn {
  flex-shrink: 0;
  margin-top: 0;
  align-self: flex-start;
}
.ws-verse-context-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.ws-main-verse-row {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 0;
}
.ws-main-verse-text {
  flex: 1;
  min-width: 0;
}
.ws-ctx-add-btn {
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
  width: 1.2rem;
  height: 1.2rem;
  min-width: 1.2rem;
  min-height: 1.2rem;
  padding: 0;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
}
.ws-ctx-add-btn:hover { opacity: 1; }
.ws-ctx-verse {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.78rem;
  line-height: 1.3;
  padding: 0.15rem 0.3rem;
  background: var(--surface-alt, #f7f7f7);
  border-left: 2px solid var(--line, #ccc);
  border-radius: 0 3px 3px 0;
  position: relative;
}
.ws-ctx-ref {
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted, #666);
  font-size: 0.72rem;
  flex-shrink: 0;
}
.ws-ctx-text {
  flex: 1;
  min-width: 0;
}
.ws-ctx-remove {
  background: none;
  border: none;
  color: #c00;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.5;
}
.ws-ctx-remove:hover { opacity: 1; }

/* Read-only occurrence note (locked mode) */
.ws-occ-note-text {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-style: italic;
}

/* Locked display: plain text in place of form fields */
.ws-locked-value {
  font-size: 0.85rem;
}
.ws-study-name-locked {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Small color swatch dot in locked category rows */
.ws-cat-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.ws-category-locked-cell {
  padding: 0.35rem 0.5rem;
}

/* Locked observation body text */
.ws-observation-text {
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* Delete study button */
.ws-delete-study-btn { color: #c00; }

/* Subcategory decoration classes */
.ws-deco-bold            { font-weight: 700; }
.ws-deco-extra-bold      { font-weight: 900; }
.ws-deco-italic          { font-style: italic; }
.ws-deco-underline       { text-decoration: underline; }
.ws-deco-double-underline { text-decoration: underline double; }
.ws-deco-strikethrough   { text-decoration: line-through; }
.ws-deco-bold-underline  { font-weight: 700; text-decoration: underline; }
.ws-deco-italic-underline { font-style: italic; text-decoration: underline; }

/* Subcategory list inside category row */
.ws-subcategory-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.3rem;
  width: 100%;
}
.ws-subcategory-locked {
  margin-top: 0.2rem;
}
.ws-subcat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  width: 100%;
  min-width: 0;
  min-height: 28px;
}
.ws-subcat-deco-edit {
  font-size: 0.72rem;
  padding: 1px 3px;
  height: 26px;
  line-height: 1.2;
  box-sizing: border-box;
  width: 88px;
  min-width: 88px;
  flex: 0 0 88px;
}
.ws-subcat-name-edit {
  font-size: 0.75rem;
  padding: 2px 6px;
  height: 26px;
  line-height: 1.2;
  box-sizing: border-box;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  border: 1px solid var(--line, #ccc);
  border-radius: 3px;
}
.ws-subcat-save {
  font-size: 0.7rem;
  padding: 0 7px;
  height: 24px;
  line-height: 1;
  white-space: nowrap;
}
.ws-subcat-name {
  font-size: 0.75rem;
}
.ws-subcat-sep {
  color: var(--muted, #666);
  user-select: none;
}
.ws-subcat-delete {
  background: none;
  border: none;
  color: #c00;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 2px;
  line-height: 1;
}
.ws-subcat-action-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.3rem;
}
.ws-subcat-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  min-height: 28px;
}
.ws-subcat-action-row .ws-subcat-delete {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ws-add-subcat-btn {
  font-size: 0.72rem;
  margin-top: 0.35rem;
  padding: 1px 6px;
}
.ws-add-subcat-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.3rem;
  padding: 0.35rem;
  background: var(--surface, #fafafa);
  border: 1px dashed var(--line, #ccc);
  border-radius: 4px;
}
.ws-new-subcat-name {
  font-size: 0.82rem;
  padding: 2px 5px;
}
.ws-add-subcat-form select {
  font-size: 0.82rem;
  padding: 2px 4px;
}
.ws-add-subcat-btns {
  display: flex;
  gap: 0.3rem;
}

/* Subcategory checkboxes in occurrence rows */
.ws-occ-subcat-picker {
  position: static;
  margin-top: 0.3rem;
  display: block;
}
.ws-occ-subcat-toggle {
  font-size: 0.72rem;
  padding: 1px 7px;
}
.ws-occ-subcat-panel {
  position: fixed;
  z-index: 200;
  min-width: 320px;
  max-width: 520px;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 0;
  padding: 0.3rem 0;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #ccc);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}
.ws-occ-subcat-group {
  margin-top: 0;
}
.ws-occ-subcat-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: normal;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--line, #eee);
}
.ws-occ-subcat-label:last-child {
  border-bottom: none;
}
.ws-occ-subcat-label input[type="checkbox"] {
  cursor: pointer;
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}
.ws-occ-subcat-label > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Locked-mode assigned subcategory names in occurrence rows */
.ws-occ-subcat-names-locked {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
  margin-top: 0.2rem;
}

.ws-occ-selected-subcats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
  font-size: 0.75rem;
}

.ws-page-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin: 0.2rem 0 0.35rem;
}

.ws-page-meta {
  font-size: 0.75rem;
  color: var(--muted, #666);
  margin-right: 0.25rem;
}

.ws-occ-subcats td {
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

.ws-orig-under-verse {
  margin-top: 0.35rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.35rem;
}

.ws-orig-under-verse .word-block {
  min-width: 66px;
}

.word-occurrence-tools {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.chapter-context {
  border-top: 1px dashed var(--line);
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  display: grid;
  gap: 0.25rem;
}

.chapter-verse {
  font-size: 0.78rem;
  line-height: 1.3;
}

.chapter-verse.active {
  background: #eef6ff;
  border-radius: 6px;
  padding: 0.15rem 0.25rem;
}

.verse-actions {
  margin-top: 0.35rem;
  display: none;
  flex-wrap: wrap;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f4f8;
}

.result.panel-open .verse-actions { display: flex; }

.verse-tab {
  flex: 1 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  border-right: 1px solid var(--line);
  padding: 0.3rem 0.7rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}

.verse-tab:last-child { border-right: none; }

.verse-tab:hover {
  background: #e2e8f0;
  color: var(--ink);
}

.verse-tab.active {
  background: var(--accent-3);
  color: #fff;
}

.orig-wrap {
  margin-top: 0.3rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.3rem;
  overflow-x: auto;
}

.orig-loading {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.3rem;
}

/* ---------- Interlinear word-blocks (legacy layout) ---------- */
.scripture-block {
  display: flex;
  flex-flow: row wrap;
  justify-content: flex-start;
}

.scripture-block h6 {
  flex: 0 0 100%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-3);
  margin: 0.4rem 0 0.2rem;
  padding: 0;
}

.word-block-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  flex: 0 0 100%;
  margin-bottom: 0.5rem;
}

.word-block-container.hebrew-rtl {
  flex-direction: row-reverse;
  justify-content: flex-start;
  padding-right: 15px;
}

.word-block {
  border: 1px solid var(--accent-3);
  border-bottom: 2px solid var(--accent-2);
  cursor: default;
  text-align: center;
  background: #f0f8ff;
  min-width: 72px;
  max-width: 120px;
  padding: 6px 5px;
  margin: 3px 2px;
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
}

.word-block.verb   { background: var(--verb-secondary);        border-color: var(--verb-primary); }
.word-block.noun   { background: var(--noun-secondary);        border-color: var(--noun-primary); }
.word-block.pronoun{ background: var(--pronoun-secondary);     border-color: var(--pronoun-primary); }
.word-block.adjective{ background: var(--adjective-secondary); border-color: var(--adjective-primary); }
.word-block.adverb { background: var(--adverb-secondary);      border-color: var(--adverb-primary); }
.word-block.preposition{ background: var(--preposition-secondary); border-color: var(--preposition-primary); }
.word-block.conjunction{ background: var(--conjunction-secondary); border-color: var(--conjunction-primary); }
.word-block.particle{ background: var(--particle-secondary);   border-color: var(--particle-primary); }
.word-block.suffix { background: var(--suffix-secondary);      border-color: var(--suffix-primary); }

.interlinear-english {
  font-size: 0.78rem;
  color: var(--ink);
  min-height: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.interlinear-hebrew {
  font-size: 1.3em;
  color: var(--accent-3);
  margin: 3px auto 0;
  direction: rtl;
}

.interlinear-greek {
  font-size: 1.15em;
  color: var(--accent-3);
  margin: 3px auto 0;
}

.interlinear-transliteration {
  font-size: 0.68rem;
  color: var(--muted);
  font-style: italic;
  margin: 2px auto 0;
}

.interlinear-strongs {
  font-size: 0.7rem;
  color: var(--accent-2);
  margin: 2px auto 0;
  cursor: help;
}

.interlinear-strongs a {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.interlinear-pos {
  font-size: 0.66rem;
  color: var(--muted);
  margin: 2px auto 0;
  text-transform: capitalize;
}

.interlinear-louwnida {
  font-size: 0.7rem;
  color: var(--accent-2);
  margin: 2px auto 0;
}

.interlinear-morph {
  font-size: 0.68rem;
  margin: 3px auto 0;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: help;
  background: rgba(0,0,0,0.06);
  color: var(--ink);
  text-transform: capitalize;
}

.interlinear-morph.verb        { background: var(--verb-secondary);        color: var(--verb-primary); }
.interlinear-morph.noun        { background: var(--noun-secondary);        color: var(--noun-primary); }
.interlinear-morph.pronoun     { background: var(--pronoun-secondary);     color: var(--pronoun-primary); }
.interlinear-morph.adjective   { background: var(--adjective-secondary);   color: var(--adjective-primary); }
.interlinear-morph.adverb      { background: var(--adverb-secondary);      color: var(--adverb-primary); }
.interlinear-morph.preposition { background: var(--preposition-secondary); color: var(--preposition-primary); }
.interlinear-morph.conjunction { background: var(--conjunction-secondary); color: var(--conjunction-primary); }
.interlinear-morph.particle    { background: var(--particle-secondary);    color: var(--particle-primary); }
.interlinear-morph.suffix      { background: var(--suffix-secondary);      color: var(--suffix-primary); }

.claims-wrap {
  margin-top: 0.35rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.35rem;
}

.claims-list-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.claims-list {
  margin: 0 0 0.4rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
}

.claims-list li { margin-bottom: 0.15rem; }

.claims-list .claim-type-badge {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
}

.claims-form { display: grid; gap: 0.4rem; margin-top: 0.1rem; }

.claims-form-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 0.35rem;
}

.claims-field {
  position: relative;
  display: flex;
  flex-direction: column;
}

.claims-field.claims-full { grid-column: 1 / -1; }

.claims-label {
  position: absolute;
  top: 0;
  left: 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  padding: 0 0.25rem;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}

.claims-optional {
  font-weight: 400;
  font-size: 0.6rem;
  color: var(--accent-3);
}

.claims-form-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
}

.claims-form-footer .claims-field { flex: 1; }

.claim-select,
.claim-type-select,
.claims-textarea,
.claims-ev-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.45rem 0.3rem 0.45rem;
  font-size: 0.82rem;
  font-family: inherit;
}

.claims-textarea {
  resize: vertical;
  width: 100%;
}

.claim-select,
.claim-type-select,
.claims-ev-input {
  width: 100%;
}
  font-family: inherit;
}

.claims-ev-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  font-size: 0.82rem;
  width: 100%;
}

.claim-select,
.claim-type-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.32rem 0.45rem;
  min-width: 0;
  width: 100%;
  font-size: 0.82rem;
}

.result.panel-open .ref {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Logged-in toolbar icons */
.nav-tools {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.nav-icon:hover {
  background: var(--accent-3);
  color: #fff;
  border-color: var(--accent-3);
}

.nav-icon i { pointer-events: none; }

.workspace { display: grid; gap: 0.9rem; }
.pane { padding: 0.85rem; }
.pane h3 { margin-bottom: 0.45rem; }

.list {
  border-top: 1px dashed var(--line);
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  display: grid;
  gap: 0.5rem;
  max-height: 360px;
  overflow: auto;
}
.empty { color: var(--muted); }

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.56rem 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.btn.solid {
  background: linear-gradient(130deg, var(--accent), #ea580c);
  color: #fff;
  border-color: #b33f01;
}
.btn.ghost { background: #fff; color: var(--ink); }
.btn.full { width: 100%; }

.dialog-shell {
  position: relative;
  width: min(420px, 90vw);
  border: none;
  border-radius: 14px;
  padding: 1rem;
}

.close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
}

.stack { display: grid; gap: 0.6rem; margin-top: 0.6rem; }
.stack label { display: grid; gap: 0.2rem; font-size: 0.9rem; }
.stack input, .note-input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
}
.note-row { display: grid; gap: 0.35rem; margin-top: 0.45rem; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .workspace { order: -1; }
  .word-study-layout { grid-template-columns: 1fr; }
  .word-study-grid { grid-template-columns: 1fr; }
  .word-study-add-term,
  .word-study-add-category { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .claims-form-row { grid-template-columns: 1fr; }
  .word-block { min-width: 64px; padding: 4px; }
  .interlinear-english, .interlinear-transliteration { font-size: 0.7rem; }
}
