:root {
  --bg: #e9ece7; --paper: #f7f8f4; --paper-2: #eff2ec; --ink: #15262b; --ink-2: #566669; --rule: #cdd5cf;
  --blue: #2d43b5; --on-blue: #ffffff; --pencil: #bf2b44; --ok: #1f7a5c; --warn: #9a6a00;
  --shadow: 0 1px 0 rgba(21,38,43,.06);
  --serif: 'Gentium Book Plus', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f181b; --paper: #162225; --paper-2: #1b2a2e; --ink: #e4ebe7; --ink-2: #93a4a6; --rule: #2a3a3d;
    --blue: #8ea0ff; --on-blue: #0f181b; --pencil: #ff8296; --ok: #58c9a0; --warn: #e0b04a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 .5em; letter-spacing: .005em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--blue); }
small, .muted { color: var(--ink-2); }
.serif { font-family: var(--serif); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }

/* ---------- forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px;
  font-size: 16px; min-height: 42px;
}
textarea { resize: vertical; line-height: 1.45; }
select { appearance: auto; }
label.field { display: block; margin: 0 0 .9rem; }
label.field > span { display: block; font-size: .82rem; color: var(--ink-2); margin-bottom: .25rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; padding: 0 1rem;
  border-radius: 4px; border: 1px solid var(--ink); background: transparent; cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--paper-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--pencil); color: var(--pencil); }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.sm { min-height: 34px; padding: 0 .7rem; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
.btn .spin { width: 14px; height: 14px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* ---------- shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.rail { background: var(--paper); border-bottom: 1px solid var(--rule); padding: calc(.6rem + var(--sat)) 1rem .6rem; display: flex; align-items: center; gap: .8rem; position: sticky; top: 0; z-index: 20; }
.brand { font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.langpick { flex: 1; min-width: 0; }
.langpick select { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; min-height: 40px; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--paper); border-top: 1px solid var(--rule); padding-bottom: var(--sab); }
.nav a, .nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .45rem; font-size: .68rem; color: var(--ink-2); text-decoration: none; background: none; border: 0; cursor: pointer; }
.nav svg { width: 22px; height: 22px; }
.nav a.active { color: var(--blue); font-weight: 700; }
.nav .secondary { display: none; }
.morepanel { position: fixed; right: .6rem; bottom: calc(64px + var(--sab)); z-index: 40; background: var(--paper); border: 1px solid var(--ink); border-radius: 6px; min-width: 190px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.morepanel a, .morepanel button { display: flex; gap: .6rem; align-items: center; width: 100%; padding: .8rem 1rem; text-decoration: none; color: var(--ink); background: none; border: 0; border-bottom: 1px solid var(--rule); font-size: .95rem; text-align: left; cursor: pointer; }
.morepanel > :last-child { border-bottom: 0; }
.morepanel svg { width: 20px; height: 20px; color: var(--ink-2); }
.userbox { display: none; }
main#view { padding: 1.2rem 1rem calc(5.5rem + var(--sab)); max-width: 1080px; margin: 0 auto; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; }
  .rail { position: sticky; top: 0; height: 100vh; flex-direction: column; align-items: stretch; border-bottom: 0; border-right: 1px solid var(--rule); padding: 1.3rem 1rem; gap: 1rem; overflow-y: auto; }
  .nav { position: static; flex-direction: column; border: 0; padding: 0; background: none; }
  .nav a { flex-direction: row; gap: .7rem; font-size: .95rem; padding: .55rem .6rem; border-radius: 4px; color: var(--ink); }
  .nav a:hover { background: var(--paper-2); }
  .nav a.active { background: var(--ink); color: var(--paper); }
  .nav .secondary { display: flex; }
  .nav .more-btn, .morepanel { display: none !important; }
  .userbox { display: block; margin-top: auto; font-size: .85rem; color: var(--ink-2); }
  main#view { padding: 2rem 2rem 4rem; }
}
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }
.pagehead p { margin: .2rem 0 0; color: var(--ink-2); }

/* ---------- panels ---------- */
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.empty { text-align: center; padding: 2.5rem 1rem; border: 1px dashed var(--rule); border-radius: 4px; color: var(--ink-2); }
.empty h2 { color: var(--ink); }
.notice { border-left: 3px solid var(--warn); background: var(--paper-2); padding: .7rem .9rem; border-radius: 0 4px 4px 0; margin-bottom: 1rem; }
.notice.err { border-color: var(--pencil); }
.notice.ok { border-color: var(--ok); }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 4px; overflow: hidden; max-width: 100%; }
.seg button { background: none; border: 0; padding: .5rem .85rem; cursor: pointer; font-weight: 600; font-size: .9rem; border-right: 1px solid var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .08rem .55rem; border-radius: 99px; font-size: .8rem; border: 1px solid var(--c, var(--rule)); color: var(--ink); background: transparent; line-height: 1.5; max-width: 100%; }
.chip::before { content: ''; width: .55rem; height: .55rem; border-radius: 50%; background: var(--c, var(--ink-2)); flex: none; }
.chip.plain::before { display: none; }
.chip.pencil { border-style: dashed; border-color: var(--pencil); }
.chip.pencil::before { background: transparent; border: 1.5px dashed var(--c, var(--pencil)); }
.chip.btnlike { cursor: pointer; }
.tagrow { display: flex; flex-wrap: wrap; gap: .4rem; }
.pos { font-family: var(--serif); font-style: italic; color: var(--ink-2); font-size: .95rem; }
.lemma { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; line-height: 1.2; overflow-wrap: anywhere; }

/* ---------- dictionary ---------- */
.toolbar { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; margin-bottom: .8rem; }
.toolbar .search { grid-column: 1 / -1; }
@media (min-width: 760px) { .toolbar { grid-template-columns: 2fr 1fr 1fr 1fr; } .toolbar .search { grid-column: auto; } }
.statline { display: flex; flex-wrap: wrap; gap: .4rem .5rem; margin-bottom: .8rem; align-items: center; }
.statline button { background: none; border: 1px solid var(--rule); border-radius: 99px; padding: .15rem .65rem; font-size: .82rem; cursor: pointer; color: var(--ink-2); }
.statline button:hover, .statline button.on { border-color: var(--ink); color: var(--ink); }
.entries { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; }
.entry { display: grid; grid-template-columns: 5px 1fr; text-align: left; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; padding: 0; }
.entry:last-child { border-bottom: 0; }
.entry:hover { background: var(--paper-2); }
.entry .stripe { background: var(--c, transparent); }
.entry .body { padding: .7rem .9rem; min-width: 0; }
.entry .top { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.entry .top > .chip { margin-left: auto; align-self: center; }
.entry .gl { color: var(--ink); margin-top: .1rem; }
.entry .gl span + span::before { content: ' · '; color: var(--ink-2); }
.entry .gl .lab { color: var(--ink-2); font-size: .75rem; margin-right: .25rem; }
.entry .fl { color: var(--ink-2); font-size: .8rem; margin-top: .15rem; }
.loadmore { text-align: center; padding: 1rem 0 0; }

/* ---------- modals and toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,16,18,.55); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.dialog { background: var(--paper); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 10px 10px 0 0; padding: 1.1rem 1.1rem calc(1.1rem + var(--sab)); border: 1px solid var(--ink); }
.dialog h2 { margin-bottom: .8rem; }
.dialog .actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
@media (min-width: 640px) { .overlay { align-items: center; padding: 1rem; } .dialog { border-radius: 6px; } }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(76px + var(--sab)); display: flex; flex-direction: column; align-items: center; gap: .4rem; z-index: 200; pointer-events: none; padding: 0 1rem; }
@media (min-width: 900px) { #toasts { bottom: 1.5rem; } }
.toast { background: var(--ink); color: var(--paper); padding: .6rem .9rem; border-radius: 4px; max-width: 520px; font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.err { background: var(--pencil); color: #fff; }

/* ---------- sign-in and welcome wizard ---------- */
.authwrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.authcard { width: 100%; max-width: 440px; }
.authcard .logo { font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 2.3rem; line-height: 1.05; margin-bottom: .4rem; }
.authcard .lead { color: var(--ink-2); margin-bottom: 1.4rem; font-size: 1.02rem; }
.wizard { max-width: 760px; margin: 0 auto; padding: calc(1.2rem + var(--sat)) 1rem 4rem; }
.steps { display: flex; gap: .35rem; margin: 0 0 1.4rem; padding: 0; list-style: none; }
.steps li { flex: 1; height: 4px; background: var(--rule); border-radius: 2px; }
.steps li.done { background: var(--ink); } .steps li.cur { background: var(--blue); }
.wizard h1 { margin-bottom: .3rem; }
.wizard .sub { color: var(--ink-2); margin-bottom: 1.3rem; font-size: 1.02rem; }
.choice { display: grid; gap: .7rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 640px) { .choice { grid-template-columns: 1fr 1fr; } }
.choice button { text-align: left; padding: 1rem; background: var(--paper); border: 1px solid var(--ink); border-radius: 4px; cursor: pointer; }
.choice button strong { display: block; font-family: var(--serif); font-size: 1.2rem; margin-bottom: .2rem; }
.choice button:hover { background: var(--paper-2); }
.lvl-edit { display: grid; grid-template-columns: 34px 1fr auto; gap: .5rem .6rem; align-items: start; padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.lvl-edit:last-child { border-bottom: 0; }
.lvl-edit input[type=color] { width: 34px; height: 42px; padding: 0; border: 1px solid var(--rule); border-radius: 4px; background: none; }
.lvl-edit .desc { grid-column: 2 / -1; }

/* ---------- import ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); margin-bottom: 1rem; -webkit-overflow-scrolling: touch; }
table.preview { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
table.preview th, table.preview td { padding: .4rem .65rem; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.preview th { background: var(--paper-2); font-weight: 700; position: sticky; top: 0; }
.colmap { display: grid; gap: .8rem; grid-template-columns: 1fr; padding: .9rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); margin-bottom: .7rem; }
.colmap.skipped { opacity: .6; }
@media (min-width: 760px) { .colmap { grid-template-columns: 1fr 1fr; } }
.colmap .name { font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.colmap .samples { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0; }
.colmap .samples code { font-family: var(--serif); background: var(--paper-2); border: 1px solid var(--rule); padding: 0 .4rem; border-radius: 3px; font-size: .95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.valmap { margin-top: .6rem; font-size: .88rem; }
.valmap summary { cursor: pointer; color: var(--blue); }
.valmap .vrow { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; align-items: center; margin-top: .4rem; }
.valmap .vrow input { min-height: 36px; padding: .3rem .5rem; }
.bignum { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.bignum div { min-width: 90px; }
.bignum b { display: block; font-family: var(--serif); font-size: 2.1rem; line-height: 1; }
.dropzone { border: 2px dashed var(--ink-2); border-radius: 6px; padding: 2.2rem 1rem; text-align: center; cursor: pointer; background: var(--paper); }
.dropzone.over { border-color: var(--blue); background: var(--paper-2); }
.dropzone strong { font-family: var(--serif); font-size: 1.3rem; display: block; margin-bottom: .3rem; }

/* ---------- levels ---------- */
.progressbar { display: flex; height: 12px; border-radius: 2px; overflow: hidden; background: var(--rule); margin: .5rem 0; }
.progressbar i { display: block; height: 100%; background: var(--c); }
.progressbar i.pend { background: repeating-linear-gradient(45deg, var(--c) 0 4px, transparent 4px 8px); }
.wgrid { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: .8rem 0; }
@media (min-width: 700px) { .wgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .wgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wcard { background: var(--paper); border: 1px solid var(--rule); border-top: 3px solid var(--c, var(--rule)); border-radius: 3px; padding: .55rem .6rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; position: relative; }
.wcard.pending { border-style: dashed; border-color: var(--pencil); border-top: 3px dashed var(--c, var(--pencil)); }
.wcard.selected { outline: 2px solid var(--blue); }
.wcard .wl { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; overflow-wrap: anywhere; padding-right: 1.6rem; }
.wcard .wg { font-size: .85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .why { font-size: .75rem; color: var(--pencil); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .sel { position: absolute; top: .5rem; right: .5rem; width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }
.chipselect { appearance: none; -webkit-appearance: none; border: 1px solid var(--c, var(--rule)); background: transparent; border-radius: 99px; padding: .12rem 1.4rem .12rem .6rem; font-size: .82rem; min-height: 30px; width: 100%; margin-top: .3rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.wcard.pending .chipselect { border-style: dashed; }
.stickybar { position: sticky; top: calc(var(--sat) + 58px); z-index: 10; background: var(--bg); padding: .5rem 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
@media (min-width: 900px) { .stickybar { top: 0; } }
.single { text-align: center; padding: 1.5rem 1rem; }
.single .lemma { font-size: 2.6rem; }
.single .proposal { margin: 1.2rem auto; max-width: 440px; min-height: 64px; }
.levelbtns { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .8rem; }
.levelbtns .btn { border-color: var(--c); }
.levelbtns .btn.pick { background: var(--c); color: #fff; }

/* ---------- gaps ---------- */
.gapcard { background: var(--paper); border: 1px solid var(--rule); border-left: 3px dashed var(--pencil); border-radius: 3px; padding: .9rem 1rem; margin-bottom: .8rem; }
.gapcard.accepted { border-left: 3px solid var(--ok); }
.gapcard h3 { margin-bottom: .2rem; }
.gapcard .tagrow { margin: .6rem 0; }
.gapcard .chip { cursor: pointer; }
.gapcard .chip:hover { background: var(--paper-2); }

/* ---------- chat ---------- */
.chatwrap { display: flex; flex-direction: column; height: calc(100dvh - 290px - var(--sab)); min-height: 340px; }
@media (min-width: 900px) { .chatwrap { height: calc(100dvh - 200px); min-height: 380px; } }
.chatlog { flex: 1; overflow-y: auto; padding: .5rem .2rem 1rem; display: flex; flex-direction: column; gap: .8rem; }
.msg { max-width: 88%; padding: .65rem .85rem; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai { align-self: flex-start; background: var(--paper); border: 1px solid var(--rule); font-family: var(--serif); font-size: 1.08rem; line-height: 1.45; }
.msg.me { align-self: flex-end; background: var(--ink); color: var(--paper); }
.propcard { align-self: flex-start; max-width: 92%; border: 1px dashed var(--pencil); border-radius: 4px; padding: .6rem .8rem; background: var(--paper); }
.propcard .sec { font-size: .78rem; color: var(--pencil); font-weight: 700; margin-bottom: .15rem; }
.propcard .why { font-size: .78rem; color: var(--ink-2); margin: .2rem 0 .5rem; }
.propcard textarea { min-height: 70px; margin: .3rem 0; }
.chatin { display: flex; gap: .5rem; align-items: flex-end; padding-top: .6rem; border-top: 1px solid var(--rule); }
.chatin textarea { min-height: 46px; max-height: 160px; }
.notes-ed { width: 100%; min-height: 58vh; font-family: var(--mono); font-size: 14px; line-height: 1.55; tab-size: 2; }

/* ---------- settings ---------- */
.frow { display: grid; grid-template-columns: 1fr; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); align-items: center; }
.frow:last-child { border-bottom: 0; }
@media (min-width: 700px) { .frow { grid-template-columns: 150px 90px 1fr 120px; } .frow.head { font-size: .8rem; color: var(--ink-2); } }
.kv { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 13px; background: var(--rule); margin: 0; cursor: pointer; transition: background .15s; }
.switch input:checked { background: var(--blue); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); pointer-events: none; transition: transform .15s; }
.switch:has(input:checked)::after { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .switch input, .switch::after { transition: none; } }
.pb-safe { height: 1px; }

/* ---------- dictionary: query bar, table, gallery ---------- */
.btn.on { background: var(--ink); color: var(--paper); }
.btn.active { border-color: var(--blue); }
.btn .count, .grouphead .count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .4em; border-radius: 99px; background: var(--blue); color: var(--on-blue); font-size: .75em; text-align: center; line-height: 1.5; }
.btn.on .count { background: var(--paper); color: var(--ink); }
.qbar { margin-bottom: .6rem; }
.qtop { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.qtop .grow { min-width: 200px; }
.qbtns { display: flex; gap: .4rem; flex-wrap: wrap; }
.qpanel { margin-top: .5rem; padding: .8rem; background: var(--paper); border: 1px solid var(--ink); border-radius: 4px; }
.qpanel .phead { font-weight: 700; font-size: .88rem; margin-bottom: .5rem; }
.qrow { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .45rem; align-items: center; }
.qrow > select, .qrow > input, .qrow > span { flex: 1 1 150px; min-width: 0; }
.qrow > button { flex: none; }
.qrow.views > button:first-child { flex: 1; justify-content: flex-start; }
.colgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .4rem .8rem; margin-bottom: .6rem; }
.table-scroll.dict, .table-scroll.bulk { max-height: calc(100dvh - 230px); min-height: 220px; overflow: auto; }
table.dt { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: .93rem; }
table.dt th, table.dt td { padding: .45rem .7rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.dt th { position: sticky; top: 0; z-index: 2; background: var(--paper-2); white-space: nowrap; }
table.dt tbody tr { cursor: pointer; }
table.dt tbody tr:hover td { background: var(--paper-2); }
table.dt td.c-lemma { white-space: nowrap; }
table.dt td.c-notes { max-width: 260px; }
.thbtn { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 700; display: inline-flex; gap: .3rem; align-items: center; color: inherit; }
.thbtn .arrow { font-size: .65em; color: var(--blue); }
.lemma-link { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: inherit; }
.clip { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.unset { color: var(--pencil); font-style: italic; font-weight: 400; }
.lemma.unset { font-size: 1rem; }
tr.unset-row .lemma { font-size: 1rem; }
tr.grouprow td { background: var(--paper-2); padding: .3rem .7rem; cursor: default; }
tr.grouprow:hover td { background: var(--paper-2); }
.grouphead { display: flex; align-items: center; gap: .6rem; font-family: var(--serif); font-size: 1.15rem; padding: .5rem 0; margin-top: 1rem; border-bottom: 2px solid var(--ink); }
tr.grouprow .grouphead { margin: 0; border: 0; padding: .1rem 0; }
.grouphead .count { background: var(--ink-2); }
.dsec .entries { margin-bottom: .5rem; }
.chip.tag { border-radius: 4px; border-color: var(--rule); color: var(--ink-2); background: var(--paper-2); }
.chip.tag::before { display: none; }
.chip.tag button { background: none; border: 0; cursor: pointer; padding: 0 0 0 .15rem; color: var(--ink-2); font-size: 1rem; line-height: 1; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; margin-top: .7rem; }
.gcard { display: flex; flex-direction: column; gap: .25rem; text-align: left; padding: .7rem .8rem .75rem; background: var(--paper); border: 1px solid var(--rule); border-top: 4px solid var(--c, var(--rule)); border-radius: 2px; cursor: pointer; min-width: 0; }
.gcard:hover { background: var(--paper-2); }
.gcard.unset-card { border-top-style: dashed; }
.gcard .gtop { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.gcard .lemma { font-size: 1.45rem; }
.gcard .gl { font-size: .95rem; }
.gcard .gl .lab { color: var(--ink-2); font-size: .72rem; margin-right: .35rem; }
.gcard .fl { color: var(--ink-2); font-size: .8rem; }
.gcard .tagrow { margin-top: auto; padding-top: .4rem; }

/* ---------- word card and forms ---------- */
.dialog.wide { max-width: 720px; padding: 0; overflow-x: hidden; }
.wc-stripe { height: 8px; background: var(--rule); }
.wc-inner { padding: 1.2rem 1.3rem calc(1.2rem + var(--sab)); }
.wc-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.wc-lemma { font-family: var(--serif); font-weight: 700; font-size: 3rem; line-height: 1.05; overflow-wrap: anywhere; }
.wc-lemma.unset { font-size: 1.5rem; }
.wc-pos { font-size: 1.2rem; }
.wc-sec { margin-top: 1.2rem; }
.wc-sec h3 { font-size: .85rem; font-family: var(--sans); font-weight: 700; color: var(--ink-2); margin-bottom: .4rem; border-bottom: 1px solid var(--rule); padding-bottom: .2rem; }
.wc-gloss { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem 1rem; }
.wc-g { font-family: var(--serif); font-size: 1.45rem; line-height: 1.25; }
.wc-dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.wc-dl dt { color: var(--ink-2); } .wc-dl dd { margin: 0; font-family: var(--serif); font-size: 1.1rem; }
.wc-notes { font-family: var(--serif); font-size: 1.1rem; line-height: 1.55; white-space: pre-wrap; }
.wc-meta { margin-top: 1.2rem; font-size: .82rem; }
.wc-actions { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--rule); }
.wc-inner .actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } .wc-lemma { font-size: 2.3rem; } }
.lab2 { display: block; font-size: .82rem; color: var(--ink-2); margin-bottom: .25rem; }
.tagedit { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; padding: .3rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); min-height: 42px; }
.tagedit input { flex: 1 1 9rem; min-width: 8rem; border: 0; background: transparent; padding: .3rem; min-height: 32px; }
.aihelp { margin: -.2rem 0 .8rem; }
.cand { display: block; width: 100%; text-align: left; background: var(--paper); border: 1px dashed var(--pencil); border-radius: 4px; padding: .45rem .7rem; margin: .35rem 0; cursor: pointer; }
.cand:hover { background: var(--paper-2); }

/* ---------- bulk edit ---------- */
.bulkbar { gap: .7rem; }
.bulk-tools .row { gap: .5rem; }
table.dt.bulk tbody tr { cursor: default; }
table.dt.bulk td { padding: .15rem .25rem; }
table.dt.bulk th.sel, table.dt.bulk td.sel { position: sticky; left: 0; z-index: 1; background: var(--paper); width: 44px; text-align: center; }
table.dt.bulk th.sel { z-index: 3; background: var(--paper-2); }
.cellin { width: 100%; min-width: 8.5rem; min-height: 36px; padding: .3rem .45rem; border: 1px solid transparent; border-radius: 3px; background: transparent; font-size: 15px; }
.cellin:hover { border-color: var(--rule); }
.cellin:focus { border-color: var(--blue); background: var(--paper); outline: none; }
.cellin.lemma-in { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; }
td.dirty .cellin { border: 1px dashed var(--pencil); background: var(--paper-2); }
tr.dirty-row td.sel { box-shadow: inset 3px 0 0 var(--pencil); }
tr.new-row td { background: var(--paper-2); }
td.ro { color: var(--ink-2); white-space: nowrap; padding: .4rem .6rem; }

/* ---------- board ---------- */
.board { display: flex; gap: .7rem; overflow-x: auto; align-items: flex-start; padding-bottom: .6rem; -webkit-overflow-scrolling: touch; }
.bcol { flex: 0 0 265px; display: flex; flex-direction: column; max-height: calc(100dvh - 300px); min-height: 140px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; }
.bcol.over { outline: 2px dashed var(--blue); outline-offset: -2px; }
.bhead { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border-bottom: 1px solid var(--rule); font-family: var(--serif); font-size: 1.05rem; position: sticky; top: 0; }
.bhead .count { margin-left: auto; background: var(--ink-2); color: var(--paper); border-radius: 99px; padding: 0 .5em; font-size: .75rem; font-family: var(--sans); }
.bcards { overflow-y: auto; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }
.bcard { background: var(--paper); border: 1px solid var(--rule); border-top: 3px solid var(--c, var(--rule)); border-radius: 2px; padding: .5rem .6rem; cursor: grab; display: flex; flex-direction: column; gap: .15rem; }
.bcard.dragging { opacity: .45; }
.bcard.unset-card { border-top-style: dashed; }
.bcard .lemma { font-size: 1.2rem; }
.bcard .gl { font-size: .88rem; }
.bcard .gtop { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.moveto select { font-size: .82rem; min-height: 30px; padding: .1rem .4rem; margin-top: .3rem; color: var(--ink-2); }
/* ---------- gap concepts and export ---------- */
.conc { display: inline-flex; align-items: center; gap: 2px; }
.conc .tick { background: none; border: 1px solid transparent; border-radius: 99px; cursor: pointer; color: var(--ink-2); font-size: .8rem; width: 26px; height: 26px; }
.conc .tick:hover { border-color: var(--ok); color: var(--ok); }
.conc.done .chip { border-color: var(--ok); color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ok); }
.xcol { display: grid; grid-template-columns: 9rem 1fr auto; gap: .4rem; margin-bottom: .45rem; align-items: center; }
@media (max-width: 560px) { .xcol { grid-template-columns: 1fr auto; } .xcol .tpl { grid-column: 1 / -1; grid-row: 2; } }
.tpl { font-family: var(--mono); font-size: 14px; }
.hdrlines { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; padding: .5rem .7rem; font-family: var(--mono); font-size: 13px; margin: 0 0 .6rem; overflow-x: auto; }
.optline { display: flex; align-items: flex-start; margin: .35rem 0; }
.optline small { display: inline; }

/* ---------- guest page ---------- */
.guest-shell { min-height: 100dvh; }
.guestbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; padding: calc(.6rem + var(--sat)) 1rem .6rem; background: var(--paper); border-bottom: 1px solid var(--rule); }
.guestbar .langpick { flex: 1; min-width: 0; }
.guestbar .gname { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.badge-ro { font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 99px; padding: .1rem .55rem; white-space: nowrap; }
.guest-shell main#view { padding-bottom: 3rem; }
.guest-intro h2 { margin-bottom: .2rem; }
.authbox { width: 100%; }
@media (max-width: 480px) { .badge-ro { display: none; } }
