@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;1,400&family=Playfair+Display:ital,wght@0,600;0,700;0,900;1,600&family=EB+Garamond:wght@400;600;700&family=Inter:wght@400;500;600;700&family=Noto+Serif+Hebrew:wght@400;600;700&display=swap');

:root {
  --bg-page: radial-gradient(circle at 10% 5%, #f7f4ed 0, #fcfbf8 40%, #f0ebdE 100%);
  --card-bg: #ffffff;
  --panel-glass-bg: #fdfbf7;
  --layer-original-bg: #f3faf4;
  --layer-translation-bg: #fdfbf0;
  --layer-lexical-bg: #f1f6fc;
  --lex-cell-bg: #ffffff;
  --accent-gold: #c9a84c;
  --accent-gold-lt: #e8c96a;
  --ruby: #8B1C2A;
  --ruby-dk: #6e1520;
  --azul: #1B3A6B;
  --azul-lt: #2a5298;
  --ink: #1a1a1a;
  --ink-soft: #4b5563;
  --highlight-bg: #e3f1fb;
  --highlight-border: #1B3A6B;
  --table-border: #c9a84c;
  --outline: rgba(201, 168, 76, 0.28);
  --elev: 0 4px 20px rgba(26, 26, 26, 0.08);
  --radius: 12px;
  --teal: #1B3A6B;
  --hebrew-font-size: 32px;
  --western-font-size: 16px;
  --workspace-zoom: 1;
}

[data-theme="sepia"] {
  --bg-page: #f4ecdc;
  --card-bg: #fdfbf7;
  --panel-glass-bg: #eee4d0;
  --layer-original-bg: #e8ded0;
  --layer-translation-bg: #f2e6cf;
  --layer-lexical-bg: #e5ded2;
  --lex-cell-bg: #fdfbf7;
  --accent-gold: #a67c38;
  --ruby: #7a2815;
  --ink: #2b1d12;
  --ink-soft: #634833;
  --highlight-bg: #ecd9b5;
  --highlight-border: #a67c38;
  --table-border: #a67c38;
  --outline: rgba(100, 65, 25, 0.2);
  --teal: #43604f;
}

[data-theme="night"] {
  --bg-page: #0f1117;
  --card-bg: #181b24;
  --panel-glass-bg: #202532;
  --layer-original-bg: #15221b;
  --layer-translation-bg: #262115;
  --layer-lexical-bg: #151e2c;
  --lex-cell-bg: #1e2433;
  --accent-gold: #e2b755;
  --ruby: #f87171;
  --ink: #f1f5f9;
  --ink-soft: #94a3b8;
  --highlight-bg: #1e3a8a;
  --highlight-border: #60a5fa;
  --table-border: #d4af37;
  --outline: rgba(255, 255, 255, 0.12);
  --elev: 0 14px 40px rgba(0, 0, 0, 0.55);
  --teal: #38bdf8;
}

[data-theme="nordic"] {
  --bg-page: #edf2f7;
  --card-bg: #ffffff;
  --panel-glass-bg: #f1f6fa;
  --layer-original-bg: #f0f7f4;
  --layer-translation-bg: #fef9ed;
  --layer-lexical-bg: #eef5fa;
  --lex-cell-bg: #ffffff;
  --accent-gold: #3182ce;
  --ruby: #2b6cb0;
  --ink: #1a202c;
  --ink-soft: #4a5568;
  --highlight-bg: #bee3f8;
  --highlight-border: #3182ce;
  --table-border: #cbd5e0;
  --outline: rgba(0, 0, 0, 0.12);
  --teal: #2c7a7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Lato', 'Inter', -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--ink);
  min-height: 100vh;
}

.labshell {
  min-height: 100vh;
  width: min(1200px, 95vw);
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(0.75rem, 2vw, 1.4rem) 2.5rem;
}

h1, h2, h3 {
  margin: 0;
  font-family: 'Playfair Display', 'EB Garamond', Georgia, serif;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--outline);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--elev);
  color: var(--ink);
}

.panel-glass {
  background: var(--panel-glass-bg);
  border-left: 5px solid var(--accent-gold);
}

.lab-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lab-controls-dock {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.lab-content-dock {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  min-width: 0;
  zoom: var(--workspace-zoom);
}

.layout-dock-top {
  display: flex;
  flex-direction: column;
}

.layout-dock-bottom {
  display: flex;
  flex-direction: column;
}

.layout-dock-left {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.layout-dock-right {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 400px);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .layout-dock-left,
  .layout-dock-right {
    display: flex;
    flex-direction: column;
  }
}

.lab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.brand h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.45rem);
  line-height: 1;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  background: #2d7d8c;
  color: #f4fcff;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.control-row {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 0.6rem 0.7rem;
  align-items: center;
}

.control-row.wrap {
  margin-top: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.accordion-card {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.control-main-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  flex: 1;
}

.ref-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a0a00;
}

.ref-input {
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.45rem 0.8rem;
  width: 140px;
  background: #fff;
  border: 1.5px solid #c9a84c;
  color: #8b1c2a;
}

.btn-load-primary {
  background: linear-gradient(135deg, #8b1c2a, #68111e) !important;
  color: #fff !important;
  font-weight: 600;
  border: 0 !important;
  box-shadow: 0 2px 6px rgba(139, 28, 42, 0.25);
}

.btn-secondary-link {
  background: #fdfbf7;
  border: 1px solid #d4d4dc;
  font-size: 0.85rem;
}

.btn-accordion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #4b5563;
}

.btn-accordion-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #111827;
}

.toggle-icon {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.accordion-content {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.2s ease;
}

.custom-colors-row {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.04);
  border: 1px dashed var(--outline);
  border-radius: 10px;
}

.custom-colors-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  display: block;
}

.custom-colors-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
}

.color-picker-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.color-picker-label input[type="color"] {
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--outline);
  cursor: pointer;
  background: transparent;
}

.accordion-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.accordion-title-group h2 {
  margin: 0;
  font-size: 1.15rem;
}

.badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  background: #eef6f9;
  color: #1b4f6b;
  border-radius: 999px;
}

.integration-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem 1rem;
  margin-top: 0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #3b3b48;
}

.form-group input {
  width: 100%;
}

.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
}

label {
  font-size: 0.9rem;
  color: #2f2f3a;
}

input,
select,
button {
  border-radius: 10px;
  border: 1px solid #d4d4dc;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: #1f2937;
  background: #fff;
}

input.wide,
select.wide,
button.wide {
  min-width: 160px;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #fff, #f0f0f0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary-highlight {
  background: linear-gradient(135deg, #1b4f6b, #2e6ea7) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  border: 1px solid #143d54 !important;
  box-shadow: 0 4px 12px rgba(27, 79, 107, 0.25) !important;
}

.btn-primary-highlight:hover {
  background: linear-gradient(135deg, #143d54, #245887) !important;
  box-shadow: 0 6px 16px rgba(27, 79, 107, 0.35) !important;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.1);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 0.2rem;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.note-editor:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid #2f6d87;
  outline-offset: 2px;
}

.verse-layer {
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
  min-height: 120px;
}

.verse-original {
  background: var(--layer-original-bg);
}

.verse-translation {
  background: var(--layer-translation-bg);
}

.verse-lexical {
  background: var(--layer-lexical-bg);
}

.layer-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.token-line {
  min-height: 84px;
  line-height: 1.95;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.token-line[dir="rtl"] {
  direction: rtl;
}

.token-line[dir="ltr"] {
  direction: ltr;
}

.original-token {
  border: 0;
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
  background: transparent;
  font-family: 'Noto Serif Hebrew', 'SBL Hebrew', 'Ezra SIL', 'Times New Roman', serif;
  font-size: var(--hebrew-font-size);
}

.original-token:hover {
  background: rgba(255, 255, 255, 0.33);
}

.original-token.selected {
  background: #bde8ff;
  box-shadow: 0 0 0 2px rgba(13, 106, 173, 0.35);
}

.original-token .note-badge {
  font-family: 'Inter', sans-serif;
  font-size: 0.62rem;
  color: #fff;
  background: #005f9e;
  border-radius: 999px;
  margin-left: 0.25rem;
  padding: 0.04rem 0.24rem;
  min-width: 1rem;
  text-align: center;
  display: inline-grid;
  place-items: center;
}

.seg-root {
  font-weight: 700;
}

.seg-affix {
  color: var(--teal);
}

.seg-neutral {
  color: #1a1a1a;
}

.seg-mark {
  opacity: 0.85;
}

.translation-line {
  font-size: var(--western-font-size);
  font-family: 'EB Garamond', 'Times New Roman', serif;
  direction: ltr !important;
  text-align: left;
  display: block !important;
  min-height: auto;
  line-height: 1.6;
}

.translation-highlight {
  color: var(--ruby);
  font-weight: 600;
}

.lex-top {
  font-family: 'Noto Serif Hebrew', 'Times New Roman', serif;
  font-size: calc(var(--hebrew-font-size) * 0.72);
  font-weight: 700;
}

.lex-bottom {
  font-family: 'Lato', 'Inter', sans-serif;
  font-size: calc(var(--western-font-size) * 0.85);
  color: var(--ruby);
}

/* CONTROLES DE TAMANHO DE FONTE E ZOOM */
.control-sizing-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--outline);
  border-radius: 10px;
}

.sizing-control-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sizing-control-item label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.sizing-value {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid var(--accent-gold);
  color: #8B6914;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.range-with-buttons {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.range-with-buttons input[type="range"] {
  flex: 1;
  accent-color: var(--ruby);
  cursor: pointer;
}

.btn-size-step {
  border: 1px solid var(--outline);
  background: #ffffff;
  color: var(--ink);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-size-step:hover {
  border-color: var(--accent-gold);
  background: #fdfbf7;
  color: var(--ruby);
}

.btn-size-reset {
  border: 1px solid var(--accent-gold);
  background: rgba(201, 168, 76, 0.12);
  color: #8B6914;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* TOGGLES DOS CAMPOS DA DEFINIÇÃO */
.control-group-definition-fields {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--outline);
  border-radius: 10px;
}

.definition-fields-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ruby);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.definition-toggles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem 1.2rem;
}

.lexical-grid {
  display: grid;
  row-gap: 0.75rem;
  column-gap: 0.65rem;
}

.lexical-grid[dir="rtl"],
.lex-row[dir="rtl"] {
  direction: rtl;
}

.lexical-grid[dir="ltr"],
.lex-row[dir="ltr"] {
  direction: ltr;
}

.lex-row {
  display: grid;
  gap: 0.65rem;
}

.lex-cell {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 10px;
  padding: 0.45rem;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.lex-top {
  font-family: 'Noto Serif', 'SBL Hebrew', 'Ezra SIL', serif;
  font-size: clamp(1.05rem, 2.1vw, 1.6rem);
  line-height: 1.25;
}

.lex-bottom {
  margin-top: 0.22rem;
  color: var(--ruby);
  font-size: clamp(0.85rem, 1.3vw, 1rem);
  line-height: 1.15;
}

.notes-notice {
  background: #fff8e2;
}

.notes-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  min-height: 78px;
}

.note-item {
  margin-bottom: 0.45rem;
}

.note-item-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.note-number {
  display: inline-grid;
  place-items: center;
  background: #0f5f8a;
  color: #f8fcff;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  font-weight: 700;
}

.note-word {
  font-size: 0.78rem;
  color: #334155;
}

.note-remove {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #7f1d2f;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}

.note-body {
  margin: 0.3rem 0 0.65rem;
  border: 1px dashed #d9a3a8;
  padding: 0.5rem 0.65rem;
  min-height: 58px;
  border-radius: 8px;
  background: #fff;
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: plaintext;
  font-family: 'Lato', 'Inter', -apple-system, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
}

.note-editor-wrap {
  margin-top: 0.7rem;
}

.note-editor-label {
  margin-bottom: 0.34rem;
  color: #1e293b;
  font-size: 0.84rem;
}

.note-editor {
  min-height: 120px;
  border: 1px solid #d4d4dc;
  border-radius: 10px;
  background: #fff;
  padding: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.small {
  margin: 0.3rem 0;
  color: #5b6675;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 0;
  background: #0b4f77;
  color: #fff;
  font-size: 1.3rem;
  box-shadow: 0 12px 28px rgba(7, 45, 73, 0.3);
  z-index: 3;
}

[hidden] {
  display: none !important;
}

.tooltip {
  position: fixed;
  max-width: min(360px, 82vw);
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(17, 24, 39, 0.18);
  padding: 0.65rem;
  box-shadow: 0 16px 28px rgba(17, 24, 39, 0.2);
  z-index: 999;
  font-size: 0.87rem;
}

.tooltip .muted {
  color: #5f6a79;
  font-size: 0.8rem;
}

.tooltip .row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.24rem;
}

.tooltip .label {
  color: #475569;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem;
  z-index: 999;
}

.modal[hidden],
.tooltip[hidden] {
  display: none !important;
}

.modal-card {
  background: #fff;
  width: min(720px, 95vw);
  border-radius: 14px;
  border: 1px solid var(--outline);
  box-shadow: 0 20px 55px rgba(17, 24, 39, 0.3);
  padding: 1rem;
}

.modal-card button {
  margin-left: auto;
  display: block;
}

.legend-content {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.52rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.legend-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.45rem;
  background: #f8fbff;
}

.legend-key {
  font-family: 'SFMono-Regular', ui-monospace, monospace;
  font-weight: 700;
  color: #1f4e8c;
  margin-right: 0.5rem;
}

.note-item.empty,
.notes-note {
  color: #586171;
}

.notes-note {
  margin-top: 0.55rem;
}

@media (max-width: 930px) {
  .control-row {
    grid-template-columns: 1fr;
  }

  .control-row.wrap {
    grid-template-columns: 1fr;
  }

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

  .original-token {
    font-size: 1.65rem;
  }

  .lex-cell {
    min-height: 100px;
  }
}

@media (max-width: 760px) {
  .lex-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .token-line {
    justify-content: flex-start;
  }
}
