:root{
  --bg:#f5f7fb;
  --panel:#ffffff;
  --panel2:#f8fafc;
  --text:#0f172a;
  --muted:#475569;
  --accent:#0284c7;
  --ok:#16a34a;
  --bad:#dc2626;
  --warn:#d97706;

  --cellW:92px;
  --cellH:28px;
  --cols:10;
  --rows:15;
  --hdrW:52px;
  --hdrH:28px;
  --radius:16px;
  --shadow: 0 12px 30px rgba(15,23,42,.12);
  font-synthesis-weight: none;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans";
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 15% 10%, rgba(2,132,199,.10), transparent 55%),
    radial-gradient(900px 700px at 90% 20%, rgba(22,163,74,.08), transparent 55%),
    var(--bg);
}

header{
  padding:18px 18px 8px;
  display:flex;
  gap:12px;
  align-items:flex-end;
  justify-content:space-between;
}

.brand{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.brand h1{
  margin:0;
  font-size:18px;
  letter-spacing:.2px;
  font-weight:800;
}
.brand p{
  margin:0;
  color:var(--muted);
  font-size:13px;
  line-height:1.25;
  max-width:64ch;
}

.pill{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding:8px 10px;
  background:rgba(255,255,255,.75);
  border:1px solid rgba(15,23,42,.10);
  border-radius:999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.70);
  color:var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.pill b{color:var(--text); font-weight:800}

main{
  padding:10px 18px 20px;
  display:grid;
  grid-template-columns: 1fr;
  gap:16px;
  align-items:start;
}

.topTaskPanelWrap{
  padding:0 18px 10px;
}

.topTaskPanel{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.topTaskActionsBar{
  width:100%;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.82);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.topTaskActionsBar .btnRow{
  width:100%;
  margin:0;
}

.topTaskActionsBar .btnRow button{
  flex:1 1 180px;
}

.topTaskGrid{
  display:grid;
  grid-template-columns: minmax(260px, 1.15fr) minmax(240px, .95fr) minmax(240px, .9fr);
  gap:12px;
  align-items:start;
}

.topTaskGrid[hidden]{
  display:none !important;
}

.topTaskBlock{
  min-width:0;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.82);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.topTaskBlockTitle{
  font-weight:900;
  font-size:12px;
  letter-spacing:.2px;
  color:var(--muted);
  text-transform:uppercase;
}

.taskIntroBlock .taskTitle{
  margin-top:0;
}

.taskMetaBlock .meta{
  margin:0;
  height:100%;
}

.taskMetaBlock .goalCheckBtn{
  width:100%;
  margin-top:auto;
}

.taskActionsBlock .btnRow{
  margin-top:0;
}

.taskActionsBlock .feedback{
  min-height:48px;
}


.taskRefBlock .refBtnRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.taskRefBlock .refBtnRow button{
  flex:1 1 220px;
}
.taskRefBlock details{
  margin:0;
  background: rgba(255,255,255,.9);
}

.taskRefBlock .refList{
  max-height:176px;
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,1), rgba(248,250,252,1));
  border:1px solid rgba(15,23,42,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

/* Sheet */
.sheetCard{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.fxRow{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.fxUndoRedo{
  display:flex;
  gap:6px;
  align-items:center;
}
.iconBtn{
  min-width:36px;
  height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  font-size:15px;
  line-height:1;
}
.iconBtn:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.addr{
  min-width:66px;
  padding:9px 10px;
  border-radius:12px;
  background:rgba(248,250,252,.90);
  border:1px solid rgba(15,23,42,.10);
  font-size:12px;
  color:var(--muted);
}
.addr b{color:var(--text)}
.fxTag{
  padding:9px 10px;
  border-radius:12px;
  background:rgba(2,132,199,.10);
  border:1px solid rgba(2,132,199,.22);
  color:var(--text);
  font-weight:800;
  font-size:12px;
  letter-spacing:.2px;
}

.formulaField{
  position:relative;
  flex:1;
  min-width:240px;
  border-radius:12px;
  background:#fff;
  border:1px solid rgba(15,23,42,.12);
  font-family: inherit;
  font-size:13px;
  font-weight:400;
  line-height:1.35;
  letter-spacing:normal;
}
.formulaField:focus-within{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
}
.formulaMirror{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  padding:10px 12px;
  border-radius:inherit;
  pointer-events:none;
  white-space:pre;
  overflow:hidden;
  color:var(--text);
  font: inherit;
  line-height:inherit;
  letter-spacing:inherit;
}
.formulaMirrorCell{
  padding:6px 8px;
  font-size:12px;
}
.formulaMirrorContent{
  display:inline-block;
  min-width:100%;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  transform: translateX(calc(-1 * var(--mirror-scroll-left, 0px)));
}
.formulaRefToken{
  font-weight: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}
#formulaBar{
  position:relative;
  z-index:1;
  width:100%;
  padding:10px 12px;
  border:0;
  border-radius:12px;
  background:transparent;
  color:transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  outline:none;
  font: inherit;
  line-height:inherit;
  letter-spacing:inherit;
}
#formulaBar::placeholder{
  color:var(--muted);
  -webkit-text-fill-color: var(--muted);
}

.fmtGroup{
  display:flex;
  gap:8px;
  align-items:center;
}

.fmtTextToggles{
  display:flex;
  gap:6px;
  align-items:center;
  padding:4px;
  border-radius:12px;
  background:rgba(248,250,252,.90);
  border:1px solid rgba(15,23,42,.10);
}

.fmtToggleBtn{
  min-width:34px;
  height:34px;
  padding:0 10px;
  border-radius:10px;
  border:1px solid rgba(15,23,42,.10);
  background:#fff;
  color:var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:14px;
  line-height:1;
  transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease, transform .08s ease;
}
.fmtToggleBtn:hover{
  background:rgba(2,132,199,.06);
  border-color:rgba(2,132,199,.22);
}
.fmtToggleBtn:active{
  transform:translateY(1px);
}
.fmtToggleBtn.isActive{
  background:rgba(2,132,199,.12);
  border-color:rgba(2,132,199,.34);
  box-shadow: inset 0 0 0 1px rgba(2,132,199,.20);
}

.fmtItem{
  display:flex;
  align-items:center;
  gap:6px;
  padding:6px 8px;
  border-radius:12px;
  background:rgba(248,250,252,.90);
  border:1px solid rgba(15,23,42,.10);
  color:var(--muted);
  font-size:12px;
  white-space:nowrap;
}

.fmtLbl{
  width:16px;
  text-align:center;
  font-weight:900;
  color:var(--text);
}

.fmtItem input[type="color"]{
  width:30px;
  height:30px;
  padding:0;
  border:none;
  background:transparent;
  cursor:pointer;
}

.fmtItem input[type="color"]::-webkit-color-swatch-wrapper{ padding:0; }
.fmtItem input[type="color"]::-webkit-color-swatch,
.fmtItem input[type="color"]::-moz-color-swatch{
  border-radius:8px;
  border:1px solid rgba(15,23,42,.18);
}

.fmtItem select{
  height:30px;
  padding:0 8px;
  border-radius:10px;
  border:1px solid rgba(15,23,42,.18);
  background:#fff;
  color:var(--text);
  font-weight:800;
  font-size:12px;
  outline:none;
}
.fmtItem select:focus{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
}

.fxToggles{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.fxSwitch{
  position:relative;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:42px;
  padding:6px 10px 6px 12px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,245,249,.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72);
  cursor:pointer;
  user-select:none;
}

.fxSwitch input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.fxSwitchCaption{
  font-size:11px;
  line-height:1;
  font-weight:900;
  letter-spacing:.24px;
  text-transform:uppercase;
  color:var(--muted);
}

.fxSwitchTrack{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  width:122px;
  height:28px;
  padding:3px;
  border-radius:999px;
  background:rgba(15,23,42,.08);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.12);
  transition:background .2s ease;
}

.fxSwitchTrack::before{
  content:'';
  position:absolute;
  left:3px;
  top:3px;
  width:58px;
  height:22px;
  border-radius:999px;
  background:#fff;
  box-shadow: 0 4px 12px rgba(15,23,42,.16);
  transition:transform .2s ease;
}

.fxSwitchTrack::after{
  content:attr(data-off);
  position:relative;
  z-index:1;
  width:100%;
  text-align:center;
  font-size:11px;
  font-weight:900;
  letter-spacing:.2px;
  color:var(--text);
}

.fxSwitch input:checked ~ .fxSwitchTrack{
  background:rgba(2,132,199,.18);
}

.fxSwitch input:checked ~ .fxSwitchTrack::before{
  transform:translateX(58px);
}

.fxSwitch input:checked ~ .fxSwitchTrack::after{
  content:attr(data-on);
}

.fxSwitch:hover{
  border-color:rgba(2,132,199,.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82), 0 6px 16px rgba(2,132,199,.08);
}

.fxSwitch:focus-within{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
}

#clearSheetBtn,
#clearFormatBtn{
  padding:9px 12px;
  height:34px;
  border-radius:12px;
  font-weight:800;
}

.sheetWrap{
  position:relative;
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(15,23,42,.10);
  background:#fff;
  user-select:none;
}

.sheetScroll{
  width:100%;
  height: min(62vh, 560px);
  overflow:auto;
  background:#fff;
}

.gridHost{
  position:relative;
  width: calc(var(--hdrW) + var(--cols) * var(--cellW));
  height: calc(var(--hdrH) + var(--rows) * var(--cellH));
}


.gridScale{
  position:absolute;
  left:0;
  top:0;
  width: calc(var(--hdrW) + var(--cols) * var(--cellW));
  height: calc(var(--hdrH) + var(--rows) * var(--cellH));
  transform-origin: 0 0;
}

.grid{
  position:absolute;
  inset:0;
  display:grid;
  grid-template-columns: var(--hdrW) repeat(var(--cols), var(--cellW));
  grid-template-rows: var(--hdrH) repeat(var(--rows), var(--cellH));
  border-left:1px solid rgba(15,23,42,0.14);
  border-top:1px solid rgba(15,23,42,0.14);
  font-family: ui-sans-serif, system-ui;
}

.hdr, .cell{
  box-sizing:border-box;
  border-right:1px solid rgba(15,23,42,0.14);
  border-bottom:1px solid rgba(15,23,42,0.14);
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
  font-size:12px;
  padding:5px 8px;
  display:flex;
  align-items:center;
}

.hdr{
  justify-content:center;
  font-weight:900;
  color: rgba(15,23,42,0.72);
  background: rgba(15,23,42,0.035);
  user-select:none;
  transition: background-color .14s ease, color .14s ease, box-shadow .14s ease;
}

.hdr.hdrHover{
  background: rgb(229 242 249);
  color: rgba(2,132,199,1);
}

.hdr.hdrSelected{
  background: rgba(2,132,199,1);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(2,132,199,1);
}

.corner{
  background: rgba(15,23,42,0.02);
  position:sticky;
  left:0;
  top:0;
  z-index:5;
}

.colHdr{
  position:sticky;
  top:0;
  z-index:4;
}

.rowHdr{
  position:sticky;
  left:0;
  z-index:3;
}

.cell{
  justify-content:flex-start;
  color: var(--text);
  background:#fff;
  transition: box-shadow .14s ease, outline-color .14s ease;
}

.cell.formulaRef{
  box-shadow: inset 0 0 0 9999px var(--formula-ref-fill, rgba(2,132,199,.08));
  outline: 2px solid var(--formula-ref-stroke, rgba(2,132,199,.42));
  outline-offset: -1px;
}

.cell.formulaRefActive{
  animation: formulaRefBlink 1.05s ease-in-out infinite;
}

@keyframes formulaRefBlink{
  0%, 100%{
    box-shadow: inset 0 0 0 9999px var(--formula-ref-fill, rgba(2,132,199,.08));
    outline-color: var(--formula-ref-stroke, rgba(2,132,199,.42));
  }
  50%{
    box-shadow: inset 0 0 0 9999px rgba(255,255,255,0);
    outline-color: rgba(255,255,255,0);
  }
}

.cell.err{ color: var(--bad); font-weight:900; }
.cell.dim{ color: var(--muted); }

.overlayLayer{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:2;
}

.selectionOverlay{
  position:absolute;
  border: 2px solid rgba(2,132,199,0.85);
  background: rgba(2,132,199,0.10);
  border-radius:8px;
  box-sizing:border-box;
  display:none;
}

.rangeOverlay{
  position:absolute;
  border: 2px dashed rgba(2,132,199,0.65);
  background: rgba(2,132,199,0.06);
  border-radius:8px;
  box-sizing:border-box;
  display:none;
}

.fillHandle{
  position:absolute;
  width:10px;
  height:10px;
  border-radius:3px;
  background: rgba(2,132,199,0.95);
  border:2px solid #fff;
  box-shadow: 0 0 0 1px rgba(2,132,199,0.85);
  z-index:7;
  cursor: crosshair;
}
.fillHandle.dragging{ cursor: grabbing; }


#gridSvg{
  display:block;
  width:100%;
  height:auto;
}

#cellsLayer{
  position:absolute;
  left: var(--hdrW);
  top: var(--hdrH);
  width: calc(var(--cols) * var(--cellW));
  height: calc(var(--rows) * var(--cellH));
  pointer-events:none;
}

.cellText{
  position:absolute;
  width: var(--cellW);
  height: var(--cellH);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  opacity:.95;
}
.cellText.err{ color: var(--bad); opacity:1; }
.cellText.dim{ color: var(--muted); }

#cellEditorWrap{
  position:absolute;
  display:none;
  border-radius:10px;
  background:#fff;
  border:1px solid rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
  z-index: 8;
  overflow:hidden;
  font-family: inherit;
  font-size:12px;
  font-weight:400;
  line-height:1.35;
  letter-spacing:normal;
}
#cellEditorMirror{
  inset:0;
}
#cellEditor{
  position:relative;
  z-index:1;
  width:100%;
  height:100%;
  padding:6px 8px;
  border:0;
  background:transparent;
  color:transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  outline:none;
  font: inherit;
  line-height:inherit;
  letter-spacing:inherit;
}

.sheetHelp{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:12px;
  margin-top:2px;
}
.kbd{
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.75);
}

/* Task panel */
.taskCard{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.taskCard .meta{
  margin-top:2px;
}

.taskTop{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}

select, button, input[type="text"]{
  font-family:inherit;
}

#langMode, #sepMode{
  padding:9px 10px;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.12);
  background:#fff;
  color: var(--text);
  outline:none;
  font-size:13px;
}
#langMode:focus, #sepMode:focus{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
}

/* Filters (v2) */
#difficulty{
  padding:9px 10px;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.12);
  background:#fff;
  color: var(--text);
  outline:none;
  font-size:13px;
  width:100%;
}
#difficulty:focus{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 3px rgba(2,132,199,.16);
}

.filtersBox{
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(248,250,252,1);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.filtersHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.filtersTitle{
  font-weight:900;
  font-size:12px;
  letter-spacing:.2px;
  color:var(--text);
}
.filtersMeta{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
}
.labelRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px;
  gap:10px;
}

.topicChips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.12);
  background: rgba(255,255,255,.85);
  cursor:pointer;
  user-select:none;
  font-size:12px;
  color:var(--text);
}
.chip input{ display:none; }
.chip .dot{
  width:10px; height:10px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.14);
  background: rgba(226,232,240,1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.70);
}
.chip.on{
  border-color: rgba(2,132,199,.30);
  background: rgba(2,132,199,.10);
}
.chip.on .dot{
  border-color: rgba(2,132,199,.45);
  background: rgba(2,132,199,.55);
}
.tinyNote{
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
}

.btnRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
button{
  cursor:pointer;
  padding:9px 10px;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.12);
  background: rgba(255,255,255,.85);
  color: var(--text);
  font-weight:800;
  font-size:12px;
  letter-spacing:.2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.70);
}
button:hover{ border-color: rgba(15,23,42,.20); }
button.primary{
  background: rgba(2,132,199,.10);
  border-color: rgba(2,132,199,.24);
}
button.danger{
  background: rgba(220,38,38,.08);
  border-color: rgba(220,38,38,.22);
}

.taskTitle{
  margin:0;
  font-size:16px;
  letter-spacing:.2px;
}
.taskDesc{
  margin:0;
  color:var(--muted);
  font-size:13px;
  line-height:1.35;
  white-space: pre-line;
}

.meta{
  display:grid;
  grid-template-columns: 1fr;
  gap:6px;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(248,250,252,1);
  font-size:12px;
  color:var(--muted);
}
.meta b{color:var(--text)}
.feedback{
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(248,250,252,1);
  font-size:13px;
  line-height:1.35;
  min-height:58px;
}
.feedback.ok{ border-color: rgba(22,163,74,.28); background: rgba(22,163,74,.07); }
.feedback.bad{ border-color: rgba(220,38,38,.28); background: rgba(220,38,38,.07); }
.feedback.warn{ border-color: rgba(217,119,6,.30); background: rgba(217,119,6,.08); }

details{
  border:1px solid rgba(15,23,42,.10);
  border-radius:14px;
  background: rgba(255,255,255,.75);
  overflow:hidden;
}
summary{
  cursor:pointer;
  padding:10px;
  color:var(--text);
  font-weight:800;
  font-size:12px;
  list-style:none;
}
summary::-webkit-details-marker{display:none}
.refBody{
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  border-top:1px solid rgba(15,23,42,.10);
}
#refSearch{
  padding:10px 12px;
  border-radius:12px;
  background:#fff;
  border:1px solid rgba(15,23,42,.12);
  color:var(--text);
  outline:none;
  font-size:13px;
}
.refList{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:240px;
  overflow:auto;
  padding-right:6px;
}
.refItem{
  padding:9px 10px;
  border-radius:12px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.85);
  display:flex;
  flex-direction:column;
  gap:5px;
}
.refItem .names{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  font-size:12px;
}
.badge{
  padding:2px 8px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.12);
  background: rgba(241,245,249,1);
  color: var(--text);
  font-weight:800;
  letter-spacing:.2px;
}
.refItem .sig{
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
}



.refIntro{
  padding:10px 10px;
  border-radius:12px;
  border:1px dashed rgba(15,23,42,.18);
  background: rgba(2,132,199,.06);
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}
.refIntro b{ color:var(--text); }
.refIntro code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11.5px;
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.10);
  padding: 1px 6px;
  border-radius: 8px;
}

.refItem .desc{
  color:var(--text);
  font-size:12px;
  line-height:1.25;
}
.refItem .ex{
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
}
.refItem code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11.5px;
  background: rgba(241,245,249,1);
  border: 1px solid rgba(15,23,42,.10);
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}
footer{
  padding:0 18px 18px;
  color:var(--muted);
  font-size:12px;
}

@media (max-width: 1280px){
  .topTaskGrid{
    grid-template-columns: 1fr 1fr;
  }
  .taskRefBlock{
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px){
  .topTaskPanelWrap{ padding:0 18px 10px; }
  .topTaskGrid{ grid-template-columns: 1fr; }
  .taskRefBlock{ grid-column:auto; }
  main{ grid-template-columns: 1fr; }
}

@media (max-width: 680px){
  header{
    align-items:flex-start;
    flex-direction:column;
  }
  .fxRow{
    align-items:stretch;
  }
  .fxToggles,
  .fmtGroup{
    width:100%;
    flex-wrap:wrap;
  }
  .fmtTextToggles{
    flex:1 1 100%;
    justify-content:flex-start;
  }
  .fxSwitch{
    flex:1 1 220px;
    justify-content:space-between;
  }
  .topTaskActionsBar .btnRow button{
    flex:1 1 calc(50% - 8px);
  }
  .fxUndoRedo{
    order:2;
  }
  .fxTag{
    order:3;
  }
  #formulaBar{
    order:4;
    width:100%;
  }
  .fxToggles{
    order:5;
  }
  .fmtGroup{
    order:6;
  }
}


@media (max-width: 1380px){
  .topTaskGrid{
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 780px){
  .topTaskGrid{
    grid-template-columns: 1fr;
  }
}

/* Reference modal */
body.modalOpen{
  overflow:hidden;
}

.refModal[hidden]{
  display:none !important;
}

.refModal{
  position:fixed;
  inset:0;
  z-index:1000;
  display:grid;
  place-items:center;
  padding:16px;
}

.refModalBackdrop{
  position:absolute;
  inset:0;
  background: rgba(15,23,42,.50);
  backdrop-filter: blur(2px);
}

.refModalDialog{
  position:relative;
  width:min(860px, calc(100vw - 32px));
  max-height:min(82vh, 760px);
  display:flex;
  flex-direction:column;
  border-radius:16px;
  border:1px solid rgba(15,23,42,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.98));
  box-shadow: 0 24px 64px rgba(15,23,42,.28);
  overflow:hidden;
}


#settingsModalDialog{
  width:min(620px, calc(100vw - 32px));
}
.settingsPanel{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.refModalHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.80);
}

.refModalHeader h3{
  margin:2px 0 0;
  font-size:16px;
  line-height:1.2;
}

.refModalClose{
  width:36px;
  height:36px;
  min-width:36px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  line-height:1;
  padding:0;
}

.refModalBody{
  border-top:none;
  padding:12px 14px 14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
}

.refModalBody .refList{
  max-height:none;
  min-height:0;
  flex:1 1 auto;
  overflow:auto;
}

@media (max-width: 680px){
  .refModal{
    padding:10px;
    align-items:end;
  }
  .refModalDialog{
    width:100%;
    max-height:88vh;
    border-radius:14px;
  }
  .refModalHeader h3{
    font-size:15px;
  }
}
