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

/* ── Global scrollbars ── */
* { scrollbar-color: var(--border) var(--surface); scrollbar-width: thin; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a48; }
::-webkit-scrollbar-corner { background: var(--surface); }

:root {
  --bg:       #0f0f14;
  --surface:  #18181f;
  --border:   #2a2a35;
  --gold:     #c9a84c;
  --gold-dim: #8a6f2e;
  --text:     #e2ddd6;
  --muted:    #7a7570;
  --accent:   #5b8dd9;
}

body { font-family: Georgia, serif; background: var(--bg); color: var(--text);
       display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
#sidebar { width: 240px; min-width: 160px; max-width: 500px; flex-shrink: 0;
           background: var(--surface); color: var(--text);
           overflow-y: auto; display: flex; flex-direction: column; }
#sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); }
#sidebar-top { display: flex; align-items: baseline; gap: 0.5rem; }
#home-link { font-size: 1.1rem; color: var(--gold); text-decoration: none; opacity: 0.8;
             transition: opacity 0.15s; flex-shrink: 0; }
#home-link:hover { opacity: 1; }
#sidebar-header h1 { font-size: 1rem; color: var(--text); }
#user-bar { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem;
            font-family: system-ui, sans-serif; font-size: 0.72rem; }
#user-name { color: var(--text); }
#user-role { padding: 0.1rem 0.4rem; border-radius: 8px; font-size: 0.65rem;
             background: var(--border); color: var(--muted); }
#user-role.role-admin { background: #2a1f0a; color: var(--gold); }
#user-role.role-user  { background: #0e1a2a; color: var(--accent); }
#logout-link, #login-link { color: var(--muted); text-decoration: none; margin-left: auto;
                             transition: color 0.12s; }
#logout-link:hover, #login-link:hover { color: var(--text); }
#sidebar-hint { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }
#export-link { display: inline-block; font-size: 0.7rem; color: var(--muted); text-decoration: none;
               margin-top: 0.4rem; font-family: system-ui, sans-serif; }
#export-link:hover { color: var(--accent); }
#section-list { flex: 1; overflow-y: auto; min-height: 0; scrollbar-color: var(--border) var(--surface); }
#section-list::-webkit-scrollbar { width: 6px; }
#section-list::-webkit-scrollbar-track { background: var(--surface); }
#section-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#section-list::-webkit-scrollbar-thumb:hover { background: #3a3a48; }
.sec { padding: 0.55rem 1rem; cursor: pointer; border-left: 3px solid transparent;
       font-size: 0.88rem; }
.sec:hover { background: rgba(255,255,255,0.04); }
.sec.active { background: rgba(255,255,255,0.04); border-left-color: var(--accent); }
.sec-name { color: var(--text); line-height: 1.35; }
.sec-abbr { font-size: 0.68rem; color: var(--muted); margin-top: 1px; font-family: monospace; }
.sec-pct  { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
.sec-bar  { height: 3px; background: var(--border); border-radius: 2px; margin-top: 4px; }
.sec-fill { height: 3px; background: var(--accent); border-radius: 2px; }
.text-heading { padding: 0.7rem 1rem 0.35rem;
                font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px;
                color: var(--muted); font-weight: bold;
                border-top: 1px solid var(--border); margin-top: 0.25rem;
                cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.text-heading:first-child { border-top: none; margin-top: 0; }
.text-heading:hover { color: var(--text); }
.text-heading::after { content: '▾'; font-size: 0.7rem; opacity: 0.6; transition: transform 0.15s; }
.text-heading.collapsed::after { transform: rotate(-90deg); }
.text-group.collapsed { display: none; }

/* ── Inline chapter list ── */
.chap-list { border-bottom: 1px solid var(--border); }
.chap-item { padding: 0.25rem 0.8rem 0.25rem 1.5rem; cursor: pointer; font-size: 0.74rem;
             color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
             border-left: 3px solid transparent; }
.chap-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }


/* ── Sidebar resizer ── */
#sidebar-resizer { width: 6px; flex-shrink: 0; cursor: col-resize;
                   background: var(--border); transition: background 0.15s;
                   user-select: none; }
#sidebar-resizer:hover { background: var(--accent); }

/* ── Panel (tag window) resizer ── */
#panel-resizer { position: fixed; top: 0; bottom: 0; width: 6px;
                 right: 320px; cursor: col-resize; background: var(--border);
                 display: none; z-index: 200; transition: background 0.15s;
                 user-select: none; }
#panel-resizer:hover { background: var(--accent); }
#panel-resizer.open { display: block; }

/* ── Main ── */
#main { flex: 1; overflow-y: auto; padding: 2.5rem 3rem; transition: margin-right .2s; }
#main.panel-open { margin-right: 330px; }
#text-area { max-width: 680px; }
#loading { color: var(--muted); font-style: italic; }

/* ── Blocks ── */
.block-heading { font-weight: bold; font-size: 1.05rem; margin: 2rem 0 0.5rem; color: var(--text); }
.block-prose   { line-height: 2; margin-bottom: 0.6rem; }
.block-poetry  { margin: 0.4rem 0 0.4rem 2rem; font-style: italic;
                 color: var(--muted); line-height: 1.8; }
.stanza-num    { display: inline-block; font-style: normal; font-size: 0.72rem;
                 font-weight: 600; color: var(--muted); min-width: 2rem;
                 margin-left: -2rem; vertical-align: middle; }

/* ── Tokens ── */
.tok { cursor: pointer; border-radius: 2px; padding: 0 1px; transition: background .1s; }
.tok.untagged  { border-bottom: 2px solid #e67e22; }
.tok.possible  { border-bottom: 2px solid #27ae60; }
.tok:hover     { background: rgba(91, 141, 217, 0.18); }
.tok.selected  { background: rgba(91, 141, 217, 0.35) !important; }
.tok.uncertain { color: #e88080; }
.tok.uncertain::after { content: '?'; font-size: 0.6em; vertical-align: super;
                        margin-left: 1px; color: #e88080; }

/* ── Right panel ── */
#panel { position: fixed; right: 0; top: 0; bottom: 0; width: 320px;
         background: var(--surface); border-left: 1px solid var(--border);
         padding: 1.5rem 1.5rem 2rem; display: none; overflow-y: auto;
         box-shadow: -4px 0 12px rgba(0,0,0,.3); }
#panel.open { display: block; }
#panel-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
               color: var(--muted); margin-bottom: 0.3rem; }
#panel-word  { font-size: 1.5rem; font-weight: bold; margin-bottom: 0.2rem; }
#panel-ext-links { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.4rem; display: flex; gap: 0.75rem; }
#panel-ext-links a { color: var(--muted); text-decoration: none; }
#panel-ext-links a:hover { color: var(--accent); text-decoration: underline; }
#panel-count { font-size: 0.78rem; color: var(--muted); margin-bottom: 1rem; }

/* Chosen reading */
#chosen-section { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
#chosen-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .5px;
                color: var(--muted); margin-bottom: 0.4rem; }
#chosen-display { padding: 0.35rem 0.5rem; border-radius: 3px; font-size: 0.8rem;
                  font-family: monospace; background: #1a1500; border: 1px solid var(--gold-dim);
                  color: var(--gold); display: flex; align-items: center; justify-content: space-between; }
#chosen-display.unset { color: var(--muted); background: var(--bg); border-color: var(--border);
                        font-style: italic; font-family: Georgia, serif; font-size: 0.8rem; }
.chosen-delete { background: none; border: none; color: var(--gold-dim); cursor: pointer;
                 font-size: 0.85rem; line-height: 1; padding: 0 0 0 0.3rem; opacity: 0.5; flex-shrink: 0; }
.chosen-delete:hover { opacity: 1; color: #e74c3c; }

/* Readings list */
#readings-section { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
#readings-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .5px;
                  color: var(--muted); margin-bottom: 0.4rem; }
.reading-btn { display: block; width: 100%; text-align: left; background: var(--bg);
               border: 1px solid var(--border); border-radius: 3px; padding: 0.35rem 0.5rem;
               font-size: 0.8rem; font-family: monospace; cursor: pointer;
               margin-bottom: 0.3rem; color: var(--text); }
.reading-btn:hover { background: rgba(91, 141, 217, 0.12); border-color: var(--accent); }
.reading-btn.active { background: rgba(91, 141, 217, 0.22); border-color: var(--accent); }
.reading-cf  { font-weight: bold; color: var(--text); }
.reading-meta { color: var(--muted); margin-left: 0.4rem; }
.reading-gw  { color: #6ec87a; margin-left: 0.4rem; font-style: italic; }

.field { margin-bottom: 0.85rem; }
.field label { display: block; font-size: 0.7rem; text-transform: uppercase;
               letter-spacing: .5px; color: var(--muted); margin-bottom: 0.3rem; }
.field input, .field select { width: 100%; border: 1px solid var(--border); border-radius: 4px;
               padding: 0.4rem 0.6rem; font-size: 0.92rem; font-family: monospace;
               background: var(--bg); color: var(--text); }
.field input:focus, .field select:focus { outline: none; border-color: var(--gold-dim); }
.field input.gw-field { font-style: italic; }
/* ── Notes field ── */
#notes-field textarea { width: 100%; border: 1px solid var(--border); border-radius: 4px;
                        padding: 0.4rem 0.6rem; font-size: 0.88rem; font-family: Georgia, serif;
                        background: var(--bg); color: var(--text); resize: vertical; min-height: 2.8rem; }
#notes-field textarea:focus { outline: none; border-color: var(--gold-dim); }
#btn-save-note { margin-top: 0.3rem; background: none; border: 1px solid var(--border);
                 border-radius: 3px; color: var(--muted); font-size: 0.75rem; cursor: pointer;
                 padding: 0.18rem 0.55rem; font-family: Georgia, serif; }
#btn-save-note:hover { background: rgba(91, 141, 217, 0.12); border-color: var(--accent); color: var(--accent); }

/* ── Uncertain toggle ── */
#btn-uncertain { width: 100%; padding: 0.45rem; border: 1px solid var(--border);
                 border-radius: 4px; font-size: 0.82rem; cursor: pointer;
                 margin-bottom: 0.5rem; color: var(--muted); background: none;
                 font-family: Georgia, serif; text-align: left; }
#btn-uncertain:hover { background: rgba(230, 126, 34, 0.1); border-color: #e67e22; color: #e67e22; }
#btn-uncertain.active { background: rgba(231, 76, 60, 0.15); border-color: #e74c3c; color: #e88080;
                        font-weight: bold; }

#btn-save   { width: 100%; padding: 0.6rem; background: var(--accent); color: #fff;
              border: none; border-radius: 4px; font-size: 0.95rem; cursor: pointer;
              margin-top: 0.25rem; font-family: Georgia, serif; }
#btn-save:hover { background: #4a7ac0; }
#btn-cancel { width: 100%; padding: 0.45rem; background: none; border: 1px solid var(--border);
              border-radius: 4px; font-size: 0.82rem; cursor: pointer;
              margin-top: 0.5rem; color: var(--muted); font-family: Georgia, serif; }
#btn-cancel:hover { background: rgba(255,255,255,0.04); }
#save-msg { font-size: 0.8rem; color: #6ec87a; margin-top: 0.75rem;
            text-align: center; min-height: 1.2rem; }

/* ── Compound elements ── */
#compound-section { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
#compound-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .5px;
                  color: var(--muted); margin-bottom: 0.5rem; }
.compound-row { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.35rem; }
.compound-row input { flex: 1; border: 1px solid var(--border); border-radius: 4px;
                      padding: 0.35rem 0.5rem; font-size: 0.88rem; font-family: monospace;
                      background: var(--bg); color: var(--text); }
.compound-row input:focus { outline: none; border-color: var(--gold-dim); }
.el-remove { background: none; border: none; color: var(--border); cursor: pointer;
             font-size: 1.1rem; padding: 0 0.25rem; line-height: 1; }
.el-remove:hover { color: #e74c3c; }
#btn-add-element { background: none; border: 1px dashed var(--border); color: var(--muted);
                   padding: 0.28rem 0.7rem; border-radius: 4px; cursor: pointer;
                   font-size: 0.8rem; margin-top: 0.1rem; }
#btn-add-element:hover { background: rgba(255,255,255,0.04); }
#btn-save-compounds { width: 100%; padding: 0.45rem; background: none; border: 1px solid var(--accent);
                      color: var(--accent); border-radius: 4px; font-size: 0.82rem; cursor: pointer;
                      margin-top: 0.5rem; font-family: Georgia, serif; }
#btn-save-compounds:hover { background: rgba(91, 141, 217, 0.12); }
#compound-msg { font-size: 0.8rem; color: #6ec87a; margin-top: 0.4rem;
                text-align: center; min-height: 1rem; }

/* ── Edit mode button ── */
#edit-mode-btn { background: none; border: 1px solid var(--border); border-radius: 4px;
                 color: var(--muted); font-size: 0.75rem; cursor: pointer;
                 padding: 0.22rem 0.6rem; margin-top: 0.5rem; width: 100%;
                 font-family: Georgia, serif; text-align: left; }
#edit-mode-btn:hover { color: var(--text); border-color: #3a3a48; }
#edit-mode-btn.active { background: #6b3a0f; border-color: #a05820; color: #f0c080; }

/* ── Settings button ── */
#settings-btn { background: none; border: 1px solid var(--border); border-radius: 4px;
                color: var(--muted); font-size: 0.75rem; cursor: pointer;
                padding: 0.22rem 0.6rem; margin-top: 0.5rem; width: 100%;
                font-family: Georgia, serif; text-align: left; }
#settings-btn:hover { color: var(--text); border-color: #3a3a48; }

/* ── Settings modal ── */
#settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65);
                    z-index: 1000; display: flex; align-items: center; justify-content: center; }
#settings-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
                  padding: 1.5rem 1.75rem; min-width: 300px; max-width: 380px; width: 90%;
                  box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
#settings-header { display: flex; align-items: center; justify-content: space-between;
                   margin-bottom: 1.5rem; }
#settings-header span { font-size: 1.05rem; font-weight: bold; color: var(--text); }
#settings-close { background: none; border: none; font-size: 1.1rem; cursor: pointer;
                  color: var(--muted); padding: 0; line-height: 1; }
#settings-close:hover { color: var(--text); }
.settings-group { margin-bottom: 1.25rem; }
.settings-group-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: .6px;
                        color: var(--muted); margin-bottom: 0.65rem; }
.settings-toggle { display: flex; align-items: center; gap: 0.75rem; cursor: pointer;
                   user-select: none; }
.settings-toggle input { display: none; }
.toggle-track { width: 36px; height: 20px; border-radius: 10px; background: var(--border);
                position: relative; flex-shrink: 0; transition: background 0.15s; }
.settings-toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
                border-radius: 50%; background: #fff; transition: left 0.15s;
                box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.settings-toggle input:checked + .toggle-track .toggle-thumb { left: 18px; }
.toggle-label { font-size: 0.88rem; color: var(--text); font-family: Georgia, serif; }

/* ── Poetry italic override ── */
body.poetry-no-italic .block-poetry { font-style: normal; }

/* ── Edit textarea ── */
#edit-textarea {
  width: 100%; min-height: 60vh;
  font-family: Georgia, serif; font-size: 1rem; line-height: 1.7;
  border: 2px solid var(--gold-dim); border-radius: 4px;
  padding: 1rem 1.2rem; background: var(--bg); color: var(--text);
  resize: vertical; outline: none;
}
#edit-textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,0.12); }
#edit-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
#edit-save-btn {
  background: #6b3a0f; color: #f0c080; border: 1px solid #a05820;
  border-radius: 4px; padding: 0.38rem 1rem; cursor: pointer; font-size: 0.88rem;
}
#edit-save-btn:hover   { background: #5a3009; }
#edit-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#edit-cancel-btn {
  background: none; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.38rem 0.8rem; cursor: pointer; font-size: 0.88rem;
}
#edit-cancel-btn:hover   { background: rgba(255,255,255,0.04); }
#edit-cancel-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#edit-status { font-size: 0.82rem; color: var(--muted); font-family: system-ui, sans-serif; }

/* ── Edit popover ── */
#edit-popover { position: fixed; z-index: 500; background: var(--surface);
                border: 1px solid var(--border); border-radius: 6px;
                padding: 0.55rem 0.65rem; width: 230px;
                box-shadow: 0 4px 18px rgba(0,0,0,0.4);
                font-family: system-ui, sans-serif; }
.ep-rename { display: flex; gap: 0.28rem; align-items: center; margin-bottom: 0.4rem; }
.ep-input  { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 3px;
             padding: 0.22rem 0.4rem; font-size: 0.88rem; font-family: monospace;
             background: var(--bg); color: var(--text); }
.ep-input:focus { outline: none; border-color: var(--accent); }
.ep-btn    { background: none; border: 1px solid var(--border); border-radius: 3px;
             cursor: pointer; font-size: 0.85rem; padding: 0.18rem 0.38rem;
             line-height: 1; flex-shrink: 0; color: var(--muted); }
.ep-confirm { color: #6ec87a; border-color: #2a6a30; }
.ep-confirm:hover { background: #0e2a14; }
.ep-x      { color: var(--muted); }
.ep-x:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.ep-actions { display: flex; gap: 0.3rem; }
.ep-action { flex: 1; border: 1px solid var(--border); border-radius: 3px; cursor: pointer;
             font-size: 0.76rem; padding: 0.22rem 0.3rem; background: var(--bg);
             font-family: system-ui, sans-serif; color: var(--muted); }
.ep-action:hover { background: rgba(255,255,255,0.06); }
.ep-delete { color: #e08080; border-color: #5a2020; background: #2a0e0e; }
.ep-delete:hover { background: #3a1010; }
.ep-insert-row { display: flex; gap: 0.28rem; align-items: center; margin-top: 0.4rem; }

/* ── View toggle ── */
#view-toggle { display: flex; gap: 4px; margin-top: 0.6rem; }
.view-btn { flex: 1; padding: 0.25rem; background: var(--bg); border: 1px solid var(--border);
            border-radius: 3px; color: var(--muted); font-size: 0.72rem; cursor: pointer;
            font-family: Georgia, serif; text-align: center; }
.view-btn.active { background: var(--accent); border-color: #4a7ac0; color: #fff; }

/* ── Headword list (dict sidebar) ── */
#headword-list { flex: 1; overflow-y: auto; min-height: 0; scrollbar-color: var(--border) var(--surface); }
#headword-list::-webkit-scrollbar { width: 6px; }
#headword-list::-webkit-scrollbar-track { background: var(--surface); }
#headword-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#headword-list::-webkit-scrollbar-thumb:hover { background: #3a3a48; }
.hw { padding: 0.55rem 1rem; cursor: pointer; border-left: 3px solid transparent;
      font-size: 0.88rem; }
.hw:hover { background: rgba(255,255,255,0.04); }
.hw.active { background: rgba(255,255,255,0.04); border-left-color: var(--gold); }
.hw-cf   { color: var(--text); font-family: monospace; }
.hw-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

/* ── Dictionary entry (main area) ── */
.dict-headword { font-size: 1.6rem; font-weight: bold; margin-bottom: 0.2rem; }
.dict-meta { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.5rem;
             padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.dict-form-row { display: flex; align-items: baseline; gap: 1rem; cursor: pointer;
                 padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.dict-form-row:hover { background: rgba(255,255,255,0.03); }
.dict-form-row.active { background: rgba(91, 141, 217, 0.12); }
.dict-form  { font-family: monospace; font-weight: 500; min-width: 140px; font-size: 0.95rem; }
.dict-tag   { color: var(--muted); font-family: monospace; font-size: 0.78rem; flex: 1; }
.dict-count { color: var(--muted); font-size: 0.75rem; }
.dict-delete { background: none; border: none; color: var(--border); cursor: pointer;
               font-size: 1rem; padding: 0 0.3rem; line-height: 1; margin-left: auto; }
.dict-delete:hover { color: #e74c3c; }

/* ── CN tag builder ── */
#cn-builder { margin: 0.5rem 0 1rem; padding: 0.7rem 0.7rem 0.3rem;
              background: #1a0a0a; border: 1px solid #3a1818; border-radius: 5px; }

/* ── Verb tag builder ── */
#verb-builder { margin: 0.5rem 0 1rem; padding: 0.7rem 0.7rem 0.3rem;
                background: #0a0a1a; border: 1px solid #1a1a38; border-radius: 5px; }
.vb-row   { margin-bottom: 0.5rem; }
.vb-label { display: block; font-size: 0.63rem; text-transform: uppercase;
            letter-spacing: .5px; color: var(--muted); margin-bottom: 0.22rem; }
.vb-btns  { display: flex; flex-wrap: wrap; gap: 0.22rem; }
.vb-btn   { padding: 0.2rem 0.5rem; border: 1px solid var(--border); border-radius: 3px;
            background: var(--bg); font-size: 0.77rem; font-family: monospace;
            cursor: pointer; color: var(--text); line-height: 1.4; }
.vb-btn:hover  { border-color: var(--accent); background: rgba(91, 141, 217, 0.15); }
.vb-btn.active { background: var(--accent); border-color: #4a7ac0; color: #fff; }

/* ── Noun tag builder ── */
#noun-builder { margin: 0.5rem 0 1rem; padding: 0.7rem 0.7rem 0.3rem;
                background: #0a1a0c; border: 1px solid #183820; border-radius: 5px; }
#noun-builder input { width: 100%; border: 1px solid var(--border); border-radius: 3px;
                      padding: 0.22rem 0.4rem; font-size: 0.77rem; font-family: monospace;
                      background: var(--bg); color: var(--text); margin-top: 0.1rem; }
#noun-builder input:focus { outline: none; border-color: var(--accent); }

/* ── Pronoun tag builder ── */
#pron-builder { margin: 0.5rem 0 1rem; padding: 0.7rem 0.7rem 0.3rem;
                background: #120a1a; border: 1px solid #281838; border-radius: 5px; }

/* ── Adjective tag builder ── */
#aj-builder { margin: 0.5rem 0 1rem; padding: 0.7rem 0.7rem 0.3rem;
              background: #1a150a; border: 1px solid #382a10; border-radius: 5px; }

/* ── POS combobox dropdown ── */
#pos-dropdown, #cf-dropdown, #gw-dropdown { display:none; position:absolute; left:0; right:0; top:100%;
                background: var(--surface); border:1px solid var(--border); border-radius:4px;
                z-index:200; max-height:200px; overflow-y:auto;
                box-shadow:0 3px 10px rgba(0,0,0,.4); }
.pos-opt { padding:0.35rem 0.6rem; font-size:0.88rem; font-family:monospace; cursor:pointer;
           color: var(--text); }
.pos-opt:hover, .pos-opt.focused { background: rgba(91, 141, 217, 0.2); }

/* ── Dict instances ── */
#dict-instances { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.dict-inst-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
                   color: var(--muted); margin-bottom: 0.5rem; }
.dict-instance { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); cursor: pointer;
                 border-radius: 3px; }
.dict-instance:hover { background: rgba(255,255,255,0.03); }
.inst-ref { font-size: 0.7rem; color: var(--muted); font-family: monospace;
            display: block; margin-bottom: 2px; }
.inst-ctx { font-size: 0.88rem; color: var(--text); line-height: 1.5; }
.inst-form { font-weight: bold; color: var(--text); }

/* ── Dict search / filter view ── */
#dict-search-view { max-width: 680px; }
.dict-search-title { font-size: 1.4rem; font-weight: bold; margin-bottom: 1.5rem; color: var(--text); }
.dict-filter-group { margin-bottom: 1rem; }
.dict-filter-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .5px;
                     color: var(--muted); margin-bottom: 0.4rem; }
.dict-filter-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.dict-chip { padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 12px;
             background: var(--bg); font-size: 0.78rem; font-family: monospace;
             cursor: pointer; color: var(--muted); line-height: 1.5; }
.dict-chip:hover { border-color: var(--accent); color: var(--accent); }
.dict-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#dict-q-input { width: 100%; border: 1px solid var(--border); border-radius: 4px;
                padding: 0.4rem 0.6rem; font-size: 0.92rem; font-family: monospace;
                background: var(--bg); color: var(--text); }
#dict-q-input:focus { outline: none; border-color: var(--gold-dim); }
#dict-results-count { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }

/* ── Name type tooltip ── */
#name-tooltip { display: none; position: fixed; z-index: 600;
                background: rgba(15, 15, 20, 0.92); color: var(--text);
                font-size: 0.7rem; font-family: system-ui, sans-serif;
                padding: 0.18rem 0.48rem; border-radius: 3px;
                pointer-events: none; white-space: nowrap; letter-spacing: 0.3px; }
