/**
 * Interface de trabalho do Magistra.
 * Redesenha a aplicação sem alterar a tipografia dos documentos impressos.
 */
@media screen {
  :root {
    --bg: #ece9e2;
    --bg2: #f7f5ef;
    --bg3: #ffffff;
    --bg4: #e8e5db;
    --border: #d9d7cd;
    --border2: #bfc8bd;
    --text: #1d3530;
    --text2: #53645c;
    --text3: #75867d;
    --gold: #b35f3c;
    --gold2: #a75635;
    --gold-bg: #f5e9df;
    --hdr-h: 76px;
    --panel-w: min(47vw, 650px);
    --radius: 10px;
  }

  html { font-size: calc(16px * var(--ui-scale, 1)); }
  body { background: var(--bg); }
  .hdr {
    padding: 0 clamp(1.25rem, 3vw, 3.5rem);
    box-shadow: 0 1px 12px #153d3420;
  }
  .hdr-logo { color: #173e34; font-size: 1.45rem; letter-spacing: -.04em; }
  .hdr-mark { display: block; width: 56px; height: auto; flex: none; }
  .hdr-mark--dark { display: none; }
  :root[data-theme="dark"] .hdr-mark--light { display: none; }
  :root[data-theme="dark"] .hdr-mark--dark { display: block; }
  .hdr-title { color: #68766c; font-size: .7rem; font-weight: 500; }
  .hdr-tabs { align-self: stretch; gap: .25rem; }
  .hdr-access { display: flex; align-items: center; gap: .25rem; }
  .hdr-access .btn { min-width: 42px; justify-content: center; }
  .hdr-access .btn:disabled { opacity: .45; cursor: not-allowed; }
  .hdr-tab {
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    color: #526459;
    font-size: .78rem;
    letter-spacing: .05em;
    padding: 0 1rem;
  }
  .hdr-tab:hover { background: #e9eee7; color: #173e34; }
  .hdr-tab-active { background: transparent; border-bottom-color: #b35f3c; color: #173e34; font-weight: 700; }
  .btn { border-radius: 8px; font-size: .82rem; font-weight: 700; min-height: 40px; padding: .55rem .9rem; }
  .btn-gold { background: #1b5143; color: #fff; }
  .btn-gold:hover { background: #123e33; }
  .btn-outline { border-color: #b9c7ba; color: #1b5143; }
  .btn-outline:hover { background: #e7eee8; border-color: #6b967e; }
  .btn-ghost { color: #526459; }
  .btn-ghost:hover { background: #eef1eb; }
  .pw { min-height: calc(100vh - var(--hdr-h)); }
  .fp {
    background: var(--bg2);
    border-right-color: var(--border);
    gap: 1.5rem;
    padding: clamp(1.5rem, 3vw, 3rem);
  }
  .fp > div:not(.toolbar) { background: #fff; border: 1px solid #e2e4da; border-radius: 14px; padding: 1.3rem 1.4rem; }
  .sec-head {
    border-bottom-color: #e6e6de;
    color: #173e34;
    font-family: var(--font-ui);
    font-size: .92rem;
    font-weight: 700;
    letter-spacing: 0;
    margin-bottom: 1rem;
    padding-bottom: .65rem;
    text-transform: none;
  }
  .fgi > label { color: #56665d; font-size: .82rem; font-weight: 700; letter-spacing: .04em; }
  .fgi input, .fgi select, .fgi textarea {
    background: #fbfcf9;
    border-color: #cfd9d0;
    border-radius: 8px;
    color: #203a32;
    font-size: .91rem;
    min-height: 40px;
    padding: .6rem .7rem;
  }
  .fgi input:focus, .fgi select:focus, .fgi textarea:focus { border-color: #27735e; box-shadow: 0 0 0 3px #27735e22; }
  .fgi input[readonly] { background: #f0f3ed; color: #425b4b; }
  .fgi select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23425b4b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-position: right .8rem center; background-repeat: no-repeat; }
  .ck-box { background: #f9faf7; border-color: #d9e1d7; border-radius: 9px; max-height: 230px; padding: .8rem; }
  .ck-box.empty { color: #68776d; font-style: normal; }
  .ck-item { color: #344c3e; font-size: .94rem; gap: .7rem; padding: .48rem .15rem; }
  .ck-item input[type="checkbox"] { accent-color: #1b5143; height: 20px; min-width: 20px; width: 20px; }
  .ck-item input[type="checkbox"]:checked + label { color: #163b2d; font-weight: 700; }
  .ck-code { background: #e5eee5; border-radius: 4px; color: #225847; font-size: .8rem; }
  .skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 200; background: #173e34; color: #fff; padding: .75rem 1rem; border-radius: 6px; }
  .skip-link:focus { top: 1rem; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  :is(button, input, select, textarea, a, .ck-box):focus-visible { outline: 3px solid #174d3e; outline-offset: 3px; }
  .ck-item:focus-within { background: #e4efe6; border-radius: 4px; }
  .toolbar { border-top-color: #dfe4db; padding-top: 1rem; }
  .pp { background: #e9ebe3; padding: clamp(1.5rem, 3vw, 3rem); }
  .pp-empty {
    align-items: flex-start;
    background: #fdfcf8;
    border: 1px solid #d9dfd3;
    border-radius: 18px;
    box-shadow: 0 18px 45px #123d2f12;
    color: #254739;
    flex: 0 0 auto;
    gap: .9rem;
    margin: auto;
    max-width: 720px;
    min-height: 430px;
    padding: clamp(2rem, 5vw, 4rem);
    width: 100%;
  }
  .pp-empty-kicker { color: #aa5b39; font-size: .72rem; font-weight: 700; letter-spacing: .13em; }
  .pp-empty-ring { border: 0; border-radius: 10px; background: #e4efe6; color: #1b5143; font-family: var(--font-ui); font-size: 1.1rem; font-weight: 700; height: 62px; margin-top: 1.8rem; width: 62px; }
  .pp-empty h2 { font-family: var(--font-disp); font-size: clamp(2rem, 3vw, 3rem); font-weight: 400; line-height: 1.14; max-width: 560px; }
  .pp-empty p { color: #587061; font-size: 1rem; line-height: 1.6; max-width: 500px; }
  #doc, #doc-folha { border-radius: 3px; box-shadow: 0 14px 42px #1e33232d; }
  :root[data-theme="dark"] {
    --bg: #0f0e0d;
    --bg2: #181714;
    --bg3: #201e1b;
    --bg4: #272420;
    --border: #3c3830;
    --border2: #675b43;
    --text: #e4ddd0;
    --text2: #c3b8a8;
    --text3: #aba08f;
    --gold: #c49a3c;
    --gold2: #a17a2a;
    --gold-bg: #30281b;
  }
  :root[data-theme="dark"] .hdr { box-shadow: 0 1px 12px #0006; }
  :root[data-theme="dark"] .hdr-logo { color: #c49a3c; }
  :root[data-theme="dark"] .sec-head { color: #d8b764; }
  :root[data-theme="dark"] .hdr-title,
  :root[data-theme="dark"] .hdr-tab,
  :root[data-theme="dark"] .btn-ghost { color: var(--text2); }
  :root[data-theme="dark"] .hdr-tab:hover,
  :root[data-theme="dark"] .btn-ghost:hover,
  :root[data-theme="dark"] .btn-outline:hover { background: #30281b; color: #f1d591; }
  :root[data-theme="dark"] .hdr-tab-active { border-bottom-color: var(--gold); color: #f1d591; }
  :root[data-theme="dark"] .btn-gold { background: #c49a3c; color: #17130d; }
  :root[data-theme="dark"] .btn-gold:hover { background: #dfb65a; }
  :root[data-theme="dark"] .btn-outline { border-color: #8a6820; color: #e1bd68; }
  :root[data-theme="dark"] .fp > div:not(.toolbar),
  :root[data-theme="dark"] .pp-empty { background: #201e1b; border-color: #3c3830; }
  :root[data-theme="dark"] .sec-head,
  :root[data-theme="dark"] .toolbar { border-color: #3c3830; }
  :root[data-theme="dark"] .fgi > label { color: #d1c5b4; }
  :root[data-theme="dark"] .fgi input,
  :root[data-theme="dark"] .fgi select,
  :root[data-theme="dark"] .fgi textarea,
  :root[data-theme="dark"] .ck-box { background: #181714; border-color: #514a3d; color: #eee5d7; }
  :root[data-theme="dark"] .fgi input[readonly] { background: #302b24; color: #e4d8c6; }
  :root[data-theme="dark"] .fgi select { background-image: none; appearance: auto; }
  :root[data-theme="dark"] .fgi input::placeholder,
  :root[data-theme="dark"] .fgi textarea::placeholder { color: #b9ad9d; opacity: 1; }
  :root[data-theme="dark"] .ck-item,
  :root[data-theme="dark"] .ck-box.empty { color: #d5c9ba; }
  :root[data-theme="dark"] .ck-item input[type="checkbox"] { accent-color: #c49a3c; }
  :root[data-theme="dark"] .ck-item input[type="checkbox"]:checked + label { color: #fff1d0; }
  :root[data-theme="dark"] .ck-code,
  :root[data-theme="dark"] .pp-empty-ring { background: #30281b; color: #f1d591; }
  :root[data-theme="dark"] .ck-item:focus-within { background: #30281b; }

  /* Habilidades BNCC: a linha inteira indica a seleção, sem controle nativo visível. */
  .fh-cross-year { position: relative; display: block; width: fit-content; max-width: 100%; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
  .fh-cross-year input[type="checkbox"] { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
  .fh-cross-year:has(input:checked) { background: #e2eee5; border-color: #43826a; box-shadow: 0 0 0 2px #43826a33, 0 0 16px #43826a33; color: #163b2d; }
  .fh-cross-year:has(input:focus-visible) { outline: 3px solid #174d3e; outline-offset: 2px; }
  :root[data-theme="dark"] .fh-cross-year:has(input:checked) { background: #3a301c; border-color: #e1bd68; box-shadow: 0 0 0 2px #e1bd6840, 0 0 18px #e1bd684d; color: #fff1d0; }
  :root[data-theme="dark"] .fh-cross-year:has(input:focus-visible) { outline-color: #e1bd68; }
  :is(#box-bncc, #box-fh-hab) .ck-item { position: relative; padding: 0; margin: .3rem 0; }
  :is(#box-bncc, #box-fh-hab) .ck-item input[type="checkbox"] { position: absolute; width: 1px; min-width: 1px; height: 1px; margin: 0; opacity: 0; }
  :is(#box-bncc, #box-fh-hab) .ck-item label { display: block; width: 100%; padding: .65rem .8rem; border: 1px solid transparent; border-radius: 7px; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
  :is(#box-bncc, #box-fh-hab) .ck-item input:checked + label { background: #e2eee5; border-color: #43826a; box-shadow: 0 0 0 2px #43826a33, 0 0 16px #43826a33; color: #163b2d; }
  :is(#box-bncc, #box-fh-hab) .ck-item input:focus-visible + label { outline: 3px solid #174d3e; outline-offset: 2px; }
  :root[data-theme="dark"] :is(#box-bncc, #box-fh-hab) .ck-item input:checked + label { background: #3a301c; border-color: #e1bd68; box-shadow: 0 0 0 2px #e1bd6840, 0 0 18px #e1bd684d; color: #fff1d0; }
  :root[data-theme="dark"] :is(#box-bncc, #box-fh-hab) .ck-item input:focus-visible + label { outline-color: #e1bd68; }
  /* Assuntos: controle pequeno e explícito, com destaque da linha selecionada. */
  #fh-topico .ck-item { align-items: center; position: relative; gap: .6rem; padding: .35rem .45rem; margin: .2rem 0; border: 1px solid transparent; border-radius: 7px; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
  .fgi #fh-topico .ck-item input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: 0 0 18px; width: 18px; min-width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; border: 1.5px solid #43826a; border-radius: 4px; background: #fff; cursor: pointer; }
  .fgi #fh-topico .ck-item input[type="checkbox"]:checked { background: #1b5143; border-color: #1b5143; }
  .fgi #fh-topico .ck-item input[type="checkbox"]:checked::after { content: "×"; display: block; color: #fff; font-size: 17px; font-weight: 700; line-height: 14px; text-align: center; }
  #fh-topico .ck-item label { flex: 1; }
  #fh-topico .ck-item:has(input:checked) { background: #e2eee5; border-color: #43826a; box-shadow: 0 0 0 2px #43826a33, 0 0 16px #43826a33; }
  #fh-topico .ck-item:has(input:focus-visible) { outline: 3px solid #174d3e; outline-offset: 2px; }
  :root[data-theme="dark"] .fgi #fh-topico .ck-item input[type="checkbox"] { background: #181714; border-color: #e1bd68; }
  :root[data-theme="dark"] .fgi #fh-topico .ck-item input[type="checkbox"]:checked { background: #e1bd68; }
  :root[data-theme="dark"] .fgi #fh-topico .ck-item input[type="checkbox"]:checked::after { color: #181714; }
  :root[data-theme="dark"] #fh-topico .ck-item:has(input:checked) { background: #3a301c; border-color: #e1bd68; box-shadow: 0 0 0 2px #e1bd6840, 0 0 18px #e1bd684d; }
  :root[data-theme="dark"] #fh-topico .ck-item:has(input:focus-visible) { outline-color: #e1bd68; }
  :root[data-theme="dark"] .pp { background: #141310; }
  :root[data-theme="dark"] .pp-empty,
  :root[data-theme="dark"] .pp-empty p { color: #d5c9ba; }
  :root[data-theme="dark"] .pp-empty-kicker { color: #e1bd68; }
  :root[data-theme="dark"] :is(button, input, select, textarea, a, .ck-box):focus-visible { outline-color: #e1bd68; }
  :root[data-theme="dark"] .skip-link { background: #c49a3c; color: #17130d; }
  @media (max-width: 1100px) {
    :root { --panel-w: 48vw; }
    .hdr { flex-wrap: wrap; gap: .5rem; height: auto; min-height: 76px; padding-bottom: .7rem; padding-top: .7rem; }
    .hdr-tabs { align-self: auto; }
    .hdr-access { justify-content: center; }
    .hdr-tab { min-height: 40px; }
    .pw { height: auto; min-height: calc(100vh - var(--hdr-h)); }
    .fp, .pp { overflow: visible; }
  }
  @media (max-width: 760px) {
    .pw { height: auto; }
    .hdr { justify-content: center; }
    .hdr-brand { justify-content: center; width: 100%; }
    .hdr-access { order: 3; width: 100%; }
    .fp { padding: 1rem; }
    .fp > div:not(.toolbar) { padding: 1rem; }
    .pp { padding: 1rem; }
    .pp-empty { min-height: 340px; }
    #doc, #doc-folha { padding: 1.5rem; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  }
}
