.lab { display: grid; gap: 24px; }
.labsection + .labsection { border-top: 1px solid var(--line); padding-top: 24px; }
.fieldlabel { display: block; margin: 14px 0 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
textarea { display: block; width: 100%; resize: vertical; min-height: 72px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 12px 13px; color: var(--ink); font: inherit; line-height: 1.45; outline: 0; }
textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,120,.1); }
.actionline.left { justify-content: flex-start; margin: 10px 0 0; }
.editorwrap { margin-top: 14px; padding: 14px; border: 1px solid #cfcbc0; border-radius: 12px; background: #f8f6f0; }
.hidden { display: none !important; }
.editorintro { display: grid; gap: 3px; margin-bottom: 10px; }
.editorintro b { font-size: 12px; }
.editorintro small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.tokeneditor { display: grid; gap: 6px; }
.tokenrow { display: grid; grid-template-columns: minmax(110px,1.2fr) minmax(90px,.7fr) minmax(105px,.85fr) minmax(120px,1fr); gap: 8px; align-items: end; padding: 8px; border: 1px solid #e1ded6; border-radius: 8px; background: #fff; }
.tokeneditor.compact .tokenrow { grid-template-columns: minmax(110px,1.2fr) minmax(105px,.9fr) minmax(90px,.65fr) minmax(105px,.8fr) minmax(120px,.9fr); }
.tokenword { display: grid; align-self: center; min-width: 0; }
.tokenword b, .tokenword small { overflow: hidden; text-overflow: ellipsis; }
.tokenword b { font-size: 13px; }
.tokenword small { color: var(--muted); font-size: 9px; }
.tokenword em { margin-top: 3px; color: inherit; font-size: 8px; font-style: normal; font-weight: 700; letter-spacing: .04em; }
.tokenrow.learn-learning { border-color: #c96b66; box-shadow: inset 3px 0 #b74945; }
.tokenrow.learn-learning .tokenword em { color: #a6413f; }
.tokenrow.learn-trusted { border-color: #73ad91; background: #f5fbf7; box-shadow: inset 3px 0 #31835f; }
.tokenrow.learn-trusted .tokenword em { color: #27775c; }
.tokenrow.identity-unresolved, .tokenrow.identity-new_cell, .tokenrow.identity-provisional_local_cell { border-style: dashed; }
.tokenrow.phrase-complement { border-left: 4px solid #c58a2e; background: #fffbf1; }
.tokenrow.learn-word { border-color: #80aad5; background: #f1f7fd; box-shadow: inset 3px 0 #2866a8; }
.tokenrow.learn-word .tokenword em { color: #245c96; }
.tokenrow.identity-unresolved .tokenword small, .tokenrow.identity-new_cell .tokenword small, .tokenrow.identity-provisional_local_cell .tokenword small { color: #9a6b20; }
.cell.local-cell { background: #f3fbf7; box-shadow: inset 3px 0 #31835f; }
.exportlink { display: inline-block; margin: 10px 2px 0; color: var(--teal); font-size: 10px; font-weight: 700; text-decoration: none; }
.exportlink:hover { text-decoration: underline; }
.latestlearned { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.latestlearned > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.latestlearned h3 { margin: 0; font: 600 14px Georgia,serif; }
.latestlearned small { color: var(--muted); font-size: 8px; white-space: nowrap; }
.latestlearned ol { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; counter-reset: recent-sentence; }
.latestlearned li { counter-increment: recent-sentence; position: relative; margin: 0; padding: 8px 9px 8px 28px; border: 1px solid #e1ded6; border-radius: 8px; background: #fff; color: var(--ink); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.latestlearned li::before { content: counter(recent-sentence); position: absolute; left: 9px; top: 8px; color: var(--teal); font-size: 8px; font-weight: 800; }
.latestlearned li.latestempty { padding-left: 9px; color: var(--muted); font-style: italic; }
.latestlearned li.latestempty::before { content: none; }
.tokenrow label, .framegrid label { display: grid; gap: 4px; }
.tokenrow label span, .framegrid label span { color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.tokenrow select, .tokenrow input, .framegrid select, .framegrid input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 7px 8px; color: var(--ink); font-size: 10px; outline: 0; }
.resolvefield { grid-column: 2/-1; }
.validationwarnings { margin: 7px 0 0; padding-left: 18px; color: #795c22; font-size: 9px; }
.storagereceipt { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 7px; }
.storagereceipt summary { cursor: pointer; color: var(--teal); font-size: 10px; font-weight: 700; }
.storagereceipt ol { display: grid; gap: 6px; margin: 7px 0 0; padding-left: 20px; }
.storagereceipt li { color: var(--ink); font-size: 9px; line-height: 1.45; }
.storagereceipt li b, .storagereceipt li span { display: block; }
.checkline { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.editorwrap > .checkline { margin: 12px 0; }
.choicebar { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.retrievalcontrols { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 9px; margin-top: 12px; }
.retrievalcontrols label { display: grid; gap: 4px; }
.retrievalcontrols label span { color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.retrievalcontrols select, .retrievalcontrols input { width: 100%; border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 8px; color: var(--ink); font-size: 10px; }
.scopehint { margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.retrievaldiagnostic { grid-column: 1/-1; }
.primary { border: 0; border-radius: 9px; background: var(--teal); color: #fff; padding: 10px 14px; font-weight: 700; font-size: 11px; }
.primary:hover { background: var(--deep); }
.primary span { margin-left: 10px; }
.askfinal { display: block; width: 100%; margin: 16px 0 14px; border: 0; border-radius: 11px; background: #d9653b; color: #fff; padding: 15px 20px; font-size: 14px; font-weight: 800; letter-spacing: .02em; box-shadow: 0 5px 14px rgba(147,61,30,.2); }
.askfinal:hover { background: #b94f2b; transform: translateY(-1px); }
.askfinal:disabled { opacity: .7; transform: none; }
.askfinal span { margin-left: 12px; }
.askrow { grid-template-columns: minmax(0,1fr) auto; }
.askrow .secondary { height: 44px; color: var(--teal); }
.frameeditor { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.frameeditor summary { cursor: pointer; color: var(--teal); font-size: 10px; font-weight: 650; }
.framegrid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin-top: 10px; }
.eventeditor { margin-top: 12px; border: 1px solid #ded9cd; border-radius: 9px; background: #fff; padding: 10px; }
.eventeditor summary { cursor: pointer; color: var(--teal); font-size: 10px; font-weight: 700; }
.eventeditor > p { margin: 6px 0 9px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.eventframes { display: grid; gap: 10px; }
.eventframe { border-top: 1px solid #e8e3d8; padding-top: 9px; }
.eventframe:first-child { border-top: 0; padding-top: 0; }
.eventframe h4 { margin: 0 0 7px; font-size: 10px; }
.eventgrid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.eventgrid label { display: grid; gap: 4px; }
.eventgrid label span { color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.eventgrid input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 7px 8px; color: var(--ink); font-size: 10px; outline: 0; }
.recognition { margin-top: 12px; }

.topactions { display: flex; align-items: center; gap: 9px; }
.helpbutton { border: 1px solid #9fc8bf; border-radius: 999px; background: #fffdf8; color: var(--deep); padding: 8px 12px; font-size: 11px; font-weight: 750; }
.helpbutton:hover { border-color: var(--teal); background: #edf8f5; }
.helpbutton:focus-visible, .helpclose:focus-visible, .helpdismiss:focus-visible { outline: 3px solid rgba(8,127,120,.22); outline-offset: 2px; }
.helpdialog { width: min(780px,calc(100% - 28px)); max-height: min(90dvh,900px); margin: auto; padding: 0; border: 1px solid #c9d5ce; border-radius: 18px; background: #fffdf8; color: var(--ink); box-shadow: 0 30px 90px rgba(22,34,42,.28); }
.helpdialog::backdrop { background: rgba(12,22,27,.62); backdrop-filter: blur(3px); }
.helpcontent { padding: 0 28px 30px; }
.helphead { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 0 -28px 20px; padding: 23px 28px 18px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.97); backdrop-filter: blur(8px); }
.helphead .eyebrow { margin: 0 0 6px; }
.helphead h2 { margin: 0; font: 600 clamp(23px,4vw,34px)/1.12 Georgia,serif; }
.helpclose { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); font-size: 27px; line-height: 1; }
.helpclose:hover { color: var(--ink); border-color: var(--teal); }
.helprequired { margin: 0 0 18px; padding: 13px 15px; border: 1px solid #b9d8d1; border-radius: 11px; background: #eaf7f3; color: #28463f; font-size: 13px; line-height: 1.55; }
.helprequired strong { color: var(--deep); }
.helpintro { margin: 0 0 22px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.helpsection { margin-top: 24px; }
.helpsection h3, .helpscope h3 { margin: 0 0 11px; color: var(--deep); font: 600 18px Georgia,serif; }
.helpsteps { display: grid; gap: 8px; margin: 0; padding-left: 22px; }
.helpsteps li { padding-left: 4px; color: #34454c; font-size: 13px; line-height: 1.55; }
.helpgrid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.helpgrid > div { display: grid; gap: 3px; padding: 10px 11px; border: 1px solid #e2ded5; border-radius: 9px; background: #fff; }
.helpgrid b { color: var(--teal); font-size: 11px; }
.helpgrid span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.helpgrid.compact b { letter-spacing: .06em; }
.helpslots { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.helpsection.example { padding: 17px; border: 1px solid #c5dbd4; border-radius: 13px; background: #f2f9f6; }
.exampletext { margin: 0 0 11px; font: 600 19px Georgia,serif; }
.exampletokens { display: flex; flex-wrap: wrap; gap: 7px; }
.exampletokens span { display: grid; gap: 2px; padding: 7px 9px; border-radius: 8px; background: #fff; color: var(--muted); font-size: 9px; }
.exampletokens b { color: var(--ink); font-size: 11px; }
.questionexamples { display: grid; gap: 6px; margin: 13px 0 0; }
.questionexamples > div { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; padding-top: 7px; border-top: 1px solid #d8e7e1; }
.questionexamples dt { font-size: 11px; font-weight: 650; }
.questionexamples dd { margin: 0; color: var(--teal); font-size: 11px; font-weight: 750; text-align: right; }
.sharednotice { margin-top: 24px; padding: 13px 14px; border-left: 4px solid var(--gold); border-radius: 0 10px 10px 0; background: #fff7e7; color: #6f5525; font-size: 12px; line-height: 1.55; }
.helpscope { margin-top: 24px; padding: 17px; border-radius: 13px; background: var(--ink); color: #eef5f3; }
.helpscope h3 { color: #8ee1d4; }
.helpscope p { margin: 8px 0 0; color: #cfddda; font-size: 12px; line-height: 1.62; }
.helpactions { display: flex; justify-content: flex-end; margin-top: 20px; }
.helpdismiss { border: 0; border-radius: 10px; background: var(--teal); color: #fff; padding: 12px 17px; font-size: 12px; font-weight: 750; box-shadow: 0 8px 20px rgba(8,127,120,.2); }
.helpdismiss:hover { background: var(--deep); }
.helpdismiss span { margin-left: 7px; }

@media (max-width: 980px) {
  .tokenrow, .tokeneditor.compact .tokenrow { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .framegrid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .retrievalcontrols { grid-template-columns: 1fr 1fr; }
  .askrow { grid-template-columns: 1fr 1fr; }
  .askrow label { grid-column: 1/-1; }
}

@media (max-width: 560px) {
  .tokenrow, .tokeneditor.compact .tokenrow, .framegrid, .eventgrid { grid-template-columns: 1fr; }
  .askrow { grid-template-columns: 1fr; }
  .askrow label { grid-column: auto; }
  .choicebar { display: grid; gap: 8px; }
  .retrievalcontrols { grid-template-columns: 1fr; }
  .topactions { gap: 6px; }
  .helpbutton { padding: 8px 10px; font-size: 10px; }
  .helpdialog { width: calc(100% - 16px); max-height: 94dvh; border-radius: 14px; }
  .helpcontent { padding: 0 16px 22px; }
  .helphead { margin: 0 -16px 16px; padding: 18px 16px 14px; }
  .helphead h2 { font-size: 23px; }
  .helpgrid { grid-template-columns: 1fr; }
  .questionexamples > div { grid-template-columns: 1fr; gap: 2px; }
  .questionexamples dd { text-align: left; }
  .helpactions { display: grid; }
  .helpdismiss { width: 100%; }
}
