
    * { box-sizing: border-box; }

    :root {
      --bg: #ececec;
      --card: #f4f4f4;
      --white: #ffffff;
      --yellow: #f5e100;
      --title-yellow: #ead61c;
      --title-green: #23a045;
      --green: #06a936;
      --blue: #1e5abc;
      --dot-blue: #4b6fae;
      --dot-gray: #a3b1c7;
      --active-blue: #2563eb;
      --text-gray: #9b9b9b;
      --icon-gray: #a2a2a2;
      --shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
    }

    html, body {
      margin: 0;
      min-height: 100%;
      height: 100%;
      font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      background: var(--bg);
      color: #444;
    }

    body {
      display: flex;
      width: 100%;
      min-height: 100svh;
      overflow: hidden;
      overscroll-behavior: none;
      -webkit-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
      justify-content: center;
      align-items: stretch;
    }

    .app {
      position: relative;
      --nav-height: 65px;
      width: 100%;
      max-width: 430px;
      height: 100dvh;
      min-height: 100svh;
      background: var(--bg);
      padding-bottom: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .top-space {
      position: relative;
      height: clamp(54px, 6vh, 96px);
      flex: 0 0 auto;
    }
    .top-logo {
      position: absolute;
      left: 16px;
      top: 7px;
      max-width: 98px;
      max-height: 43px;
      width: auto;
      height: auto;
      object-fit: contain;
      object-position: left top;
    }

    .header-wrap {
      display: flex;
      justify-content: center;
      position: relative;
      z-index: 2;
      /* A imagem inclui uma margem superior; sobrepõe metade dessa faixa com o rótulo. */
      transform: translateY(clamp(14px, 3.3vh, 30px));
      margin-bottom: 0;
      padding: 0 20px;
    }

    .header-tag {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: var(--title-yellow);
      color: var(--title-green);
      font-size: 11.2px;
      font-weight: 700;
      letter-spacing: 0.14px;
      line-height: 1;
      text-transform: uppercase;
      padding: 7.7px 8.4px 7px;
      white-space: nowrap;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .doc-area {
      position: relative;
      width: min(calc(100% - 24px), 430px);
      height: auto;
      min-height: 0;
      margin: 0 auto;
      background: var(--bg);
      flex: 1 1 auto;
      aspect-ratio: var(--doc-ratio, 0.72);
      max-height: none;
      overflow: hidden;
    }
    .doc-slider {
      position: absolute;
      inset: 0;
      display: flex;
      background: var(--bg);
      overflow-x: auto;
      overflow-y: hidden;
      scroll-snap-type: x mandatory;
      scroll-behavior: smooth;
      scrollbar-width: none;
      overscroll-behavior-x: contain;
      touch-action: pan-x pan-y;
    }
    .doc-slider::-webkit-scrollbar { display: none; }
    .doc-slide {
      flex: 0 0 100%;
      min-width: 0;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 0;
      background: var(--bg);
      scroll-snap-align: start;
      scroll-snap-stop: always;
    }
    .doc-slide img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: contain;
      user-select: none;
      -webkit-user-drag: none;
    }

    .controls {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 16px 16px 16px;
      flex: 0 0 auto;
    }

    .control-btn {
      width: 43px;
      height: 43px;
      border: 0;
      border-radius: 14px;
      background: var(--card);
      box-shadow: var(--shadow);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
      flex: 0 0 43px;
    }

    .control-btn svg {
      width: 24px;
      height: 24px;
    }

    .more-btn {
      background: var(--green);
    }

    .pager-wrap {
      flex: 1 1 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 0;
      gap: 24px;
    }

    .pager {
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .pager-dot {
      appearance: none;
      padding: 0;
      border: 0;
      flex: 0 0 11px;
      width: 11px;
      height: 11px;
      border-radius: 50%;
      background: var(--dot-gray);
      cursor: pointer;
    }
    .pager-dot:focus-visible, .pager-next:focus-visible,
    .nav-item:focus-visible, .control-btn:focus-visible {
      outline: 2px solid var(--blue);
      outline-offset: 4px;
    }

    .pager-dot.active {
      background: var(--dot-blue);
    }

    .pager-next {
      border: 0;
      background: transparent;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    .pager-next svg {
      width: 20px;
      height: 32px;
      stroke: var(--blue);
      stroke-width: 3;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    /* Barra inferior alinhada pela mesma linha de base para os 4 rótulos, com safe-area contínua e círculo do QR centralizado. */
    .nav-bar {
      width: 100%;
      height: calc(var(--nav-height) + env(safe-area-inset-bottom));
      flex: 0 0 calc(var(--nav-height) + env(safe-area-inset-bottom));
      display: flex;
      justify-content: space-around;
      align-items: stretch;
      border-top: 1px solid #e6e6e6;
      background: #fff;
      margin-top: 0;
      padding: 0 4px env(safe-area-inset-bottom);
      position: relative;
      z-index: 31;
      overflow: visible;
    }

    .nav-item {
      flex: 1 1 20%;
      width: 20%;
      min-width: 0;
      height: 100%;
      padding: 6px 2px 9px;
      appearance: none;
      border: 0;
      background: transparent;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-end;
      gap: 4px;
      color: #777;
      font-family: inherit;
      font-size: 10.5px;
      font-weight: 500;
      line-height: 1.15;
      cursor: pointer;
      text-decoration: none;
      -webkit-tap-highlight-color: transparent;
      transition: color .15s ease;
    }
    .nav-item:active { opacity: .78; }
    .nav-item > span:last-child {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }
    .nav-item.active {
      color: var(--active-blue);
      font-weight: 600;
    }
    .nav-item.active .nav-icon { color: var(--active-blue); }
    .nav-item[aria-label="QR Code"].active { color: var(--green); }
    .nav-icon {
      display: block;
      flex: 0 0 22px;
      width: 22px;
      height: 22px;
      fill: currentColor;
    }
    /* O ícone do menu é formado por três traços abertos, então precisa de stroke. */
    .nav-item[aria-label="Menu"] .nav-icon {
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
    }
    .qr-circle {
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
      border-radius: 50%;
      background: var(--green);
      display: grid;
      place-items: center;
      margin-top: -12px;
      margin-bottom: 1px;
      box-shadow: 0 3px 10px rgba(6, 169, 54, 0.28);
      transition: transform .15s ease, box-shadow .15s ease;
    }
    .qr-circle svg { width: 20px; height: 20px; fill: #fff; }
    /* O QR Code é a única ação verde; os demais ícones ativos usam azul. */
    .nav-item.active .qr-circle {
      background: var(--green);
      box-shadow: 0 4px 12px rgba(6, 169, 54, 0.36);
    }

    /* A prancheta inteira ocupa exatamente a mesma área de 22 x 22 px dos SVGs e segue currentColor. */
    .clipboard {
      position: relative;
      display: block;
      flex: 0 0 22px;
      width: 22px;
      height: 22px;
      margin: 0;
      background: transparent;
      color: inherit;
    }
    .clipboard::before {
      content: "";
      position: absolute;
      top: 3px;
      left: 1px;
      width: 20px;
      height: 19px;
      border-radius: 3px;
      background: currentColor;
    }
    .clipboard::after {
      content: "";
      position: absolute;
      top: 0;
      left: 6px;
      width: 10px;
      height: 5px;
      border-radius: 2px 2px 0 0;
      background: currentColor;
    }
    .nav-item.active .clipboard::before,
    .nav-item.active .clipboard::after { background: var(--active-blue); }
    .clip-line {
      position: absolute;
      left: 5px;
      height: 2px;
      border-radius: 2px;
      background: #fff;
      z-index: 1;
    }
    .clip-line-top { top: 8px; width: 12px; }
    .clip-line-mid { top: 13px; left: 9px; width: 8px; }
    .clip-line-bot { top: 18px; left: 9px; width: 8px; }
    .clip-dot {
      position: absolute;
      left: 5px;
      width: 2px;
      height: 2px;
      border-radius: 50%;
      background: #fff;
      z-index: 1;
    }
    .clip-dot-mid { top: 13px; }
    .clip-dot-bot { top: 18px; }

    @media (max-width: 390px) {
      .top-space { height: clamp(47px, 6vh, 78px); }
      .top-logo { max-height: 38px; max-width: 90px; }
      .header-tag { font-size: 9.8px; }
      .doc-area { width: calc(100% - 26px); }
      .control-btn { width: 39px; height: 39px; border-radius: 13px; flex-basis: 39px; }
    }
    @media (max-width: 600px), (pointer: coarse) {
      .app { max-width: 100vw; }
      .doc-area { width: calc(100% - 24px); }
    }
  
    .app-dialog {
      width: min(92vw, 550px);
      max-height: 90dvh;
      border: 0;
      padding: 16px;
      border-radius: 16px;
      box-shadow: 0 20px 75px rgba(0,0,0,.3);
      background: #fff;
      color: #243b29;
    }
    .app-dialog::backdrop { background: rgba(0,0,0,.75); }
    .dialog-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
    .dialog-head strong { font-size:14px; }
    .dialog-close { font:inherit; border:0; padding:5px 10px; background:#edf2ef; border-radius:7px; cursor:pointer; }
    .dialog-image { display:block; width:100%; height:auto; max-height:75dvh; object-fit:contain; background:var(--bg); }
    .options-menu { position:absolute; right:86px; top:50%; transform:translateY(-50%); z-index:10; display:grid; gap:4px; max-width:calc(100% - 96px); background:#fff; padding:8px; border-radius:10px; box-shadow:0 12px 35px #0002; }
    .options-menu[hidden] { display:none; }
    .options-menu[data-source="nav"] { position:fixed; right:12px; bottom:calc(var(--nav-height) + env(safe-area-inset-bottom) + 8px); top:auto; transform:none; z-index:60; }
    .options-menu button { background:transparent; text-align:left; border:0; padding:9px 14px; cursor:pointer; font:inherit; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .options-menu button:hover { background:#f5f5f5; }
    input, textarea, select, button, [contenteditable="true"] {
      -webkit-user-select: auto;
      user-select: auto;
    }
    img, svg { -webkit-user-drag: none; }
    @media (max-width: 340px) {
      .top-space { height: 48px; }
      .header-wrap { padding: 0 12px; margin-bottom: 0; }
      .header-tag { font-size: 9px; padding: 7px 6px; }
      .doc-area { width: calc(100% - 20px); }
      .controls { gap: 7px; padding: 10px 8px 8px; }
      .control-btn { width: 35px; height: 35px; flex-basis: 35px; border-radius: 11px; }
      .control-btn svg { width: 20px; height: 20px; }
      .pager { gap: 10px; }
      .pager-wrap { gap: 10px; }
      .nav-item { font-size: 9px; }
      .app { --nav-height: 62px; }
      .nav-item { padding: 5px 2px 7px; font-size: 9.5px; }
      .qr-circle { width: 36px; height: 36px; flex-basis: 36px; margin-top: -10px; }
    }
    @media (max-height: 600px) and (orientation: landscape) {
      .top-space { height: 42px; }
      .header-wrap { margin-bottom: 0; }
      .doc-area { max-height: none; }
      .controls { padding-top: 8px; padding-bottom: 6px; }
      .control-btn { width: 34px; height: 34px; flex-basis: 34px; }
      .app { --nav-height: 56px; }
    }
    @media (prefers-reduced-motion: reduce) { .doc-slider { scroll-behavior:auto; } }
